[NTOS]: MiRosTakeOverPebTebRanges now creates a small ~1MB ARM3 memory range on top...
authorSir Richard <sir_richard@svn.reactos.org>
Thu, 22 Jul 2010 03:22:43 +0000 (03:22 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Thu, 22 Jul 2010 03:22:43 +0000 (03:22 +0000)
[NTOS]: Knowing if this change causes issues will help later in determining regressions due to TEB/PEBs mapped as VADs by ARM3, and regressions simply due to the change in VA layout.
[NTOS]: When implemented, the VAD mapping for PEB/TEB will only use that ~1MB, which yes, will limit ReactOS processes to each have only 256 threads. That is obviously a temporary limitation, one I doubt we'll even hit, but I'm putting it out here so you know.

svn path=/trunk/; revision=48176

reactos/ntoskrnl/mm/ARM3/procsup.c
reactos/ntoskrnl/mm/procsup.c

index 63b0942..d2ea798 100644 (file)
@@ -25,6 +25,29 @@ MiCreatePebOrTeb(PEPROCESS Process,
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
+VOID
+NTAPI
+MiRosTakeOverPebTebRanges(IN PEPROCESS Process)
+{
+    NTSTATUS Status;
+    PMEMORY_AREA MemoryArea;
+    PHYSICAL_ADDRESS BoundaryAddressMultiple;
+    PVOID AllocatedBase = (PVOID)MI_LOWEST_VAD_ADDRESS;
+    BoundaryAddressMultiple.QuadPart = 0;
+
+    Status = MmCreateMemoryArea(&Process->Vm,
+                                MEMORY_AREA_OWNED_BY_ARM3,
+                                &AllocatedBase,
+                                ((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - 1) -
+                                (ULONG_PTR)MI_LOWEST_VAD_ADDRESS,
+                                PAGE_READWRITE,
+                                &MemoryArea,
+                                TRUE,
+                                0,
+                                BoundaryAddressMultiple);
+    ASSERT(NT_SUCCESS(Status));
+}
+
 VOID
 NTAPI
 MmDeleteKernelStack(IN PVOID StackBase,
@@ -394,8 +417,8 @@ MmCreatePeb(IN PEPROCESS Process,
     //
     Peb = MiCreatePebOrTeb(Process,
                            (PVOID)((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS + 1));
-    ASSERT(Peb == (PVOID)0x7FFDF000);
-    
+    if (!Peb) return STATUS_INSUFFICIENT_RESOURCES;
+
     //
     // Map NLS Tables
     //
index ededba8..1e5bd9a 100644 (file)
 #define NDEBUG
 #include <debug.h>
 
-/* FUNCTIONS *****************************************************************/
+VOID NTAPI MiRosTakeOverPebTebRanges(IN PEPROCESS Process);
 
+/* FUNCTIONS *****************************************************************/
 PVOID
 NTAPI
 MiCreatePebOrTeb(PEPROCESS Process,
@@ -111,6 +113,9 @@ MmInitializeHandBuiltProcess2(IN PEPROCESS Process)
                                 FALSE,
                                 0,
                                 BoundaryAddressMultiple);
+    
+    /* Lock the VAD, ARM3-owned ranges away */                            
+    MiRosTakeOverPebTebRanges(Process);
     return Status;
 }
 
@@ -192,7 +197,10 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
     {
         DPRINT1("Failed to create Shared User Data\n");
         goto exit;
-     }
+    }
+     
+    /* Lock the VAD, ARM3-owned ranges away */                            
+    MiRosTakeOverPebTebRanges(Process);
 
     /* The process now has an address space */
     Process->HasAddressSpace = TRUE;
@@ -319,6 +327,7 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
 
          case MEMORY_AREA_SHARED_DATA:
          case MEMORY_AREA_NO_ACCESS:
+         case MEMORY_AREA_OWNED_BY_ARM3:
              MmFreeMemoryArea(&Process->Vm,
                               MemoryArea,
                               NULL,