[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
This commit is contained in:
Sir Richard 2010-07-22 20:54:37 +00:00
parent da305551a9
commit 89acc3113a
3 changed files with 7 additions and 108 deletions

View file

@ -33,7 +33,7 @@ MiRosTakeOverPebTebRanges(IN PEPROCESS Process)
Status = MmCreateMemoryArea(&Process->Vm, Status = MmCreateMemoryArea(&Process->Vm,
MEMORY_AREA_OWNED_BY_ARM3, MEMORY_AREA_OWNED_BY_ARM3,
&AllocatedBase, &AllocatedBase,
((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - 1) - ((ULONG_PTR)MM_HIGHEST_USER_ADDRESS - 1) -
(ULONG_PTR)MI_LOWEST_VAD_ADDRESS, (ULONG_PTR)MI_LOWEST_VAD_ADDRESS,
PAGE_READWRITE, PAGE_READWRITE,
&MemoryArea, &MemoryArea,

View file

@ -105,10 +105,6 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
switch (MemoryArea->Type) switch (MemoryArea->Type)
{ {
case MEMORY_AREA_SYSTEM:
Status = STATUS_ACCESS_VIOLATION;
break;
case MEMORY_AREA_PAGED_POOL: case MEMORY_AREA_PAGED_POOL:
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
@ -124,10 +120,6 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
Status = STATUS_ACCESS_VIOLATION; Status = STATUS_ACCESS_VIOLATION;
break; break;
case MEMORY_AREA_SHARED_DATA:
Status = STATUS_ACCESS_VIOLATION;
break;
default: default:
Status = STATUS_ACCESS_VIOLATION; Status = STATUS_ACCESS_VIOLATION;
break; break;
@ -153,7 +145,6 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
MEMORY_AREA* MemoryArea; MEMORY_AREA* MemoryArea;
NTSTATUS Status; NTSTATUS Status;
BOOLEAN Locked = FromMdl; BOOLEAN Locked = FromMdl;
extern PMMPTE MmSharedUserDataPte;
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address); DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
@ -211,10 +202,6 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
break; break;
} }
case MEMORY_AREA_SYSTEM:
Status = STATUS_ACCESS_VIOLATION;
break;
case MEMORY_AREA_SECTION_VIEW: case MEMORY_AREA_SECTION_VIEW:
Status = MmNotPresentFaultSectionView(AddressSpace, Status = MmNotPresentFaultSectionView(AddressSpace,
MemoryArea, MemoryArea,
@ -223,18 +210,12 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
break; break;
case MEMORY_AREA_VIRTUAL_MEMORY: case MEMORY_AREA_VIRTUAL_MEMORY:
case MEMORY_AREA_PEB_OR_TEB:
Status = MmNotPresentFaultVirtualMemory(AddressSpace, Status = MmNotPresentFaultVirtualMemory(AddressSpace,
MemoryArea, MemoryArea,
(PVOID)Address, (PVOID)Address,
Locked); Locked);
break; break;
case MEMORY_AREA_SHARED_DATA:
*MiAddressToPte(USER_SHARED_DATA) = *MmSharedUserDataPte;
Status = STATUS_SUCCESS;
break;
default: default:
Status = STATUS_ACCESS_VIOLATION; Status = STATUS_ACCESS_VIOLATION;
break; break;
@ -284,7 +265,7 @@ MmAccessFault(IN BOOLEAN StoreInstruction,
* can go away. * can go away.
*/ */
MemoryArea = MmLocateMemoryAreaByAddress(MmGetKernelAddressSpace(), Address); 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? */ /* Could this be a VAD fault from user-mode? */
MemoryArea = MmLocateMemoryAreaByAddress(MmGetCurrentAddressSpace(), Address); MemoryArea = MmLocateMemoryAreaByAddress(MmGetCurrentAddressSpace(), Address);

View file

@ -21,28 +21,9 @@ NTSTATUS
NTAPI NTAPI
MmInitializeHandBuiltProcess2(IN PEPROCESS Process) 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 */ /* Lock the VAD, ARM3-owned ranges away */
MiRosTakeOverPebTebRanges(Process); MiRosTakeOverPebTebRanges(Process);
return Status; return STATUS_SUCCESS;
} }
NTSTATUS NTSTATUS
@ -53,15 +34,11 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
IN OUT PULONG Flags, IN OUT PULONG Flags,
IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL) IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL)
{ {
NTSTATUS Status; NTSTATUS Status = STATUS_SUCCESS;
PMMSUPPORT ProcessAddressSpace = &Process->Vm; PMMSUPPORT ProcessAddressSpace = &Process->Vm;
PVOID BaseAddress;
PMEMORY_AREA MemoryArea;
PHYSICAL_ADDRESS BoundaryAddressMultiple;
SIZE_T ViewSize = 0; SIZE_T ViewSize = 0;
PVOID ImageBase = 0; PVOID ImageBase = 0;
PROS_SECTION_OBJECT SectionObject = Section; PROS_SECTION_OBJECT SectionObject = Section;
BoundaryAddressMultiple.QuadPart = 0;
/* Initialize the Addresss Space lock */ /* Initialize the Addresss Space lock */
KeInitializeGuardedMutex(&Process->AddressCreationLock); KeInitializeGuardedMutex(&Process->AddressCreationLock);
@ -74,57 +51,6 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
/* Acquire the Lock */ /* Acquire the Lock */
MmLockAddressSpace(ProcessAddressSpace); 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); MiRosTakeOverPebTebRanges(Process);
@ -207,7 +133,6 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
return Status; return Status;
} }
exit:
/* Unlock the Address Space */ /* Unlock the Address Space */
DPRINT("Unlocking\n"); DPRINT("Unlocking\n");
MmUnlockAddressSpace(ProcessAddressSpace); MmUnlockAddressSpace(ProcessAddressSpace);
@ -247,12 +172,9 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
break; break;
case MEMORY_AREA_VIRTUAL_MEMORY: case MEMORY_AREA_VIRTUAL_MEMORY:
case MEMORY_AREA_PEB_OR_TEB:
MmFreeVirtualMemory(Process, MemoryArea); MmFreeVirtualMemory(Process, MemoryArea);
break; break;
case MEMORY_AREA_SHARED_DATA:
case MEMORY_AREA_NO_ACCESS:
case MEMORY_AREA_OWNED_BY_ARM3: case MEMORY_AREA_OWNED_BY_ARM3:
MmFreeMemoryArea(&Process->Vm, MmFreeMemoryArea(&Process->Vm,
MemoryArea, MemoryArea,
@ -260,10 +182,6 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
NULL); NULL);
break; break;
case MEMORY_AREA_MDL_MAPPING:
KeBugCheck(PROCESS_HAS_LOCKED_PAGES);
break;
default: default:
KeBugCheck(MEMORY_MANAGEMENT); KeBugCheck(MEMORY_MANAGEMENT);
} }