From 4d4e4bb68a74fec7a38e0abd6bacb140cde1211f Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 25 Dec 2017 20:13:50 +0100 Subject: [PATCH] [NTOS] Deduplicate MiSynchronizeSystemPde(). #179 --- ntoskrnl/mm/ARM3/miarm.h | 23 +++++++++++++++++++++++ ntoskrnl/mm/ARM3/pagfault.c | 21 --------------------- ntoskrnl/mm/i386/page.c | 22 ---------------------- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h index c1d81807f6a..b68d680210e 100644 --- a/ntoskrnl/mm/ARM3/miarm.h +++ b/ntoskrnl/mm/ARM3/miarm.h @@ -2260,4 +2260,27 @@ MiRemoveZeroPageSafe(IN ULONG Color) return 0; } +#if (_MI_PAGING_LEVELS == 2) +FORCEINLINE +BOOLEAN +MiSynchronizeSystemPde(PMMPDE PointerPde) +{ + MMPDE SystemPde; + ULONG Index; + + /* Get the Index from the PDE */ + Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE); + + /* Copy the PDE from the double-mapped system page directory */ + SystemPde = MmSystemPagePtes[Index]; + *PointerPde = SystemPde; + + /* Make sure we re-read the PDE and PTE */ + KeMemoryBarrierWithoutFence(); + + /* Return, if we had success */ + return SystemPde.u.Hard.Valid != 0; +} +#endif + /* EOF */ diff --git a/ntoskrnl/mm/ARM3/pagfault.c b/ntoskrnl/mm/ARM3/pagfault.c index 2e962edd924..1e70cc07b90 100644 --- a/ntoskrnl/mm/ARM3/pagfault.c +++ b/ntoskrnl/mm/ARM3/pagfault.c @@ -310,27 +310,6 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress, } #if (_MI_PAGING_LEVELS == 2) -FORCEINLINE -BOOLEAN -MiSynchronizeSystemPde(PMMPDE PointerPde) -{ - MMPDE SystemPde; - ULONG Index; - - /* Get the Index from the PDE */ - Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE); - - /* Copy the PDE from the double-mapped system page directory */ - SystemPde = MmSystemPagePtes[Index]; - *PointerPde = SystemPde; - - /* Make sure we re-read the PDE and PTE */ - KeMemoryBarrierWithoutFence(); - - /* Return, if we had success */ - return (BOOLEAN)SystemPde.u.Hard.Valid; -} - NTSTATUS FASTCALL MiCheckPdeForSessionSpace(IN PVOID Address) diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c index b371c12200a..4ed0ebc29f1 100644 --- a/ntoskrnl/mm/i386/page.c +++ b/ntoskrnl/mm/i386/page.c @@ -189,28 +189,6 @@ ProtectToPTE(ULONG flProtect) return(Attributes); } -/* Taken from ARM3/pagfault.c */ -FORCEINLINE -BOOLEAN -MiSynchronizeSystemPde(PMMPDE PointerPde) -{ - MMPDE SystemPde; - ULONG Index; - - /* Get the Index from the PDE */ - Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE); - - /* Copy the PDE from the double-mapped system page directory */ - SystemPde = MmSystemPagePtes[Index]; - *PointerPde = SystemPde; - - /* Make sure we re-read the PDE and PTE */ - KeMemoryBarrierWithoutFence(); - - /* Return, if we had success */ - return SystemPde.u.Hard.Valid != 0; -} - NTSTATUS NTAPI MiDispatchFault(IN BOOLEAN StoreInstruction,