[NTOS]: Stop creating a memory area for the shared user data page.
authorSir Richard <sir_richard@svn.reactos.org>
Thu, 22 Jul 2010 20:54:37 +0000 (20:54 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Thu, 22 Jul 2010 20:54:37 +0000 (20:54 +0000)
[NTOS]: Also stop creating a memory area for the illegal user-mode parts of address space.
[NTOS]: Instead, mark the area between MM_HIGHEST_VAD_ADDRESS and MM_HIGHEST_USER_ADDRESS as being ARM3 as well: this way, ARM3 will get the illegal access (and fault), and it will also get the shared user data page access.
[NTOS]: With the previous commit, ARM3 knows how to handle the shared user data page access, and does so succesfully. End result: two more MAREA types have been removed, and the address space setup code is now much simpler.

svn path=/trunk/; revision=48202

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

index 75c25c6..00020a4 100644 (file)
@@ -33,7 +33,7 @@ MiRosTakeOverPebTebRanges(IN PEPROCESS Process)
     Status = MmCreateMemoryArea(&Process->Vm,
                                 MEMORY_AREA_OWNED_BY_ARM3,
                                 &AllocatedBase,
-                                ((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - 1) -
+                                ((ULONG_PTR)MM_HIGHEST_USER_ADDRESS - 1) -
                                 (ULONG_PTR)MI_LOWEST_VAD_ADDRESS,
                                 PAGE_READWRITE,
                                 &MemoryArea,
index 50b5611..308686d 100644 (file)
@@ -105,10 +105,6 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
 
       switch (MemoryArea->Type)
       {
-         case MEMORY_AREA_SYSTEM:
-            Status = STATUS_ACCESS_VIOLATION;
-            break;
-
          case MEMORY_AREA_PAGED_POOL:
             Status = STATUS_SUCCESS;
             break;
@@ -124,10 +120,6 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
             Status = STATUS_ACCESS_VIOLATION;
             break;
 
-         case MEMORY_AREA_SHARED_DATA:
-            Status = STATUS_ACCESS_VIOLATION;
-            break;
-
          default:
             Status = STATUS_ACCESS_VIOLATION;
             break;
@@ -153,7 +145,6 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
    MEMORY_AREA* MemoryArea;
    NTSTATUS Status;
    BOOLEAN Locked = FromMdl;
-   extern PMMPTE MmSharedUserDataPte;
 
    DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
 
@@ -211,10 +202,6 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
                break;
             }
 
-         case MEMORY_AREA_SYSTEM:
-            Status = STATUS_ACCESS_VIOLATION;
-            break;
-
          case MEMORY_AREA_SECTION_VIEW:
             Status = MmNotPresentFaultSectionView(AddressSpace,
                                                   MemoryArea,
@@ -223,18 +210,12 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
             break;
 
          case MEMORY_AREA_VIRTUAL_MEMORY:
-         case MEMORY_AREA_PEB_OR_TEB:
             Status = MmNotPresentFaultVirtualMemory(AddressSpace,
                                                     MemoryArea,
                                                     (PVOID)Address,
                                                     Locked);
             break;
 
-         case MEMORY_AREA_SHARED_DATA:
-              *MiAddressToPte(USER_SHARED_DATA) = *MmSharedUserDataPte;
-              Status = STATUS_SUCCESS;
-            break;
-
          default:
             Status = STATUS_ACCESS_VIOLATION;
             break;
@@ -284,7 +265,7 @@ MmAccessFault(IN BOOLEAN StoreInstruction,
      * can go away.
      */
     MemoryArea = MmLocateMemoryAreaByAddress(MmGetKernelAddressSpace(), Address);
-    if (!(MemoryArea) && (Address <= MM_HIGHEST_VAD_ADDRESS))
+    if (!(MemoryArea) && (Address <= MM_HIGHEST_USER_ADDRESS))
     {
         /* Could this be a VAD fault from user-mode? */
         MemoryArea = MmLocateMemoryAreaByAddress(MmGetCurrentAddressSpace(), Address);
index fce21f5..8694acf 100644 (file)
 #include <debug.h>
 
 VOID NTAPI MiRosTakeOverPebTebRanges(IN PEPROCESS Process);
-
+    
 /* FUNCTIONS *****************************************************************/
+
 NTSTATUS
 NTAPI
 MmInitializeHandBuiltProcess2(IN PEPROCESS Process)
 {
-    PVOID BaseAddress;
-    PMEMORY_AREA MemoryArea;
-    PHYSICAL_ADDRESS BoundaryAddressMultiple;
-    NTSTATUS Status;
-    PMMSUPPORT ProcessAddressSpace = &Process->Vm;
-    BoundaryAddressMultiple.QuadPart = 0;
-
-    /* Create the shared data page */
-    BaseAddress = (PVOID)USER_SHARED_DATA;
-    Status = MmCreateMemoryArea(ProcessAddressSpace,
-                                MEMORY_AREA_SHARED_DATA,
-                                &BaseAddress,
-                                PAGE_SIZE,
-                                PAGE_EXECUTE_READ,
-                                &MemoryArea,
-                                FALSE,
-                                0,
-                                BoundaryAddressMultiple);
-    
     /* Lock the VAD, ARM3-owned ranges away */                            
     MiRosTakeOverPebTebRanges(Process);
-    return Status;
+    return STATUS_SUCCESS;
 }
 
 NTSTATUS
@@ -53,15 +34,11 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
                                 IN OUT PULONG Flags,
                                 IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL)
 {
-    NTSTATUS Status;
+    NTSTATUS Status = STATUS_SUCCESS;
     PMMSUPPORT ProcessAddressSpace = &Process->Vm;
-    PVOID BaseAddress;
-    PMEMORY_AREA MemoryArea;
-    PHYSICAL_ADDRESS BoundaryAddressMultiple;
     SIZE_T ViewSize = 0;
     PVOID ImageBase = 0;
     PROS_SECTION_OBJECT SectionObject = Section;
-    BoundaryAddressMultiple.QuadPart = 0;
 
     /* Initialize the Addresss Space lock */
     KeInitializeGuardedMutex(&Process->AddressCreationLock);
@@ -73,59 +50,8 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
 
     /* Acquire the Lock */
     MmLockAddressSpace(ProcessAddressSpace);
-
-    /* Protect the highest 64KB of the process address space */
-    BaseAddress = (PVOID)MmUserProbeAddress;
-    Status = MmCreateMemoryArea(ProcessAddressSpace,
-                                MEMORY_AREA_NO_ACCESS,
-                                &BaseAddress,
-                                0x10000,
-                                PAGE_NOACCESS,
-                                &MemoryArea,
-                                FALSE,
-                                0,
-                                BoundaryAddressMultiple);
-    if (!NT_SUCCESS(Status))
-    {
-        DPRINT1("Failed to protect last 64KB\n");
-        goto exit;
-     }
-
-    /* Protect the 60KB above the shared user page */
-    BaseAddress = (char*)USER_SHARED_DATA + PAGE_SIZE;
-    Status = MmCreateMemoryArea(ProcessAddressSpace,
-                                MEMORY_AREA_NO_ACCESS,
-                                &BaseAddress,
-                                0x10000 - PAGE_SIZE,
-                                PAGE_NOACCESS,
-                                &MemoryArea,
-                                FALSE,
-                                0,
-                                BoundaryAddressMultiple);
-    if (!NT_SUCCESS(Status))
-    {
-        DPRINT1("Failed to protect the memory above the shared user page\n");
-        goto exit;
-     }
-
-    /* Create the shared data page */
-    BaseAddress = (PVOID)USER_SHARED_DATA;
-    Status = MmCreateMemoryArea(ProcessAddressSpace,
-                                MEMORY_AREA_SHARED_DATA,
-                                &BaseAddress,
-                                PAGE_SIZE,
-                                PAGE_EXECUTE_READ,
-                                &MemoryArea,
-                                FALSE,
-                                0,
-                                BoundaryAddressMultiple);
-    if (!NT_SUCCESS(Status))
-    {
-        DPRINT1("Failed to create Shared User Data\n");
-        goto exit;
-    }
      
-    /* Lock the VAD, ARM3-owned ranges away */                            
+    /* Lock the VAD, ARM3-owned ranges away */
     MiRosTakeOverPebTebRanges(Process);
 
     /* The process now has an address space */
@@ -207,7 +133,6 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
         return Status;
     }
 
-exit:
     /* Unlock the Address Space */
     DPRINT("Unlocking\n");
     MmUnlockAddressSpace(ProcessAddressSpace);
@@ -247,12 +172,9 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
              break;
 
          case MEMORY_AREA_VIRTUAL_MEMORY:
-         case MEMORY_AREA_PEB_OR_TEB:
              MmFreeVirtualMemory(Process, MemoryArea);
              break;
 
-         case MEMORY_AREA_SHARED_DATA:
-         case MEMORY_AREA_NO_ACCESS:
          case MEMORY_AREA_OWNED_BY_ARM3:
              MmFreeMemoryArea(&Process->Vm,
                               MemoryArea,
@@ -260,10 +182,6 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
                               NULL);
              break;
 
-         case MEMORY_AREA_MDL_MAPPING:
-            KeBugCheck(PROCESS_HAS_LOCKED_PAGES);
-            break;
-
          default:
             KeBugCheck(MEMORY_MANAGEMENT);
       }