mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 04:35:07 +00:00
- Move hypermap.c into ARM3 since it will be changed to use System PTEs for zero PTEs to solve the current race conditions that had to be fixed/hacked around in the current implementation.
- DO NOT MAP HYPERSPACE PTEs as GLOBAL! They are now mapped as local, which might fix some really strange bugs that could've occured in the past. - Use MiPteToAddress instead of manually doing the bitmagic when mapping a page into hyperspace. svn path=/trunk/; revision=41574
This commit is contained in:
parent
52fc282ff3
commit
12ed6254a7
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Kernel
|
||||
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
||||
* FILE: ntoskrnl/mm/hypermap.c
|
||||
* FILE: ntoskrnl/mm/ARM3/hypermap.c
|
||||
* PURPOSE: Hyperspace Mapping Functionality
|
||||
* PROGRAMMERS: ReactOS Portable Systems Group
|
||||
*/
|
||||
|
@ -15,6 +15,7 @@
|
|||
/* GLOBALS ********************************************************************/
|
||||
|
||||
PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
|
||||
PMMPTE MiFirstReservedZeroingPte;
|
||||
MMPTE HyperTemplatePte;
|
||||
PEPROCESS HyperProcess;
|
||||
KIRQL HyperIrql;
|
||||
|
@ -30,43 +31,60 @@ MiMapPageInHyperSpace(IN PEPROCESS Process,
|
|||
MMPTE TempPte;
|
||||
PMMPTE PointerPte;
|
||||
PFN_NUMBER Offset;
|
||||
PVOID Address;
|
||||
|
||||
/* Never accept page 0 */
|
||||
//
|
||||
// Never accept page 0
|
||||
//
|
||||
ASSERT(Page != 0);
|
||||
|
||||
/* Build the PTE */
|
||||
//
|
||||
// Build the PTE
|
||||
//
|
||||
TempPte = HyperTemplatePte;
|
||||
TempPte.u.Hard.PageFrameNumber = Page;
|
||||
TempPte.u.Hard.Global = 0; // Hyperspace is local!
|
||||
|
||||
/* Pick the first hyperspace PTE */
|
||||
//
|
||||
// Pick the first hyperspace PTE
|
||||
//
|
||||
PointerPte = MmFirstReservedMappingPte;
|
||||
|
||||
/* Acquire the hyperlock */
|
||||
//
|
||||
// Acquire the hyperlock
|
||||
//
|
||||
ASSERT(Process == PsGetCurrentProcess());
|
||||
KeAcquireSpinLock(&Process->HyperSpaceLock, OldIrql);
|
||||
|
||||
/* Now get the first free PTE */
|
||||
//
|
||||
// Now get the first free PTE
|
||||
//
|
||||
Offset = PFN_FROM_PTE(PointerPte);
|
||||
if (!Offset)
|
||||
{
|
||||
/* Reset the PTEs */
|
||||
//
|
||||
// Reset the PTEs
|
||||
//
|
||||
Offset = MI_HYPERSPACE_PTES;
|
||||
KeFlushProcessTb();
|
||||
}
|
||||
|
||||
/* Prepare the next PTE */
|
||||
//
|
||||
// Prepare the next PTE
|
||||
//
|
||||
PointerPte->u.Hard.PageFrameNumber = Offset - 1;
|
||||
|
||||
/* Write the current PTE */
|
||||
//
|
||||
// Write the current PTE
|
||||
//
|
||||
PointerPte += Offset;
|
||||
ASSERT(PointerPte->u.Hard.Valid == 0);
|
||||
ASSERT(TempPte.u.Hard.Valid == 1);
|
||||
*PointerPte = TempPte;
|
||||
|
||||
/* Return the address */
|
||||
Address = (PVOID)((ULONG_PTR)PointerPte << 10);
|
||||
return Address;
|
||||
//
|
||||
// Return the address
|
||||
//
|
||||
return MiPteToAddress(PointerPte);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -77,10 +95,14 @@ MiUnmapPageInHyperSpace(IN PEPROCESS Process,
|
|||
{
|
||||
ASSERT(Process == PsGetCurrentProcess());
|
||||
|
||||
/* Blow away the mapping */
|
||||
//
|
||||
// Blow away the mapping
|
||||
//
|
||||
MiAddressToPte(Address)->u.Long = 0;
|
||||
|
||||
/* Release the hyperlock */
|
||||
//
|
||||
// Release the hyperlock
|
||||
//
|
||||
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
|
||||
KeReleaseSpinLock(&Process->HyperSpaceLock, OldIrql);
|
||||
}
|
||||
|
@ -93,24 +115,36 @@ MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page)
|
|||
PMMPTE PointerPte;
|
||||
PVOID Address;
|
||||
|
||||
/* Never accept page 0 */
|
||||
//
|
||||
// Never accept page 0
|
||||
//
|
||||
ASSERT(Page != 0);
|
||||
|
||||
/* Build the PTE */
|
||||
//
|
||||
// Build the PTE
|
||||
//
|
||||
TempPte = HyperTemplatePte;
|
||||
TempPte.u.Hard.PageFrameNumber = Page;
|
||||
|
||||
/* Get the Zero PTE and its address */
|
||||
//
|
||||
// Get the Zero PTE and its address
|
||||
//
|
||||
PointerPte = MiAddressToPte(MI_ZERO_PTE);
|
||||
Address = (PVOID)((ULONG_PTR)PointerPte << 10);
|
||||
|
||||
/* Invalidate the old address */
|
||||
//
|
||||
// Invalidate the old address
|
||||
//
|
||||
__invlpg(Address);
|
||||
|
||||
/* Write the current PTE */
|
||||
//
|
||||
// Write the current PTE
|
||||
//
|
||||
TempPte.u.Hard.PageFrameNumber = Page;
|
||||
*PointerPte = TempPte;
|
||||
|
||||
/* Return the address */
|
||||
//
|
||||
// Return the address
|
||||
//
|
||||
return Address;
|
||||
}
|
|
@ -360,6 +360,7 @@
|
|||
</directory>
|
||||
</if>
|
||||
<directory name="ARM3">
|
||||
<file>hypermap.c</file>
|
||||
<file>init.c</file>
|
||||
<file>pool.c</file>
|
||||
<file>syspte.c</file>
|
||||
|
@ -370,7 +371,6 @@
|
|||
<file>dbgpool.c</file>
|
||||
<file>drvlck.c</file>
|
||||
<file>freelist.c</file>
|
||||
<file>hypermap.c</file>
|
||||
<file>iospace.c</file>
|
||||
<file>kmap.c</file>
|
||||
<file>marea.c</file>
|
||||
|
|
Loading…
Reference in a new issue