https://git.reactos.org/?p=reactos.git;a=commitdiff;h=afc27ab1aabd7e715abfb…
commit afc27ab1aabd7e715abfbec509381ea1c8a04476
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Mon Jun 7 14:29:37 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Jun 9 11:27:18 2021 +0200
[NTOS:MM] Handle PT references for page table faults in MmAccessFault
Idea from Timo Kreuzer
---
ntoskrnl/mm/ARM3/pagfault.c | 9 ++++++++-
ntoskrnl/mm/ARM3/virtual.c | 8 --------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/ntoskrnl/mm/ARM3/pagfault.c b/ntoskrnl/mm/ARM3/pagfault.c
index b6e2f9e8287..4656828a3b0 100644
--- a/ntoskrnl/mm/ARM3/pagfault.c
+++ b/ntoskrnl/mm/ARM3/pagfault.c
@@ -2314,7 +2314,14 @@ UserFault:
* Check if this is a real user-mode address or actually a kernel-mode
* page table for a user mode address
*/
- if (Address <= MM_HIGHEST_USER_ADDRESS)
+ if (Address <= MM_HIGHEST_USER_ADDRESS
+#if _MI_PAGING_LEVELS >= 3
+ || MiIsUserPte(Address)
+#if _MI_PAGING_LEVELS == 4
+ || MiIsUserPde(Address)
+#endif
+#endif
+ )
{
/* Add an additional page table reference */
MiIncrementPageTableReferences(Address);
diff --git a/ntoskrnl/mm/ARM3/virtual.c b/ntoskrnl/mm/ARM3/virtual.c
index 27e2daa4241..0910d080542 100644
--- a/ntoskrnl/mm/ARM3/virtual.c
+++ b/ntoskrnl/mm/ARM3/virtual.c
@@ -2532,10 +2532,6 @@ MiMakePdeExistAndMakeValid(IN PMMPDE PointerPde,
//
if (!PointerPpe->u.Hard.Valid)
{
-#if _MI_PAGING_LEVELS == 4
- if (PointerPpe->u.Long == 0)
- MiIncrementPageTableReferences(PointerPde);
-#endif
MiMakeSystemAddressValid(PointerPde, TargetProcess);
ASSERT(PointerPpe->u.Hard.Valid == 1);
}
@@ -2544,10 +2540,6 @@ MiMakePdeExistAndMakeValid(IN PMMPDE PointerPde,
//
// And finally, make the PDE itself valid.
//
-#if _MI_PAGING_LEVELS >= 3
- if (PointerPde->u.Long == 0)
- MiIncrementPageTableReferences(PointerPte);
-#endif
MiMakeSystemAddressValid(PointerPte, TargetProcess);
/* Do not increment Page table refcount here for the PDE, this must be managed by
caller */