Author: tkreuzer
Date: Sun Jul 25 00:50:03 2010
New Revision: 48238
URL:
http://svn.reactos.org/svn/reactos?rev=48238&view=rev
Log:
[NTOSKRNL]
Make MmIsAddressValid portable by using _MI_PAGING_LEVELS macro.
Modified:
trunk/reactos/ntoskrnl/include/internal/amd64/mm.h
trunk/reactos/ntoskrnl/include/internal/i386/mm.h
trunk/reactos/ntoskrnl/mm/ARM3/mmsup.c
trunk/reactos/ntoskrnl/mm/amd64/page.c
Modified: trunk/reactos/ntoskrnl/include/internal/amd64/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/amd64/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/amd64/mm.h [iso-8859-1] Sun Jul 25 00:50:03
2010
@@ -3,6 +3,8 @@
*/
#pragma once
+
+#define _MI_PAGING_LEVELS 4
/* Helper macros */
#define PAGE_MASK(x) ((x)&(~0xfff))
Modified: trunk/reactos/ntoskrnl/include/internal/i386/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/mm.h [iso-8859-1] Sun Jul 25 00:50:03
2010
@@ -6,6 +6,12 @@
struct _EPROCESS;
PULONG MmGetPageDirectory(VOID);
+
+#ifdef _PAE_
+#define _MI_PAGING_LEVELS 3
+#else
+#define _MI_PAGING_LEVELS 2
+#endif
#define PAGE_MASK(x) ((x)&(~0xfff))
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
Modified: trunk/reactos/ntoskrnl/mm/ARM3/mmsup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mmsup.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/mmsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/mmsup.c [iso-8859-1] Sun Jul 25 00:50:03 2010
@@ -64,22 +64,26 @@
NTAPI
MmIsAddressValid(IN PVOID VirtualAddress)
{
- //
- // Just check the Valid bit in the Address' PDE and PTE
- //
- if ((MiAddressToPde(VirtualAddress)->u.Hard.Valid == 0) ||
- (MiAddressToPte(VirtualAddress)->u.Hard.Valid == 0))
- {
- //
- // Attempting to access this page is guranteed to result in a page fault
- //
- return FALSE;
- }
+#if _MI_PAGING_LEVELS >= 4
+ /* Check if the PXE is valid */
+ if (MiAddressToPxe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
+#endif
- //
- // This address is valid now, but it will only stay so if the caller holds
- // the PFN lock
- //
+#if _MI_PAGING_LEVELS >= 3
+ /* Check if the PPE is valid */
+ if (MiAddressToPpe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
+#endif
+
+#if _MI_PAGING_LEVELS >= 2
+ /* Check if the PDE is valid */
+ if (MiAddressToPde(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
+#endif
+
+ /* Check if the PTE is valid */
+ if (MiAddressToPte(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
+
+ /* This address is valid now, but it will only stay so if the caller holds
+ * the PFN lock */
return TRUE;
}
Modified: trunk/reactos/ntoskrnl/mm/amd64/page.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/amd64/page.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/amd64/page.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/amd64/page.c [iso-8859-1] Sun Jul 25 00:50:03 2010
@@ -519,16 +519,4 @@
return 0;
}
-BOOLEAN
-NTAPI
-_MmIsAddressValid(IN PVOID VirtualAddress)
-{
- /* Check all four page table levels */
- return (MiAddressToPxe(VirtualAddress)->u.Hard.Valid != 0 &&
- MiAddressToPpe(VirtualAddress)->u.Hard.Valid != 0 &&
- MiAddressToPde(VirtualAddress)->u.Hard.Valid != 0 &&
- MiAddressToPte(VirtualAddress)->u.Hard.Valid != 0);
-}
-
-
/* EOF */