From: Cameron Gutman Date: Wed, 14 Dec 2011 17:53:15 +0000 (+0000) Subject: [NTOSKRNL] X-Git-Tag: backups/usb-bringup@55523~3^2~153 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=c6b88aa125877421e22c641cd6338c43cfda38e5;hp=f4065b5b2ad09c5f542540014e4328e90c0b2908 [NTOSKRNL] - Don't page out locked pages - Fixes random failed assertions in MmUnlockPages svn path=/trunk/; revision=54648 --- diff --git a/reactos/ntoskrnl/mm/anonmem.c b/reactos/ntoskrnl/mm/anonmem.c index 7dfdfa1f5ad..8c7be81e513 100644 --- a/reactos/ntoskrnl/mm/anonmem.c +++ b/reactos/ntoskrnl/mm/anonmem.c @@ -74,6 +74,20 @@ MmPageOutVirtualMemory(PMMSUPPORT AddressSpace, MmReleasePageOp(PageOp); return(STATUS_UNSUCCESSFUL); } + + /* + * Check the reference count to ensure this page can be paged out + */ + Page = MmGetPfnForProcess(Process, Address); + if (MmGetReferenceCountPage(Page) != 1) + { + DPRINT1("Cannot page out locked virtual memory page: 0x%p (RefCount: %d)\n", + Page, MmGetReferenceCountPage(Page)); + PageOp->Status = STATUS_UNSUCCESSFUL; + KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); + MmReleasePageOp(PageOp); + return(STATUS_UNSUCCESSFUL); + } /* * Disable the virtual mapping. diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 8c3aea9852b..596be8a0674 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -2106,6 +2106,18 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, Page = MmGetPfnForProcess(Process, Address); SwapEntry = MmGetSavedSwapEntryPage(Page); + /* + * Check the reference count to ensure this page can be paged out + */ + if (MmGetReferenceCountPage(Page) != 1) + { + DPRINT1("Cannot page out locked section page: 0x%p (RefCount: %d)\n", + Page, MmGetReferenceCountPage(Page)); + PageOp->Status = STATUS_UNSUCCESSFUL; + MmspCompleteAndReleasePageOp(PageOp); + return STATUS_UNSUCCESSFUL; + } + /* * Prepare the context structure for the rmap delete call. */