From aa574a3c900fbbb4237b25965843a1e1274dc5c3 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Sun, 6 Jun 2010 14:15:18 +0000 Subject: [PATCH] [NTOS]: A PFN entry is not necessarily physical only if it is higher than MmHighestPhysicalPage. It can also be physical if it lies in a memory hole within the min-max physical page range. We can detect this by using our PFN Bitmap. So replace all "Is this an I/O mapping?" checks with a check on whether or not the PFN Database entry is NULL (which will check for us both of these statements). This ought to be a macro... svn path=/trunk/; revision=47623 --- reactos/ntoskrnl/mm/ARM3/iosup.c | 6 +++--- reactos/ntoskrnl/mm/ARM3/mdlsup.c | 2 +- reactos/ntoskrnl/mm/mmdbg.c | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/iosup.c b/reactos/ntoskrnl/mm/ARM3/iosup.c index 1a174509382..5d8cb2e12da 100644 --- a/reactos/ntoskrnl/mm/ARM3/iosup.c +++ b/reactos/ntoskrnl/mm/ARM3/iosup.c @@ -90,8 +90,8 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, // Also translate the cache attribute // Pfn = (PFN_NUMBER)(PhysicalAddress.QuadPart >> PAGE_SHIFT); - IsIoMapping = (Pfn > MmHighestPhysicalPage) ? TRUE : FALSE; - if (!IsIoMapping) Pfn1 = MiGetPfnEntry(Pfn); + Pfn1 = MiGetPfnEntry(Pfn); + IsIoMapping = (Pfn1 == NULL) ? TRUE : FALSE; CacheAttribute = MiPlatformCacheAttributes[IsIoMapping][CacheType]; // @@ -219,7 +219,7 @@ MmUnmapIoSpace(IN PVOID BaseAddress, // // Is this an I/O mapping? // - if (Pfn > MmHighestPhysicalPage) + if (!MiGetPfnEntry(Pfn)) { // // Destroy the PTE diff --git a/reactos/ntoskrnl/mm/ARM3/mdlsup.c b/reactos/ntoskrnl/mm/ARM3/mdlsup.c index 1b95448fc43..078de3de1c8 100644 --- a/reactos/ntoskrnl/mm/ARM3/mdlsup.c +++ b/reactos/ntoskrnl/mm/ARM3/mdlsup.c @@ -129,7 +129,7 @@ MmBuildMdlForNonPagedPool(IN PMDL Mdl) // // Check if this is an I/O mapping // - if (Pfn > MmHighestPhysicalPage) Mdl->MdlFlags |= MDL_IO_SPACE; + if (!MiGetPfnEntry(Pfn)) Mdl->MdlFlags |= MDL_IO_SPACE; } /* diff --git a/reactos/ntoskrnl/mm/mmdbg.c b/reactos/ntoskrnl/mm/mmdbg.c index fd11099e1fd..313516b1bf3 100644 --- a/reactos/ntoskrnl/mm/mmdbg.c +++ b/reactos/ntoskrnl/mm/mmdbg.c @@ -85,10 +85,8 @@ MiDbgTranslatePhysicalAddress(IN ULONG64 PhysicalAddress, // Pfn = (PFN_NUMBER)(PhysicalAddress >> PAGE_SHIFT); - // - // Check if this could be an I/O mapping - // - if (Pfn > MmHighestPhysicalPage) + /* Check if this could be an I/O mapping */ + if (!MiGetPfnEntry(Pfn)) { // // FIXME: We don't support this yet