@@ -904,6 +904,8 @@ NTAPI
904
904
MiInitializeWorkingSetList (IN PEPROCESS CurrentProcess )
905
905
{
906
906
PMMPFN Pfn1 ;
907
+ PMMPTE sysPte ;
908
+ MMPTE tempPte ;
907
909
908
910
/* Setup some bogus list data */
909
911
MmWorkingSetList -> LastEntry = CurrentProcess -> Vm .MinimumWorkingSetSize ;
@@ -923,6 +925,12 @@ MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess)
923
925
Pfn1 = MiGetPfnEntry (CurrentProcess -> Pcb .DirectoryTableBase [0 ] >> PAGE_SHIFT );
924
926
ASSERT (Pfn1 -> u4 .PteFrame == MiGetPfnEntryIndex (Pfn1 ));
925
927
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 );
926
934
}
927
935
928
936
NTSTATUS
@@ -1220,6 +1228,8 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
1220
1228
/* Now write the PTE/PDE entry for the working set list index itself */
1221
1229
TempPte = ValidKernelPte ;
1222
1230
TempPte .u .Hard .PageFrameNumber = WsListIndex ;
1231
+ /* Hyperspace is local */
1232
+ MI_MAKE_LOCAL_PAGE (& TempPte );
1223
1233
PdeOffset = MiAddressToPteOffset (MmWorkingSetList );
1224
1234
HyperTable [PdeOffset ] = TempPte ;
1225
1235
@@ -1377,6 +1387,7 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process)
1377
1387
MiDecrementShareCount (Pfn2 , Pfn1 -> u4 .PteFrame );
1378
1388
MiDecrementShareCount (Pfn1 , Process -> WorkingSetPage );
1379
1389
ASSERT ((Pfn1 -> u3 .e2 .ReferenceCount == 0 ) || (Pfn1 -> u3 .e1 .WriteInProgress ));
1390
+ MiReleaseSystemPtes (MiAddressToPte (Process -> Vm .VmWorkingSetList ), 1 , SystemPteSpace );
1380
1391
1381
1392
/* Now map hyperspace and its page table */
1382
1393
PageFrameIndex = Process -> Pcb .DirectoryTableBase [1 ] >> PAGE_SHIFT ;
@@ -1388,7 +1399,7 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process)
1388
1399
MiDecrementShareCount (Pfn2 , Pfn1 -> u4 .PteFrame );
1389
1400
MiDecrementShareCount (Pfn1 , PageFrameIndex );
1390
1401
ASSERT ((Pfn1 -> u3 .e2 .ReferenceCount == 0 ) || (Pfn1 -> u3 .e1 .WriteInProgress ));
1391
-
1402
+
1392
1403
/* Finally, nuke the PDE itself */
1393
1404
PageFrameIndex = Process -> Pcb .DirectoryTableBase [0 ] >> PAGE_SHIFT ;
1394
1405
Pfn1 = MiGetPfnEntry (PageFrameIndex );
@@ -1399,6 +1410,8 @@ MmDeleteProcessAddressSpace2(IN PEPROCESS Process)
1399
1410
/* HACK: In Richard's original patch this ASSERT did work */
1400
1411
//DPRINT1("Ref count: %lx %lx\n", Pfn1->u3.e2.ReferenceCount, Pfn1->u2.ShareCount);
1401
1412
//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 );
1402
1415
}
1403
1416
else
1404
1417
{
0 commit comments