Author: cgutman
Date: Wed Dec 14 17:53:15 2011
New Revision: 54648

URL: http://svn.reactos.org/svn/reactos?rev=54648&view=rev
Log:
[NTOSKRNL]
- Don't page out locked pages
- Fixes random failed assertions in MmUnlockPages

Modified:
    trunk/reactos/ntoskrnl/mm/anonmem.c
    trunk/reactos/ntoskrnl/mm/section.c

Modified: trunk/reactos/ntoskrnl/mm/anonmem.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/anonmem.c?rev=54648&r1=54647&r2=54648&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] Wed Dec 14 17:53:15 2011
@@ -74,6 +74,20 @@
         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.

Modified: trunk/reactos/ntoskrnl/mm/section.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=54648&r1=54647&r2=54648&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Wed Dec 14 17:53:15 2011
@@ -2105,6 +2105,18 @@
    }
    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.


Reply via email to