[NTOS:MM] Handle PT references for page table faults in MmAccessFault

Idea from Timo Kreuzer
This commit is contained in:
Jérôme Gardou 2021-06-07 14:29:37 +02:00 committed by Jérôme Gardou
parent c7e09061ca
commit afc27ab1aa
2 changed files with 8 additions and 9 deletions

View file

@ -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);

View file

@ -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 */