Only update page dir for page containing stack

svn path=/trunk/; revision=4657
This commit is contained in:
Gé van Geldorp 2003-05-08 05:26:36 +00:00
parent 5966a211e9
commit 77d0973eaa
3 changed files with 13 additions and 17 deletions

View file

@ -218,7 +218,7 @@ MmDeleteVirtualMapping(struct _EPROCESS* Process,
BOOL FreePage, BOOL FreePage,
BOOL* WasDirty, BOOL* WasDirty,
PHYSICAL_ADDRESS* PhysicalPage); PHYSICAL_ADDRESS* PhysicalPage);
VOID MmUpdatePageDir(PULONG LocalPageDir); VOID MmUpdatePageDir(PULONG LocalPageDir, PVOID Address);
#define MM_PAGE_CLEAN (0) #define MM_PAGE_CLEAN (0)
#define MM_PAGE_DIRTY (1) #define MM_PAGE_DIRTY (1)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: process.c,v 1.12 2003/05/07 21:41:03 gvg Exp $ /* $Id: process.c,v 1.13 2003/05/08 05:26:36 gvg Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/process.c * FILE: ntoskrnl/ke/process.c
@ -44,6 +44,7 @@ KeAttachProcess (PEPROCESS Process)
{ {
KIRQL oldlvl; KIRQL oldlvl;
PETHREAD CurrentThread; PETHREAD CurrentThread;
PVOID ESP;
PULONG AttachedProcessPageDir; PULONG AttachedProcessPageDir;
ULONG PageDir; ULONG PageDir;
@ -68,8 +69,11 @@ KeAttachProcess (PEPROCESS Process)
To prevent this, make sure the page directory of the process we're To prevent this, make sure the page directory of the process we're
attaching to is up-to-date. */ attaching to is up-to-date. */
__asm__("mov %%esp,%0\n\t"
: "=r" (ESP));
AttachedProcessPageDir = ExAllocatePageWithPhysPage(Process->Pcb.DirectoryTableBase); AttachedProcessPageDir = ExAllocatePageWithPhysPage(Process->Pcb.DirectoryTableBase);
MmUpdatePageDir(AttachedProcessPageDir); MmUpdatePageDir(AttachedProcessPageDir, ESP);
ExUnmapPage(AttachedProcessPageDir); ExUnmapPage(AttachedProcessPageDir);
CurrentThread->OldProcess = PsGetCurrentProcess(); CurrentThread->OldProcess = PsGetCurrentProcess();
@ -77,7 +81,7 @@ KeAttachProcess (PEPROCESS Process)
PageDir = Process->Pcb.DirectoryTableBase.u.LowPart; PageDir = Process->Pcb.DirectoryTableBase.u.LowPart;
DPRINT("Switching process context to %x\n",PageDir) DPRINT("Switching process context to %x\n",PageDir)
__asm__("movl %0,%%cr3\n\t" __asm__("movl %0,%%cr3\n\t"
: /* no inputs */ : /* no outputs */
: "r" (PageDir)); : "r" (PageDir));

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: page.c,v 1.48 2003/05/07 21:41:03 gvg Exp $ /* $Id: page.c,v 1.49 2003/05/08 05:26:36 gvg Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/i386/page.c * FILE: ntoskrnl/mm/i386/page.c
@ -1214,21 +1214,13 @@ MmGetPhysicalAddress(PVOID vaddr)
VOID VOID
MmUpdatePageDir(PULONG LocalPageDir) MmUpdatePageDir(PULONG LocalPageDir, PVOID Address)
{ {
unsigned Entry; unsigned Entry = ADDR_TO_PDE_OFFSET(Address);
for (Entry = ADDR_TO_PDE_OFFSET(KERNEL_BASE); if (0 == LocalPageDir[Entry])
Entry < PAGE_SIZE / sizeof(LONG);
Entry++)
{ {
/* Skip the page directory */ LocalPageDir[Entry] = MmGlobalKernelPageDirectory[Entry];
if (ADDR_TO_PDE_OFFSET(PAGETABLE_MAP) != Entry &&
0 == LocalPageDir[Entry] &&
0 != MmGlobalKernelPageDirectory[Entry])
{
LocalPageDir[Entry] = MmGlobalKernelPageDirectory[Entry];
}
} }
} }