Author: cgutman Date: Mon Mar 5 19:29:39 2012 New Revision: 56049
URL: http://svn.reactos.org/svn/reactos?rev=56049&view=rev Log: [NEWCC] - Hold the PFN lock when referencing pages
Modified: trunk/reactos/ntoskrnl/cache/section/data.c trunk/reactos/ntoskrnl/cache/section/fault.c
Modified: trunk/reactos/ntoskrnl/cache/section/data.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/data... ============================================================================== --- trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] Mon Mar 5 19:29:39 2012 @@ -104,8 +104,12 @@ 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 @@ 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 @@ 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 @@ (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
Modified: trunk/reactos/ntoskrnl/cache/section/fault.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/faul... ============================================================================== --- trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] Mon Mar 5 19:29:39 2012 @@ -73,6 +73,7 @@ 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 @@ KeBugCheck(CACHE_MANAGER); }
+ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); MmReferencePage(Page); + KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
Status = MmCreateVirtualMapping(Process, Address, Attributes, &Page, 1); if (NT_SUCCESS(Status))