From ee6f35722f945fa679072d202fc547207eb4a7a5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 1 Apr 2012 15:23:08 +0000 Subject: [PATCH] [NTOSKRNL] Use MiFillSystemPageDirectory on amd64, too svn path=/trunk/; revision=56304 --- reactos/ntoskrnl/include/internal/amd64/mm.h | 14 +++++++------- reactos/ntoskrnl/mm/ARM3/section.c | 18 ++++++++++++------ reactos/ntoskrnl/mm/amd64/init.c | 3 +++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/amd64/mm.h b/reactos/ntoskrnl/include/internal/amd64/mm.h index 5a24de881a2..6a624a11567 100644 --- a/reactos/ntoskrnl/include/internal/amd64/mm.h +++ b/reactos/ntoskrnl/include/internal/amd64/mm.h @@ -256,6 +256,10 @@ MiIsPdeForAddressValid(PVOID Address) #define MiPdeToPte(PDE) ((PMMPTE)MiPteToAddress(PDE)) #define MiPteToPde(PTE) ((PMMPDE)MiAddressToPte(PTE)) +#define MiPdeToPpe(Pde) ((PMMPPE)MiAddressToPte(Pde)) + +/* Sign extend 48 bits */ +#define MiProtoPteToPte(x) (PMMPTE)(((LONG64)(x)->u.Long) >> 16) FORCEINLINE VOID @@ -263,17 +267,13 @@ MI_MAKE_PROTOTYPE_PTE(IN PMMPTE NewPte, IN PMMPTE PointerPte) { /* Store the Address */ - NewPte->u.Long = (ULONG64)PointerPte; + NewPte->u.Long = (ULONG64)PointerPte << 16; /* Mark this as a prototype PTE */ NewPte->u.Proto.Prototype = 1; - NewPte->u.Proto.Valid = 1; - NewPte->u.Proto.ReadOnly = 0; - NewPte->u.Proto.Protection = 0; -} -/* Sign extend 48 bits */ -#define MiProtoPteToPte(x) (PMMPTE)((LONG64)(x)->u.Proto.ProtoAddress) + ASSERT(MiProtoPteToPte(NewPte) == PointerPte); +} VOID FORCEINLINE diff --git a/reactos/ntoskrnl/mm/ARM3/section.c b/reactos/ntoskrnl/mm/ARM3/section.c index 85935f815d8..fa2f10d72c7 100644 --- a/reactos/ntoskrnl/mm/ARM3/section.c +++ b/reactos/ntoskrnl/mm/ARM3/section.c @@ -410,7 +410,6 @@ MiAddMappedPtes(IN PMMPTE FirstPte, return STATUS_SUCCESS; } -#if (_MI_PAGING_LEVELS == 2) VOID NTAPI MiFillSystemPageDirectory(IN PVOID Base, @@ -418,7 +417,7 @@ MiFillSystemPageDirectory(IN PVOID Base, { PMMPDE PointerPde, LastPde, SystemMapPde; MMPDE TempPde; - PFN_NUMBER PageFrameIndex; + PFN_NUMBER PageFrameIndex, ParentPage; KIRQL OldIrql; PAGED_CODE(); @@ -426,8 +425,13 @@ MiFillSystemPageDirectory(IN PVOID Base, PointerPde = MiAddressToPde(Base); LastPde = MiAddressToPde((PVOID)((ULONG_PTR)Base + NumberOfBytes - 1)); +#if (_MI_PAGING_LEVELS == 2) /* Find the system double-mapped PDE that describes this mapping */ SystemMapPde = &MmSystemPagePtes[((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE)]; +#else + /* We don't have a double mapping */ + SystemMapPde = PointerPde; +#endif /* Use the PDE template and loop the PDEs */ TempPde = ValidKernelPde; @@ -446,10 +450,15 @@ MiFillSystemPageDirectory(IN PVOID Base, ASSERT(PageFrameIndex); TempPde.u.Hard.PageFrameNumber = PageFrameIndex; +#if (_MI_PAGING_LEVELS == 2) + ParentPage = MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_COUNT]; +#else + ParentPage = MiPdeToPpe(PointerPde)->u.Hard.PageFrameNumber; +#endif /* Initialize its PFN entry, with the parent system page directory page table */ MiInitializePfnForOtherProcess(PageFrameIndex, (PMMPTE)PointerPde, - MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) / PDE_COUNT]); + ParentPage); /* Make the system PDE entry valid */ MI_WRITE_VALID_PDE(SystemMapPde, TempPde); @@ -468,7 +477,6 @@ MiFillSystemPageDirectory(IN PVOID Base, PointerPde++; } } -#endif NTSTATUS NTAPI @@ -734,10 +742,8 @@ MiMapViewInSystemSpace(IN PVOID Section, Base = MiInsertInSystemSpace(Session, Buckets, ControlArea); ASSERT(Base); -#if (_MI_PAGING_LEVELS == 2) /* Create the PDEs needed for this mapping, and double-map them if needed */ MiFillSystemPageDirectory(Base, Buckets * MI_SYSTEM_VIEW_BUCKET_SIZE); -#endif /* Create the actual prototype PTEs for this mapping */ Status = MiAddMappedPtes(MiAddressToPte(Base), diff --git a/reactos/ntoskrnl/mm/amd64/init.c b/reactos/ntoskrnl/mm/amd64/init.c index 1a2e6bad142..00e832bf112 100644 --- a/reactos/ntoskrnl/mm/amd64/init.c +++ b/reactos/ntoskrnl/mm/amd64/init.c @@ -242,6 +242,9 @@ MiInitializePageTable() /* Setup 1 PPE for hyper space */ MiMapPPEs((PVOID)HYPER_SPACE, (PVOID)HYPER_SPACE_END); + /* Setup PPEs for system space view */ + MiMapPPEs(MiSystemViewStart, (PCHAR)MiSystemViewStart + MmSystemViewSize); + /* Setup the mapping PDEs */ MiMapPDEs((PVOID)MI_MAPPING_RANGE_START, (PVOID)MI_MAPPING_RANGE_END);