This breaks boot.
Author: dgorbachev
Date: Sat Mar 14 04:20:18 2009
New Revision: 40008
URL:
http://svn.reactos.org/svn/reactos?rev=40008&view=rev
Log:
Return to an old idea of MiMapPageToZeroInHyperSpace(), "fix" bug #4267.
Modified:
trunk/reactos/ntoskrnl/mm/hypermap.c
Modified: trunk/reactos/ntoskrnl/mm/hypermap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/hypermap.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/hypermap.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/hypermap.c [iso-8859-1] Sat Mar 14 04:20:18 2009
@@ -14,8 +14,11 @@
/* GLOBALS ********************************************************************/
+#define MI_ZEROING_PTES 255
+
PMMPTE MmFirstReservedMappingPte;
PMMPTE MmLastReservedMappingPte;
+PMMPTE MmFirstReservedZeroingPte;
MMPTE HyperTemplatePte;
PEPROCESS HyperProcess;
KIRQL HyperIrql;
@@ -40,6 +43,8 @@
MmFirstReservedMappingPte = MiAddressToPte(MI_MAPPING_RANGE_START);
MmLastReservedMappingPte = MiAddressToPte(MI_MAPPING_RANGE_END);
MmFirstReservedMappingPte->u.Hard.PageFrameNumber = MI_HYPERSPACE_PTES;
+ MmFirstReservedZeroingPte = MiAddressToPte(MI_ZERO_PTE);
+ MmFirstReservedZeroingPte->u.Hard.PageFrameNumber = MI_ZEROING_PTES;
}
PVOID
@@ -134,38 +139,62 @@
{
MMPTE TempPte;
PMMPTE PointerPte;
+ PFN_NUMBER Offset;
PVOID Address;
-
+
//
// Never accept page 0
//
ASSERT(Page != 0);
-
+
//
// Build the PTE
//
TempPte = HyperTemplatePte;
TempPte.u.Hard.PageFrameNumber = Page;
-
- //
- // Get the Zero PTE and its address
- //
- PointerPte = MiAddressToPte(MI_ZERO_PTE);
+
+ //
+ // Pick the first zeroing PTE
+ //
+ PointerPte = MmFirstReservedZeroingPte;
+
+ //
+ // Now get the first free PTE
+ //
+ Offset = PFN_FROM_PTE(PointerPte);
+ if (!Offset)
+ {
+ //
+ // Reset the PTEs
+ //
+ Offset = MI_ZEROING_PTES;
+ KeFlushProcessTb();
+ }
+
+ //
+ // Prepare the next PTE
+ //
+ PointerPte->u.Hard.PageFrameNumber = Offset - 1;
+
+ //
+ // Write the current PTE
+ //
+ PointerPte += Offset;
+ *PointerPte = TempPte;
+
+ //
+ // Return the address
+ //
Address = (PVOID)((ULONG_PTR)PointerPte << 10);
-
- //
- // Invalidate the old address
- //
- __invlpg(Address);
-
- //
- // Write the current PTE
- //
- TempPte.u.Hard.PageFrameNumber = Page;
- *PointerPte = TempPte;
-
- //
- // Return the address
- //
return Address;
}
+
+VOID
+NTAPI
+MiUnmapPageInZeroSpace(IN PVOID Address)
+{
+ //
+ // Blow away the mapping
+ //
+ MiAddressToPte(Address)->u.Long = 0;
+}