Revert my changes from rev 15805.

svn path=/trunk/; revision=15816
This commit is contained in:
Hartmut Birr 2005-06-05 21:24:36 +00:00
parent f97e4e54cd
commit 1272e9ca67
4 changed files with 50 additions and 114 deletions

View file

@ -367,9 +367,6 @@ typedef VOID (*PMM_FREE_PAGE_FUNC)(PVOID Context, PMEMORY_AREA MemoryArea,
/* FUNCTIONS */ /* FUNCTIONS */
VOID MmLockPagedPool(VOID);
VOID MmUnlockPagedPool(VOID);
/* aspace.c ******************************************************************/ /* aspace.c ******************************************************************/
VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace); VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace);

View file

@ -364,7 +364,6 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
PFN_TYPE Page; PFN_TYPE Page;
PEPROCESS CurrentProcess = PsGetCurrentProcess(); PEPROCESS CurrentProcess = PsGetCurrentProcess();
PMADDRESS_SPACE AddressSpace; PMADDRESS_SPACE AddressSpace;
BOOLEAN PagedPool;
DPRINT("MmProbeAndLockPages(Mdl %x)\n", Mdl); DPRINT("MmProbeAndLockPages(Mdl %x)\n", Mdl);
@ -399,7 +398,6 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
Mode = KernelMode; Mode = KernelMode;
Mdl->Process = NULL; Mdl->Process = NULL;
AddressSpace = MmGetKernelAddressSpace(); AddressSpace = MmGetKernelAddressSpace();
PagedPool = Mdl->StartVa >= MmPagedPoolBase && Mdl->StartVa < MmPagedPoolBase + MmPagedPoolSize ? TRUE : FALSE;
} }
else else
{ {
@ -407,21 +405,14 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
Mode = UserMode; Mode = UserMode;
Mdl->Process = CurrentProcess; Mdl->Process = CurrentProcess;
AddressSpace = &CurrentProcess->AddressSpace; AddressSpace = &CurrentProcess->AddressSpace;
PagedPool = FALSE;
} }
if (PagedPool)
{
MmLockPagedPool();
}
else
{
MmLockAddressSpace(AddressSpace);
}
/* /*
* Lock the pages * Lock the pages
*/ */
MmLockAddressSpace(AddressSpace);
for (i = 0; i < NrPages; i++) for (i = 0; i < NrPages; i++)
{ {
PVOID Address; PVOID Address;
@ -447,14 +438,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
MmDereferencePage(Page); MmDereferencePage(Page);
} }
} }
if (PagedPool) MmUnlockAddressSpace(AddressSpace);
{
MmUnlockPagedPool();
}
else
{
MmUnlockAddressSpace(AddressSpace);
}
ExRaiseStatus(STATUS_ACCESS_VIOLATION); ExRaiseStatus(STATUS_ACCESS_VIOLATION);
} }
} }
@ -478,14 +462,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
MmDereferencePage(Page); MmDereferencePage(Page);
} }
} }
if (PagedPool) MmUnlockAddressSpace(AddressSpace);
{
MmUnlockPagedPool();
}
else
{
MmUnlockAddressSpace(AddressSpace);
}
ExRaiseStatus(STATUS_ACCESS_VIOLATION); ExRaiseStatus(STATUS_ACCESS_VIOLATION);
} }
} }
@ -497,14 +474,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
MmReferencePage(Page); MmReferencePage(Page);
} }
if (PagedPool) MmUnlockAddressSpace(AddressSpace);
{
MmUnlockPagedPool();
}
else
{
MmUnlockAddressSpace(AddressSpace);
}
Mdl->MdlFlags |= MDL_PAGES_LOCKED; Mdl->MdlFlags |= MDL_PAGES_LOCKED;
} }

View file

