Author: sir_richard
Date: Tue Oct 5 08:14:02 2010
New Revision: 48993
URL: http://svn.reactos.org/svn/reactos?rev=48993&view=rev
Log:
[NTOS]: Add the tiny little bit of code required to correctly handle user-mode faults on ARM3 mapped sections in certain limited scenarios.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pagfault.…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c [iso-8859-1] Tue Oct 5 08:14:02 2010
@@ -27,6 +27,7 @@
OUT PMMVAD *ProtoVad)
{
PMMVAD Vad;
+ PMMPTE PointerPte;
/* No prototype/section support for now */
*ProtoVad = NULL;
@@ -50,15 +51,33 @@
*ProtectCode = MM_NOACCESS;
return NULL;
}
-
- /* This must be a TEB/PEB VAD */
- ASSERT(Vad->u.VadFlags.PrivateMemory == TRUE);
- ASSERT(Vad->u.VadFlags.MemCommit == TRUE);
+
+ /* This must be a VM VAD */
ASSERT(Vad->u.VadFlags.VadType == VadNone);
- /* Return the protection on it */
- *ProtectCode = Vad->u.VadFlags.Protection;
- return NULL;
+ /* Check if it's a section, or just an allocation */
+ if (Vad->u.VadFlags.PrivateMemory == TRUE)
+ {
+ /* This must be a TEB/PEB VAD */
+ ASSERT(Vad->u.VadFlags.MemCommit == TRUE);
+ *ProtectCode = Vad->u.VadFlags.Protection;
+ return NULL;
+ }
+ else
+ {
+ /* Return the proto VAD */
+ ASSERT(Vad->u2.VadFlags2.ExtendableFile == 0);
+ *ProtoVad = Vad;
+
+ /* Get the prototype PTE for this page */
+ PointerPte = (((ULONG_PTR)VirtualAddress >> PAGE_SHIFT) - Vad->StartingVpn) + Vad->FirstPrototypePte;
+ ASSERT(PointerPte <= Vad->LastContiguousPte);
+ ASSERT(PointerPte != NULL);
+
+ /* Return the Prototype PTE and the protection for the page mapping */
+ *ProtectCode = Vad->u.VadFlags.Protection;
+ return PointerPte;
+ }
}
NTSTATUS
@@ -482,8 +501,8 @@
}
else
{
+ /* Resolve the fault -- this will release the PFN lock */
ASSERT(PointerPte->u.Hard.Valid == 0);
- /* Resolve the fault -- this will release the PFN lock */
Status = MiResolveProtoPteFault(StoreInstruction,
Address,
PointerPte,
@@ -505,15 +524,14 @@
}
else
{
- /* We currently only handle the shared user data PTE path */
+ /* We currently only handle very limited paths */
ASSERT(PointerPte->u.Soft.Prototype == 1);
ASSERT(PointerPte->u.Soft.PageFileHigh == MI_PTE_LOOKUP_NEEDED);
- ASSERT(Vad == NULL);
/* Lock the PFN database */
LockIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
- /* For the shared data page, this should be true */
+ /* For our current usage, this should be true */
ASSERT(SuperProtoPte->u.Hard.Valid == 1);
ASSERT(TempPte.u.Hard.Valid == 0);
@@ -972,8 +990,9 @@
}
else
{
- /* The only "prototype PTE" we support is the shared user data path */
- ASSERT(ProtectionCode == MM_READONLY);
+ /* No guard page support yet */
+ ASSERT((ProtectionCode & MM_DECOMMIT) == 0);
+ ASSERT(ProtectionCode != 0x100);
/* Write the prototype PTE */
TempPte = PrototypePte;
@@ -991,7 +1010,7 @@
Vad);
ASSERT(Status == STATUS_PAGE_FAULT_TRANSITION);
ASSERT(PointerPte->u.Hard.Valid == 1);
- ASSERT(PointerPte->u.Hard.PageFrameNumber == MmSharedUserDataPte->u.Hard.PageFrameNumber);
+ ASSERT(PointerPte->u.Hard.PageFrameNumber != 0);
}
/* Release the working set */
Author: sir_richard
Date: Tue Oct 5 05:00:19 2010
New Revision: 48990
URL: http://svn.reactos.org/svn/reactos?rev=48990&view=rev
Log:
[NTOS]: Use the Spare flag in the VAD as a ReactOS/MemoryArea specific flag to signify that this VAD is associated with a MEMORY_AREA and should be unlinked at process exit, but not freed. This is because MemoryAreas themselves are cleaned up later, and in the future their associated VADs (not yet in Trunk) will also be parsed. In the process death scenario, those VADs will be freed, but not unlinked (since it would already have been unlinked).
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/procsup.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/procsup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/procsup.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] Tue Oct 5 05:00:19 2010
@@ -125,7 +125,7 @@
/* Build the rest of the VAD now */
Vad->StartingVpn = (*Base) >> PAGE_SHIFT;
- Vad->EndingVpn = ((*Base) + Size - 1) >> PAGE_SHIFT;
+ Vad->EndingVpn = ((*Base) + Size - 1) >> PAGE_SHIFT;
Vad->u3.Secured.StartVpn = *Base;
Vad->u3.Secured.EndVpn = (Vad->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1);
Vad->u1.Parent = NULL;
@@ -1195,6 +1195,14 @@
/* Release the working set */
MiUnlockProcessWorkingSet(Process, Thread);
+ /* Skip ARM3 fake VADs, they'll be freed by MmDeleteProcessAddresSpace */
+ if (Vad->u.VadFlags.Spare == 1)
+ {
+ /* Set a flag so MmDeleteMemoryArea knows to free, but not to remove */
+ Vad->u.VadFlags.Spare = 2;
+ continue;
+ }
+
/* Free the VAD memory */
ExFreePool(Vad);
}