- Hold the PFN lock when referencing pages

svn path=/trunk/; revision=56049
This commit is contained in:
Cameron Gutman 2012-03-05 19:29:39 +00:00
parent 4a78d2e988
commit 9973fe86bf
2 changed files with 13 additions and 0 deletions

View file

@ -104,8 +104,12 @@ MiZeroFillSection
PMEMORY_AREA MemoryArea;
PMM_SECTION_SEGMENT Segment;
LARGE_INTEGER FileOffset = *FileOffsetPtr, End, FirstMapped;
KIRQL OldIrql;
DPRINT("MiZeroFillSection(Address %x,Offset %x,Length %x)\n", Address, FileOffset.LowPart, Length);
AddressSpace = MmGetKernelAddressSpace();
MmLockAddressSpace(AddressSpace);
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, Address);
MmUnlockAddressSpace(AddressSpace);
@ -140,7 +144,10 @@ MiZeroFillSection
MmSetPageEntrySectionSegment(Segment, &FileOffset, MAKE_PFN_SSE(Page));
Address = ((PCHAR)MemoryArea->StartingAddress) + FileOffset.QuadPart - FirstMapped.QuadPart;
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
MmReferencePage(Page);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
MmCreateVirtualMapping(NULL, Address, PAGE_READWRITE, &Page, 1);
MmInsertRmap(Page, NULL, Address);
}
@ -175,6 +182,7 @@ _MiFlushMappedSection
LARGE_INTEGER FileOffset;
PFN_NUMBER Page;
PPFN_NUMBER Pages;
KIRQL OldIrql;
DPRINT("MiFlushMappedSection(%x,%08x,%x,%d,%s:%d)\n", BaseAddress, BaseOffset->LowPart, FileSize, WriteData, File, Line);
@ -222,7 +230,9 @@ _MiFlushMappedSection
(MmIsDirtyPageRmap(Page) || IS_DIRTY_SSE(Entry)) &&
FileOffset.QuadPart < FileSize->QuadPart)
{
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
MmReferencePage(Page);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
Pages[(PageAddress - BeginningAddress) >> PAGE_SHIFT] = Entry;
}
else

View file

@ -73,6 +73,7 @@ MmNotPresentFaultCachePage
ULONG Entry;
ULONG Attributes;
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
KIRQL OldIrql;
DPRINT("Not Present: %p %p (%p-%p)\n", AddressSpace, Address, MemoryArea->StartingAddress, MemoryArea->EndingAddress);
@ -175,7 +176,9 @@ MmNotPresentFaultCachePage
KeBugCheck(CACHE_MANAGER);
}
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
MmReferencePage(Page);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
Status = MmCreateVirtualMapping(Process, Address, Attributes, &Page, 1);
if (NT_SUCCESS(Status))