From 89acc3113ac881985931d3ef3c57faa1ca7246db Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Thu, 22 Jul 2010 20:54:37 +0000 Subject: [PATCH] [NTOS]: Stop creating a memory area for the shared user data page. [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 | 2 +- reactos/ntoskrnl/mm/mmfault.c | 21 +------ reactos/ntoskrnl/mm/procsup.c | 92 ++---------------------------- 3 files changed, 7 insertions(+), 108 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index 75c25c681cc..00020a44338 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -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, diff --git a/reactos/ntoskrnl/mm/mmfault.c b/reactos/ntoskrnl/mm/mmfault.c index 50b5611e7f4..308686df707 100644 --- a/reactos/ntoskrnl/mm/mmfault.c +++ b/reactos/ntoskrnl/mm/mmfault.c @@ -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); diff --git a/reactos/ntoskrnl/mm/procsup.c b/reactos/ntoskrnl/mm/procsup.c index fce21f5bd6f..8694acf0376 100644 --- a/reactos/ntoskrnl/mm/procsup.c +++ b/reactos/ntoskrnl/mm/procsup.c @@ -14,35 +14,16 @@ #include 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); } -- 2.17.1