mirror of
https://github.com/reactos/reactos.git
synced 2024-07-31 00:28:56 +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
|
* PROJECT: ReactOS Kernel
|
||||||
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
* 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
|
* PURPOSE: Hyperspace Mapping Functionality
|
||||||
* PROGRAMMERS: ReactOS Portable Systems Group
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
/* GLOBALS ********************************************************************/
|
/* GLOBALS ********************************************************************/
|
||||||
|
|
||||||
PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
|
PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
|
||||||
|
PMMPTE MiFirstReservedZeroingPte;
|
||||||
MMPTE HyperTemplatePte;
|
MMPTE HyperTemplatePte;
|
||||||
PEPROCESS HyperProcess;
|
PEPROCESS HyperProcess;
|
||||||
KIRQL HyperIrql;
|
KIRQL HyperIrql;
|
||||||
|
@ -30,43 +31,60 @@ MiMapPageInHyperSpace(IN PEPROCESS Process,
|
||||||
MMPTE TempPte;
|
MMPTE TempPte;
|
||||||
PMMPTE PointerPte;
|
PMMPTE PointerPte;
|
||||||
PFN_NUMBER Offset;
|
PFN_NUMBER Offset;
|
||||||
PVOID Address;
|
|
||||||
|
|
||||||
/* Never accept page 0 */
|
//
|
||||||
|
// Never accept page 0
|
||||||
|
//
|
||||||
ASSERT(Page != 0);
|
ASSERT(Page != 0);
|
||||||
|
|
||||||
/* Build the PTE */
|
//
|
||||||
|
// Build the PTE
|
||||||
|
//
|
||||||
TempPte = HyperTemplatePte;
|
TempPte = HyperTemplatePte;
|
||||||
TempPte.u.Hard.PageFrameNumber = Page;
|
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;
|
PointerPte = MmFirstReservedMappingPte;
|
||||||
|
|
||||||
/* Acquire the hyperlock */
|
//
|
||||||
|
// Acquire the hyperlock
|
||||||
|
//
|
||||||
ASSERT(Process == PsGetCurrentProcess());
|
ASSERT(Process == PsGetCurrentProcess());
|
||||||
KeAcquireSpinLock(&Process->HyperSpaceLock, OldIrql);
|
KeAcquireSpinLock(&Process->HyperSpaceLock, OldIrql);
|
||||||
|
|
||||||
/* Now get the first free PTE */
|
//
|
||||||
|
// Now get the first free PTE
|
||||||
|
//
|
||||||
Offset = PFN_FROM_PTE(PointerPte);
|
Offset = PFN_FROM_PTE(PointerPte);
|
||||||
if (!Offset)
|
if (!Offset)
|
||||||
{
|
{
|
||||||
/* Reset the PTEs */
|
//
|
||||||
|
// Reset the PTEs
|
||||||
|
//
|
||||||
Offset = MI_HYPERSPACE_PTES;
|
Offset = MI_HYPERSPACE_PTES;
|
||||||
KeFlushProcessTb();
|
KeFlushProcessTb();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare the next PTE */
|
//
|
||||||
|
// Prepare the next PTE
|
||||||
|
//
|
||||||
PointerPte->u.Hard.PageFrameNumber = Offset - 1;
|
PointerPte->u.Hard.PageFrameNumber = Offset - 1;
|
||||||
|
|
||||||
/* Write the current PTE */
|
//
|
||||||
|
// Write the current PTE
|
||||||
|
//
|
||||||
PointerPte += Offset;
|
PointerPte += Offset;
|
||||||
ASSERT(PointerPte->u.Hard.Valid == 0);
|
ASSERT(PointerPte->u.Hard.Valid == 0);
|
||||||
ASSERT(TempPte.u.Hard.Valid == 1);
|
ASSERT(TempPte.u.Hard.Valid == 1);
|
||||||
*PointerPte = TempPte;
|
*PointerPte = TempPte;
|
||||||
|
|
||||||
/* Return the address */
|
//
|
||||||
Address = (PVOID)((ULONG_PTR)PointerPte << 10);
|
// Return the address
|
||||||
return Address;
|
//
|
||||||
|
return MiPteToAddress(PointerPte);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -77,10 +95,14 @@ MiUnmapPageInHyperSpace(IN PEPROCESS Process,
|
||||||
{
|
{
|
||||||
ASSERT(Process == PsGetCurrentProcess());
|
ASSERT(Process == PsGetCurrentProcess());
|
||||||
|
|
||||||
/* Blow away the mapping */
|
//
|
||||||
|
// Blow away the mapping
|
||||||
|
//
|
||||||
MiAddressToPte(Address)->u.Long = 0;
|
MiAddressToPte(Address)->u.Long = 0;
|
||||||
|
|
||||||
/* Release the hyperlock */
|
//
|
||||||
|
// Release the hyperlock
|
||||||
|
//
|
||||||
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
|
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
|
||||||
KeReleaseSpinLock(&Process->HyperSpaceLock, OldIrql);
|
KeReleaseSpinLock(&Process->HyperSpaceLock, OldIrql);
|
||||||
}
|
}
|
||||||
|
@ -93,24 +115,36 @@ MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page)
|
||||||
PMMPTE PointerPte;
|
PMMPTE PointerPte;
|
||||||
PVOID Address;
|
PVOID Address;
|
||||||
|
|
||||||
/* Never accept page 0 */
|
//
|
||||||
|
// Never accept page 0
|
||||||
|
//
|
||||||
ASSERT(Page != 0);
|
ASSERT(Page != 0);
|
||||||
|
|
||||||
/* Build the PTE */
|
//
|
||||||
|
// Build the PTE
|
||||||
|
//
|
||||||
TempPte = HyperTemplatePte;
|
TempPte = HyperTemplatePte;
|
||||||
TempPte.u.Hard.PageFrameNumber = Page;
|
TempPte.u.Hard.PageFrameNumber = Page;
|
||||||
|
|
||||||
/* Get the Zero PTE and its address */
|
//
|
||||||
|
// Get the Zero PTE and its address
|
||||||
|
//
|
||||||
PointerPte = MiAddressToPte(MI_ZERO_PTE);
|
PointerPte = MiAddressToPte(MI_ZERO_PTE);
|
||||||
Address = (PVOID)((ULONG_PTR)PointerPte << 10);
|
Address = (PVOID)((ULONG_PTR)PointerPte << 10);
|
||||||
|
|
||||||
/* Invalidate the old address */
|
//
|
||||||
|
// Invalidate the old address
|
||||||
|
//
|
||||||
__invlpg(Address);
|
__invlpg(Address);
|
||||||
|
|
||||||
/* Write the current PTE */
|
//
|
||||||
|
// Write the current PTE
|
||||||
|
//
|
||||||
TempPte.u.Hard.PageFrameNumber = Page;
|
TempPte.u.Hard.PageFrameNumber = Page;
|
||||||
*PointerPte = TempPte;
|
*PointerPte = TempPte;
|
||||||
|
|
||||||
/* Return the address */
|
//
|
||||||
|
// Return the address
|
||||||
|
//
|
||||||
return Address;
|
return Address;
|
||||||
}
|
}
|
|
@ -360,6 +360,7 @@
|
||||||
</directory>
|
</directory>
|
||||||
</if>
|
</if>
|
||||||
<directory name="ARM3">
|
<directory name="ARM3">
|
||||||
|
<file>hypermap.c</file>
|
||||||
<file>init.c</file>
|
<file>init.c</file>
|
||||||
<file>pool.c</file>
|
<file>pool.c</file>
|
||||||
<file>syspte.c</file>
|
<file>syspte.c</file>
|
||||||
|
@ -370,7 +371,6 @@
|
||||||
<file>dbgpool.c</file>
|
<file>dbgpool.c</file>
|
||||||
<file>drvlck.c</file>
|
<file>drvlck.c</file>
|
||||||
<file>freelist.c</file>
|
<file>freelist.c</file>
|
||||||
<file>hypermap.c</file>
|
|
||||||
<file>iospace.c</file>
|
<file>iospace.c</file>
|
||||||
<file>kmap.c</file>
|
<file>kmap.c</file>
|
||||||
<file>marea.c</file>
|
<file>marea.c</file>
|
||||||
|
|
Loading…
Reference in a new issue