@ -215,10 +215,6 @@ NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
DbgPrint("%s:%d\n",__FILE__,__LINE__); DbgPrint("%s:%d\n",__FILE__,__LINE__);
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
if (Address >= (ULONG_PTR)MmPagedPoolBase && Address < (ULONG_PTR)MmPagedPoolBase + MmPagedPoolSize)
{
return STATUS_SUCCESS;
}
AddressSpace = MmGetKernelAddressSpace(); AddressSpace = MmGetKernelAddressSpace();
} }
else else
@ -289,7 +285,9 @@ NTSTATUS MmCommitPagedPoolAddress(PVOID Address, BOOLEAN Locked)
Status = MmRequestPageMemoryConsumer(MC_PPOOL, FALSE, &AllocatedPage); Status = MmRequestPageMemoryConsumer(MC_PPOOL, FALSE, &AllocatedPage);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return Status; MmUnlockAddressSpace(MmGetKernelAddressSpace());
Status = MmRequestPageMemoryConsumer(MC_PPOOL, TRUE, &AllocatedPage);
MmLockAddressSpace(MmGetKernelAddressSpace());
} }
Status = Status =
MmCreateVirtualMapping(NULL, MmCreateVirtualMapping(NULL,
@ -313,7 +311,6 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
NTSTATUS Status; NTSTATUS Status;
BOOLEAN Locked = FromMdl; BOOLEAN Locked = FromMdl;
PFN_TYPE Pfn; PFN_TYPE Pfn;
BOOLEAN PagedPool;
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address); DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
@ -347,25 +344,16 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
CPRINT("Address: %x\n", Address); CPRINT("Address: %x\n", Address);
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
PagedPool = Address >= (ULONG_PTR)MmPagedPoolBase && Address < (ULONG_PTR)MmPagedPoolBase + MmPagedPoolSize ? TRUE : FALSE;
AddressSpace = MmGetKernelAddressSpace(); AddressSpace = MmGetKernelAddressSpace();
} }
else else
{ {
PagedPool = FALSE;
AddressSpace = &PsGetCurrentProcess()->AddressSpace; AddressSpace = &PsGetCurrentProcess()->AddressSpace;
} }
if (!FromMdl) if (!FromMdl)
{ {
if (PagedPool) MmLockAddressSpace(AddressSpace);
{
MmLockPagedPool();
}
else
{
MmLockAddressSpace(AddressSpace);
}
} }
/* /*
@ -373,56 +361,56 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
*/ */
do do
{ {
if (PagedPool) MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, (PVOID)Address);
if (MemoryArea == NULL || MemoryArea->DeleteInProgress)
{ {
Status = MmCommitPagedPoolAddress((PVOID)Address, Locked); if (!FromMdl)
{
MmUnlockAddressSpace(AddressSpace);
}
return (STATUS_UNSUCCESSFUL);
} }
else
switch (MemoryArea->Type)
{ {
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, (PVOID)Address); case MEMORY_AREA_PAGED_POOL:
if (MemoryArea == NULL || MemoryArea->DeleteInProgress)
{
if (!FromMdl)
{ {
MmUnlockAddressSpace(AddressSpace); Status = MmCommitPagedPoolAddress((PVOID)Address, Locked);
break;
} }
return (STATUS_UNSUCCESSFUL);
}
switch (MemoryArea->Type) case MEMORY_AREA_SYSTEM:
{ Status = STATUS_UNSUCCESSFUL;
case MEMORY_AREA_SYSTEM: break;
Status = STATUS_UNSUCCESSFUL;
break;
case MEMORY_AREA_SECTION_VIEW: case MEMORY_AREA_SECTION_VIEW:
Status = MmNotPresentFaultSectionView(AddressSpace, Status = MmNotPresentFaultSectionView(AddressSpace,
MemoryArea, MemoryArea,
(PVOID)Address, (PVOID)Address,
Locked); Locked);
break; break;
case MEMORY_AREA_VIRTUAL_MEMORY: case MEMORY_AREA_VIRTUAL_MEMORY:
case MEMORY_AREA_PEB_OR_TEB: 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: case MEMORY_AREA_SHARED_DATA:
Pfn = MmSharedDataPagePhysicalAddress.QuadPart >> PAGE_SHIFT; Pfn = MmSharedDataPagePhysicalAddress.QuadPart >> PAGE_SHIFT;
Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Status =
(PVOID)PAGE_ROUND_DOWN(Address), MmCreateVirtualMapping(PsGetCurrentProcess(),
PAGE_READONLY, (PVOID)PAGE_ROUND_DOWN(Address),
&Pfn, PAGE_READONLY,
1); &Pfn,
break; 1);
break;
default: default:
Status = STATUS_UNSUCCESSFUL; Status = STATUS_UNSUCCESSFUL;
break; break;
}
} }
} }
while (Status == STATUS_MM_RESTART_OPERATION); while (Status == STATUS_MM_RESTART_OPERATION);
@ -430,14 +418,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
DPRINT("Completed page fault handling\n"); DPRINT("Completed page fault handling\n");
if (!FromMdl) if (!FromMdl)
{ {
if (PagedPool) MmUnlockAddressSpace(AddressSpace);
{
MmUnlockPagedPool();
}
else
{
MmUnlockAddressSpace(AddressSpace);
}
} }
return(Status); return(Status);
} }

View file

@ -41,7 +41,6 @@ PVOID MmPagedPoolBase;
ULONG MmPagedPoolSize; ULONG MmPagedPoolSize;
ULONG MmTotalPagedPoolQuota = 0; // TODO FIXME commented out until we use it ULONG MmTotalPagedPoolQuota = 0; // TODO FIXME commented out until we use it
static PR_POOL MmPagedPool = NULL; static PR_POOL MmPagedPool = NULL;
static FAST_MUTEX MmPagedPoolLock;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -61,17 +60,6 @@ MmInitializePagedPool(VOID)
PAGE_SIZE ); PAGE_SIZE );
ExInitializeFastMutex(&MmPagedPool->Mutex); ExInitializeFastMutex(&MmPagedPool->Mutex);
ExInitializeFastMutex(&MmPagedPoolLock);
}
VOID MmLockPagedPool(VOID)
{
ExAcquireFastMutex(&MmPagedPoolLock);
}
VOID MmUnlockPagedPool(VOID)
{
ExReleaseFastMutex(&MmPagedPoolLock);
} }
/********************************************************************** /**********************************************************************