[ros-diffs] [ros-arm-bringup] 32364: One would expect that a function called "MmIsUsablePage" would return whether a not a page is usable. In other words, we are making sure that the page is free/available, so that we may make use of it. Apparently not so -- MmIsUsable page returned if a page was NOT usable, but was instead "already used". The caller's wish was to ensure he was correctly using a used page, not to check if he could start using a usable page. This would just be an annoying gramatical/logic error (but makes "sense" in the way it's used), if it weren't for the fact that MmIsUsablePage also returned TRUE for BIOS pages (which meant, "yes, you are correctly using/overwriting memory we spent time ensuring to mark as reserved/BIOS"). Renamed the function to MmIsPageInUse, and only return TRUE if the page is in use. Like the name says.

ros-arm-bringup at svn.reactos.org ros-arm-bringup at svn.reactos.org
Thu Feb 14 21:30:31 CET 2008


Author: ros-arm-bringup
Date: Thu Feb 14 23:30:31 2008
New Revision: 32364

URL: http://svn.reactos.org/svn/reactos?rev=32364&view=rev
Log:
One would expect that a function called "MmIsUsablePage" would return whether a not a page is usable. In other words, we are making sure that the page is free/available, so that we may make use of it. Apparently not so -- MmIsUsable page returned if a page was NOT usable, but was instead "already used". The caller's wish was to ensure he was correctly using a used page, not to check if he could start using a usable page. This would just be an annoying gramatical/logic error (but makes "sense" in the way it's used), if it weren't for the fact that MmIsUsablePage also returned TRUE for BIOS pages (which meant, "yes, you are correctly using/overwriting memory we spent time ensuring to mark as reserved/BIOS").
Renamed the function to MmIsPageInUse, and only return TRUE if the page is in use. Like the name says.

Modified:
    trunk/reactos/ntoskrnl/include/internal/mm.h
    trunk/reactos/ntoskrnl/mm/freelist.c
    trunk/reactos/ntoskrnl/mm/i386/page.c

Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/mm.h?rev=32364&r1=32363&r2=32364&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h Thu Feb 14 23:30:31 2008
@@ -1145,7 +1145,7 @@
 
 BOOLEAN
 NTAPI
-MmIsUsablePage(PFN_TYPE Page);
+MmIsPageInUse(PFN_TYPE Page);
 
 VOID
 NTAPI

Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev=32364&r1=32363&r2=32364&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c Thu Feb 14 23:30:31 2008
@@ -640,23 +640,17 @@
 
 BOOLEAN
 NTAPI
-MmIsUsablePage(PFN_TYPE Pfn)
-{
-
-   DPRINT("MmIsUsablePage(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT);
+MmIsPageInUse(PFN_TYPE Pfn)
+{
+
+   DPRINT("MmIsPageInUse(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT);
 
    if (Pfn == 0 || Pfn >= MmPageArraySize)
    {
       KEBUGCHECK(0);
    }
-
-   if (MmPageArray[Pfn].Flags.Type != MM_PHYSICAL_PAGE_USED &&
-         MmPageArray[Pfn].Flags.Type != MM_PHYSICAL_PAGE_BIOS)
-   {
-      return(FALSE);
-   }
-
-   return(TRUE);
+    
+   return (MmPageArray[Pfn].Flags.Type == MM_PHYSICAL_PAGE_USED);
 }
 
 VOID

Modified: trunk/reactos/ntoskrnl/mm/i386/page.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/i386/page.c?rev=32364&r1=32363&r2=32364&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/i386/page.c (original)
+++ trunk/reactos/ntoskrnl/mm/i386/page.c Thu Feb 14 23:30:31 2008
@@ -1941,18 +1941,10 @@
 
    for (i = 0; i < PageCount; i++)
    {
-      if (!MmIsUsablePage(Pages[i]))
-      {
-          /* Is this an attempt to map KUSER_SHARED_DATA? */
-         if ((Address == (PVOID)0x7FFE0000) && (PageCount == 1) && (Pages[0] == 2))
-         {
-            // allow
-         }
-         else
-         {
-            DPRINT1("Page at address %x not usable\n", PFN_TO_PTE(Pages[i]));
-            KEBUGCHECK(0);
-         }
+      if (!MmIsPageInUse(Pages[i]))
+      {
+         DPRINT1("Page at address %x not in use\n", PFN_TO_PTE(Pages[i]));
+         KEBUGCHECK(0);
       }
    }
 




More information about the Ros-diffs mailing list