Author: tkreuzer
Date: Mon Feb 6 10:46:52 2012
New Revision: 55456
URL: http://svn.reactos.org/svn/reactos?rev=55456&view=rev
Log:
[NTOSKRNL]
- Implement MiSynchronizeSystemPde, which does what its name suggests, synchronize a system PDE and is an improved replacement (with a more proper name) for MiCheckPdeForPagedPool
- Move some code to avoid an additional check
- Call MiResolveDemandZeroFault directy instead of creating a demand zero PDE and then calling MiDispatchFault, which after a lot of checks will finally do the same
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] Mon Feb 6 10:46:52 2012
@@ -100,6 +100,28 @@
}
}
+#if (_MI_PAGING_LEVELS == 2)
+BOOLEAN
+FORCEINLINE
+MiSynchronizeSystemPde(PMMPDE PointerPde)
+{
+ MMPDE SystemPde;
+ ULONG Index;
+
+ /* Get the Index from the PDE */
+ Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE);
+
+ /* Copy the PDE from the double-mapped system page directory */
+ SystemPde = MmSystemPagePtes[Index];
+ *PointerPde = SystemPde;
+
+ /* Make sure we re-read the PDE and PTE */
+ KeMemoryBarrierWithoutFence();
+
+ /* Return, if we had success */
+ return (BOOLEAN)SystemPde.u.Hard.Valid;
+}
+
NTSTATUS
FASTCALL
MiCheckPdeForPagedPool(IN PVOID Address)
@@ -159,6 +181,7 @@
//
return Status;
}
+#endif
VOID
NTAPI
@@ -699,28 +722,12 @@
/* Check if the PDE is invalid */
if (PointerPde->u.Hard.Valid == 0)
{
- //
- // Debug spew (eww!)
- //
- DPRINT("Invalid PDE\n");
#if (_MI_PAGING_LEVELS == 2)
- //
- // Handle mapping in "Special" PDE directoreis
- //
- MiCheckPdeForPagedPool(Address);
-#endif
- //
- // Now we SHOULD be good
- //
- if (PointerPde->u.Hard.Valid == 0)
+ /* Sync this PDE and check, if that made it valid */
+ if (!MiSynchronizeSystemPde(PointerPde))
+#endif
{
- //
- // FIXFIX: Do the S-LIST hack
- //
-
- //
- // Kill the system
- //
+ /* PDE (still) not valid, kill the system */
KeBugCheckEx(PAGE_FAULT_IN_NONPAGED_AREA,
(ULONG_PTR)Address,
StoreInstruction,
@@ -824,20 +831,20 @@
(ULONG_PTR)TrapInformation,
1);
}
- }
-
- /* Check for demand page */
- if ((StoreInstruction) && !(ProtoPte) && !(TempPte.u.Hard.Valid))
- {
- /* Get the protection code */
- if (!(TempPte.u.Soft.Protection & MM_READWRITE))
+
+ /* Check for demand page */
+ if ((StoreInstruction) && !(TempPte.u.Hard.Valid))
{
- /* Bad boy, bad boy, whatcha gonna do, whatcha gonna do when ARM3 comes for you! */
- KeBugCheckEx(ATTEMPTED_WRITE_TO_READONLY_MEMORY,
- (ULONG_PTR)Address,
- TempPte.u.Long,
- (ULONG_PTR)TrapInformation,
- 14);
+ /* Get the protection code */
+ if (!(TempPte.u.Soft.Protection & MM_READWRITE))
+ {
+ /* Bugcheck the system! */
+ KeBugCheckEx(ATTEMPTED_WRITE_TO_READONLY_MEMORY,
+ (ULONG_PTR)Address,
+ TempPte.u.Long,
+ (ULONG_PTR)TrapInformation,
+ 14);
+ }
}
}
@@ -889,21 +896,15 @@
/* Right now, we expect a valid protection mask on the VAD */
ASSERT(ProtectionCode != MM_NOACCESS);
- /* Make the PDE demand-zero */
- MI_WRITE_INVALID_PDE(PointerPde, DemandZeroPde);
-
/* And go dispatch the fault on the PDE. This should handle the demand-zero */
#if MI_TRACE_PFNS
UserPdeFault = TRUE;
#endif
- Status = MiDispatchFault(TRUE,
- PointerPte,
- (PMMPTE)PointerPde,
- NULL,
- FALSE,
- PsGetCurrentProcess(),
- TrapInformation,
- NULL);
+ /* Resolve a demand zero fault */
+ Status = MiResolveDemandZeroFault(PointerPte,
+ MM_READWRITE,
+ CurrentProcess,
+ MM_NOIRQL);
#if MI_TRACE_PFNS
UserPdeFault = FALSE;
#endif
@@ -930,15 +931,14 @@
return STATUS_PAGE_FAULT_DEMAND_ZERO;
}
- /* Get protection and check if it's a prototype PTE */
- ProtectionCode = (ULONG)TempPte.u.Soft.Protection;
+ /* Make sure it's not a prototype PTE */
ASSERT(TempPte.u.Soft.Prototype == 0);
/* Check for non-demand zero PTE */
if (TempPte.u.Long != 0)
{
/* This is a page fault, check for valid protection */
- ASSERT(ProtectionCode != 0x100);
+ ASSERT(TempPte.u.Soft.Protection != 0x100);
/* FIXME: Run MiAccessCheck */
Author: ion
Date: Mon Feb 6 08:17:03 2012
New Revision: 55452
URL: http://svn.reactos.org/svn/reactos?rev=55452&view=rev
Log:
[NTOSKRNL]: Finish implementation of NtAreMappedFilesTheSame based on what winetests revealed. Should fix all 20+ winetests in this area, on top of making Ldr suck less.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/section.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/section.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/section.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/section.c [iso-8859-1] Mon Feb 6 08:17:03 2012
@@ -1387,8 +1387,6 @@
PMEMORY_AREA MemoryArea1, MemoryArea2;
PROS_SECTION_OBJECT Section1, Section2;
- DPRINT1("Is image: %p the same as file: %p?\n", File1MappedAsAnImage, File2MappedAsFile);
-
/* Lock address space */
AddressSpace = MmGetCurrentAddressSpace();
MmLockAddressSpace(AddressSpace);
@@ -1398,7 +1396,6 @@
if (!MemoryArea1)
{
/* Fail, the address does not exist */
- DPRINT1("Invalid address\n");
MmUnlockAddressSpace(AddressSpace);
return STATUS_INVALID_ADDRESS;
}
@@ -1407,7 +1404,6 @@
if (MemoryArea1->Type != MEMORY_AREA_SECTION_VIEW)
{
/* Fail, the address is not a section */
- DPRINT1("Invalid address (not a section)\n");
MmUnlockAddressSpace(AddressSpace);
return STATUS_CONFLICTING_ADDRESSES;
}
@@ -1416,7 +1412,6 @@
Section1 = MemoryArea1->Data.SectionData.Section;
if (Section1->FileObject == NULL)
{
- DPRINT1("No file object\n");
MmUnlockAddressSpace(AddressSpace);
return STATUS_CONFLICTING_ADDRESSES;
}
@@ -1426,7 +1421,6 @@
if (!MemoryArea2)
{
/* Fail, the address does not exist */
- DPRINT1("Invalid address\n");
MmUnlockAddressSpace(AddressSpace);
return STATUS_INVALID_ADDRESS;
}
@@ -1435,7 +1429,6 @@
if (MemoryArea2->Type != MEMORY_AREA_SECTION_VIEW)
{
/* Fail, the address is not a section */
- DPRINT1("Invalid address (not a section)\n");
MmUnlockAddressSpace(AddressSpace);
return STATUS_CONFLICTING_ADDRESSES;
}
@@ -1444,23 +1437,17 @@
Section2 = MemoryArea2->Data.SectionData.Section;
if (Section2->FileObject == NULL)
{
- DPRINT1("No file object\n");
MmUnlockAddressSpace(AddressSpace);
return STATUS_CONFLICTING_ADDRESSES;
}
- /* These dbgprints should allow me to see what should w ecompare in ROS's section implementation once the winetests are run... for now lie and say they're not equal. */
- DPRINT1("FO1/2: %p %p\n", Section1->FileObject, Section2->FileObject);
- DPRINT1("SOP: %p %p\n",
- Section1->FileObject->SectionObjectPointer,
- Section2->FileObject->SectionObjectPointer);
- DPRINT1("SCM: %p %p\n",
- Section1->FileObject->SectionObjectPointer->SharedCacheMap,
- Section2->FileObject->SectionObjectPointer->SharedCacheMap);
- DPRINT1("ISO: %p %p\n",
- Section1->FileObject->SectionObjectPointer->ImageSectionObject,
- Section2->FileObject->SectionObjectPointer->ImageSectionObject);
- DPRINT1("SISO: %p %p\n", Section1->ImageSection, Section2->ImageSection);
+ /* The shared cache map seems to be the same if both of these are equal */
+ if (Section1->FileObject->SectionObjectPointer->SharedCacheMap ==
+ Section2->FileObject->SectionObjectPointer->SharedCacheMap)
+ {
+ MmUnlockAddressSpace(AddressSpace);
+ return STATUS_SUCCESS;
+ }
/* Unlock address space */
MmUnlockAddressSpace(AddressSpace);