Skip to content

Commit 435f5a8

Browse files
committed
[NTOSKRNL/MM]
- Make MmWorkingSetList PTE local - Map MmWorkingSetList to Vm.VmWorkingSetList when creating process. svn path=/trunk/; revision=55761
1 parent 8df2149 commit 435f5a8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

reactos/ntoskrnl/mm/ARM3/procsup.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,8 @@ NTAPI
904904
MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess)
905905
{
906906
PMMPFN Pfn1;
907+
PMMPTE sysPte;
908+
MMPTE tempPte;
907909

908910
/* Setup some bogus list data */
909911
MmWorkingSetList->LastEntry = CurrentProcess->Vm.MinimumWorkingSetSize;
@@ -923,6 +925,12 @@ MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess)
923925
Pfn1 = MiGetPfnEntry(CurrentProcess->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT);
924926
ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1));
925927
Pfn1->u1.Event = (PKEVENT)CurrentProcess;
928+
929+
/* Map the process working set in kernel space */
930+
sysPte = MiReserveSystemPtes(1, SystemPteSpace);
931+
MI_MAKE_HARDWARE_PTE_KERNEL(&tempPte, sysPte, MM_READWRITE, CurrentProcess->WorkingSetPage);
932+
MI_WRITE_VALID_PTE(sysPte, tempPte);
933+
CurrentProcess->Vm.VmWorkingSetList = MiPteToAddress(sysPte);
926934
}
927935

928936
NTSTATUS
@@ -1220,6 +1228,8 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
12201228
/* Now write the PTE/PDE entry for the working set list index itself */
12211229
TempPte = ValidKernelPte;
12221230
TempPte.u.Hard.PageFrameNumber = WsListIndex;
1231+
/* Hyperspace is local */
1232+
MI_MAKE_LOCAL_PAGE(&TempPte);
12231233
PdeOffset = MiAddressToPteOffset(MmWorkingSetList);
12241234
HyperTable[PdeOffset] = TempPte;
12251235

@@ -1377,6 +1387,7 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process)
13771387
MiDecrementShareCount(Pfn2, Pfn1->u4.PteFrame);
13781388
MiDecrementShareCount(Pfn1, Process->WorkingSetPage);
13791389
ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress));
1390+
MiReleaseSystemPtes(MiAddressToPte(Process->Vm.VmWorkingSetList), 1, SystemPteSpace);
13801391

13811392
/* Now map hyperspace and its page table */
13821393
PageFrameIndex = Process->Pcb.DirectoryTableBase[1] >> PAGE_SHIFT;
@@ -1388,7 +1399,7 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process)
13881399
MiDecrementShareCount(Pfn2, Pfn1->u4.PteFrame);
13891400
MiDecrementShareCount(Pfn1, PageFrameIndex);
13901401
ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress));
1391-
1402+
13921403
/* Finally, nuke the PDE itself */
13931404
PageFrameIndex = Process->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT;
13941405
Pfn1 = MiGetPfnEntry(PageFrameIndex);
@@ -1399,6 +1410,8 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process)
13991410
/* HACK: In Richard's original patch this ASSERT did work */
14001411
//DPRINT1("Ref count: %lx %lx\n", Pfn1->u3.e2.ReferenceCount, Pfn1->u2.ShareCount);
14011412
//ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress));
1413+
if(!((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress)))
1414+
DPRINT1("Ref count: %lx %lx\n", Pfn1->u3.e2.ReferenceCount, Pfn1->u2.ShareCount);
14021415
}
14031416
else
14041417
{

0 commit comments

Comments
 (0)