mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 03:29:37 +00:00
- Create a double-mapping PTE for the shared user data region and fault it in whenever a process touches that address.
- Remove the old hack which used the PCR's page frame number to create a fake PTE each time to reference it, basing on the fact that the shared user data region was on the same page as the PCR on certain architectures. svn path=/trunk/; revision=42252
This commit is contained in:
parent
059da34e93
commit
3e04cabe4e
2 changed files with 34 additions and 9 deletions
|
@ -150,7 +150,7 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
BOOLEAN Locked = FromMdl;
|
BOOLEAN Locked = FromMdl;
|
||||||
PFN_TYPE Pfn;
|
extern PMMPTE MmSharedUserDataPte;
|
||||||
|
|
||||||
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
|
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
|
||||||
|
|
||||||
|
@ -228,14 +228,8 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEMORY_AREA_SHARED_DATA:
|
case MEMORY_AREA_SHARED_DATA:
|
||||||
Pfn = MmGetPhysicalAddress((PVOID)PCR).LowPart >> PAGE_SHIFT;
|
*MiAddressToPte(USER_SHARED_DATA) = *MmSharedUserDataPte;
|
||||||
Pfn++;
|
Status = STATUS_SUCCESS;
|
||||||
Status =
|
|
||||||
MmCreateVirtualMapping(PsGetCurrentProcess(),
|
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address),
|
|
||||||
PAGE_READONLY,
|
|
||||||
&Pfn,
|
|
||||||
1);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -48,6 +48,7 @@ MemType[] =
|
||||||
PBOOLEAN Mm64BitPhysicalAddress = FALSE;
|
PBOOLEAN Mm64BitPhysicalAddress = FALSE;
|
||||||
ULONG MmReadClusterSize;
|
ULONG MmReadClusterSize;
|
||||||
MM_STATS MmStats;
|
MM_STATS MmStats;
|
||||||
|
PMMPTE MmSharedUserDataPte;
|
||||||
PMMSUPPORT MmKernelAddressSpace;
|
PMMSUPPORT MmKernelAddressSpace;
|
||||||
extern KMUTANT MmSystemLoadLock;
|
extern KMUTANT MmSystemLoadLock;
|
||||||
extern ULONG MmBootImageSize;
|
extern ULONG MmBootImageSize;
|
||||||
|
@ -181,6 +182,11 @@ NTAPI
|
||||||
MmInitSystem(IN ULONG Phase,
|
MmInitSystem(IN ULONG Phase,
|
||||||
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
{
|
{
|
||||||
|
extern MMPTE HyperTemplatePte;
|
||||||
|
PMMPTE PointerPte;
|
||||||
|
MMPTE TempPte = HyperTemplatePte;
|
||||||
|
PFN_NUMBER PageFrameNumber;
|
||||||
|
|
||||||
if (Phase == 0)
|
if (Phase == 0)
|
||||||
{
|
{
|
||||||
/* Initialize Mm bootstrap */
|
/* Initialize Mm bootstrap */
|
||||||
|
@ -210,6 +216,31 @@ MmInitSystem(IN ULONG Phase,
|
||||||
MmInitSectionImplementation();
|
MmInitSectionImplementation();
|
||||||
MmInitPagingFile();
|
MmInitPagingFile();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create a PTE to double-map the shared data section. We allocate it
|
||||||
|
// from paged pool so that we can't fault when trying to touch the PTE
|
||||||
|
// itself (to map it), since paged pool addresses will already be mapped
|
||||||
|
// by the fault handler.
|
||||||
|
//
|
||||||
|
MmSharedUserDataPte = ExAllocatePoolWithTag(PagedPool,
|
||||||
|
sizeof(MMPTE),
|
||||||
|
' mM');
|
||||||
|
if (!MmSharedUserDataPte) return FALSE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now get the PTE for shared data, and read the PFN that holds it
|
||||||
|
//
|
||||||
|
PointerPte = MiAddressToPte(KI_USER_SHARED_DATA);
|
||||||
|
ASSERT(PointerPte->u.Hard.Valid == 1);
|
||||||
|
PageFrameNumber = PFN_FROM_PTE(PointerPte);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now write a copy of it
|
||||||
|
//
|
||||||
|
TempPte.u.Hard.Owner = 1;
|
||||||
|
TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
|
||||||
|
*MmSharedUserDataPte = TempPte;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unmap low memory
|
* Unmap low memory
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue