From 435f5a8bfd7aa317413b04ac2016211fd750558f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Mon, 20 Feb 2012 20:50:36 +0000 Subject: [PATCH] [NTOSKRNL/MM] - Make MmWorkingSetList PTE local - Map MmWorkingSetList to Vm.VmWorkingSetList when creating process. svn path=/trunk/; revision=55761 --- reactos/ntoskrnl/mm/ARM3/procsup.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index a94db6fb276..eb210948258 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -904,6 +904,8 @@ NTAPI MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess) { PMMPFN Pfn1; + PMMPTE sysPte; + MMPTE tempPte; /* Setup some bogus list data */ MmWorkingSetList->LastEntry = CurrentProcess->Vm.MinimumWorkingSetSize; @@ -923,6 +925,12 @@ MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess) Pfn1 = MiGetPfnEntry(CurrentProcess->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT); ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1)); Pfn1->u1.Event = (PKEVENT)CurrentProcess; + + /* Map the process working set in kernel space */ + sysPte = MiReserveSystemPtes(1, SystemPteSpace); + MI_MAKE_HARDWARE_PTE_KERNEL(&tempPte, sysPte, MM_READWRITE, CurrentProcess->WorkingSetPage); + MI_WRITE_VALID_PTE(sysPte, tempPte); + CurrentProcess->Vm.VmWorkingSetList = MiPteToAddress(sysPte); } NTSTATUS @@ -1220,6 +1228,8 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, /* Now write the PTE/PDE entry for the working set list index itself */ TempPte = ValidKernelPte; TempPte.u.Hard.PageFrameNumber = WsListIndex; + /* Hyperspace is local */ + MI_MAKE_LOCAL_PAGE(&TempPte); PdeOffset = MiAddressToPteOffset(MmWorkingSetList); HyperTable[PdeOffset] = TempPte; @@ -1377,6 +1387,7 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process) MiDecrementShareCount(Pfn2, Pfn1->u4.PteFrame); MiDecrementShareCount(Pfn1, Process->WorkingSetPage); ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress)); + MiReleaseSystemPtes(MiAddressToPte(Process->Vm.VmWorkingSetList), 1, SystemPteSpace); /* Now map hyperspace and its page table */ PageFrameIndex = Process->Pcb.DirectoryTableBase[1] >> PAGE_SHIFT; @@ -1388,7 +1399,7 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process) MiDecrementShareCount(Pfn2, Pfn1->u4.PteFrame); MiDecrementShareCount(Pfn1, PageFrameIndex); ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress)); - + /* Finally, nuke the PDE itself */ PageFrameIndex = Process->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT; Pfn1 = MiGetPfnEntry(PageFrameIndex); @@ -1399,6 +1410,8 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process) /* HACK: In Richard's original patch this ASSERT did work */ //DPRINT1("Ref count: %lx %lx\n", Pfn1->u3.e2.ReferenceCount, Pfn1->u2.ShareCount); //ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress)); + if(!((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress))) + DPRINT1("Ref count: %lx %lx\n", Pfn1->u3.e2.ReferenceCount, Pfn1->u2.ShareCount); } else {