Author: sir_richard
Date: Sat Jun 5 00:08:40 2010
New Revision: 47579
URL:
http://svn.reactos.org/svn/reactos?rev=47579&view=rev
Log:
[NTOS]: When expanding paged pool, use MiRemoveAnyPage, not MmAllocPage.
[NTOS]: When expanding paged pool, initialize the PFN entry for the allocated page. Note
we might be in arbitrary process space, so the PTE is not necessary valid for the process
causing the expansion.
[NTOS]: Implement MiInitializePfnForOtherProcess to handle the case above.
[NTOS]: Change two static ASSERTs into C_ASSERTs. Might break non-x86 builds for a bit (vs
breaking them at boot, which is worse).
Paged pool should start working soon.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c
trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
trunk/reactos/ntoskrnl/mm/ARM3/pool.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Sat Jun 5 00:08:40 2010
@@ -708,6 +708,14 @@
VOID
NTAPI
+MiInitializePfnForOtherProcess(
+ IN PFN_NUMBER PageFrameIndex,
+ IN PMMPTE PointerPte,
+ IN PFN_NUMBER PteFrame
+);
+
+VOID
+NTAPI
MiDecrementShareCount(
IN PMMPFN Pfn1,
IN PFN_NUMBER PageFrameIndex
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pagfault.…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c [iso-8859-1] Sat Jun 5 00:08:40 2010
@@ -65,7 +65,7 @@
if (PointerPde->u.Hard.Valid == 0)
{
/* This seems to be making the assumption that one PDE is one page long */
- ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
+ C_ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
//
// Copy it from our double-mapped system page directory
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] Sat Jun 5 00:08:40 2010
@@ -16,6 +16,7 @@
#define MODULE_INVOLVED_IN_ARM3
#include "../ARM3/miarm.h"
+#if DBG
#define ASSERT_LIST_INVARIANT(x) \
do { \
ASSERT(((x)->Total == 0 && \
@@ -25,6 +26,9 @@
(x)->Flink != LIST_HEAD && \
(x)->Blink != LIST_HEAD)); \
} while (0)
+#else
+#define ASSERT_LIST_INVARIANT(x)
+#endif
/* GLOBALS ********************************************************************/
@@ -58,7 +62,6 @@
IN PMMPFN Entry)
{
PFN_NUMBER OldBlink, EntryIndex = MiGetPfnEntryIndex(Entry);
-
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT_LIST_INVARIANT(ListHead);
@@ -133,6 +136,7 @@
/* And now the head points back to us, since we are last */
ListHead->Blink = EntryIndex;
+ ASSERT_LIST_INVARIANT(ListHead);
/* Update the page location */
Pfn1->u3.e1.PageLocation = ZeroedPageList;
@@ -151,8 +155,6 @@
/* Otherwise check if we reached the high threshold and signal the event */
KeSetEvent(MiHighMemoryEvent, 0, FALSE);
}
-
- ASSERT_LIST_INVARIANT(ListHead);
#if 0
/* Get the page color */
@@ -328,14 +330,13 @@
}
/* We are not on a list anymore */
+ ASSERT_LIST_INVARIANT(ListHead);
Pfn1->u1.Flink = Pfn1->u2.Blink = 0;
/* Zero flags but restore color and cache */
Pfn1->u3.e2.ShortFlags = 0;
Pfn1->u3.e1.PageColor = OldColor;
Pfn1->u3.e1.CacheAttribute = OldCache;
-
- ASSERT_LIST_INVARIANT(ListHead);
#if 0 // When switching to ARM3
/* Get the first page on the color list */
@@ -433,11 +434,10 @@
(Pfn1->u3.e1.PageLocation == ZeroedPageList));
ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
ASSERT(Pfn1->u2.ShareCount == 0);
+ ASSERT_LIST_INVARIANT(&MmFreePageListHead);
+ ASSERT_LIST_INVARIANT(&MmZeroedPageListHead);
/* Return the page */
- ASSERT_LIST_INVARIANT(&MmFreePageListHead);
- ASSERT_LIST_INVARIANT(&MmZeroedPageListHead);
-
return PageIndex;
}
@@ -447,7 +447,6 @@
{
PFN_NUMBER Entry, Flink;
PMMPFN Pfn1;
-
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT_LIST_INVARIANT(ListHead);
@@ -474,7 +473,6 @@
/* We are not on a list anymore */
Pfn1->u1.Flink = Pfn1->u2.Blink = 0;
ListHead->Total--;
-
ASSERT_LIST_INVARIANT(ListHead);
/* Return the head element */
@@ -529,6 +527,7 @@
/* Now make the list head point back to us (since we go at the end) */
ListHead->Blink = PageFrameIndex;
+ ASSERT_LIST_INVARIANT(ListHead);
/* And initialize our own list pointers */
Pfn1->u1.Flink = LIST_HEAD;
@@ -556,8 +555,6 @@
/* Otherwise check if we reached the high threshold and signal the event */
KeSetEvent(MiHighMemoryEvent, 0, FALSE);
}
-
- ASSERT_LIST_INVARIANT(ListHead);
#if 0 // When using ARM3 PFN
/* Get the page color */
@@ -762,4 +759,41 @@
}
}
+VOID
+NTAPI
+MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex,
+ IN PMMPTE PointerPte,
+ IN PFN_NUMBER PteFrame)
+{
+ PMMPFN Pfn1;
+
+ /* Setup the PTE */
+ Pfn1 = MiGetPfnEntry(PageFrameIndex);
+ Pfn1->PteAddress = PointerPte;
+
+#if 0 // When using ARM3 PFN
+ /* Make this a software PTE */
+ MI_MAKE_SOFTWARE_PTE(&Pfn1->OriginalPte, MM_READWRITE);
+#endif
+
+ /* Setup the page */
+ ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
+ Pfn1->u3.e2.ReferenceCount = 1;
+ Pfn1->u2.ShareCount = 1;
+ Pfn1->u3.e1.PageLocation = ActiveAndValid;
+ Pfn1->u3.e1.Modified = TRUE;
+ Pfn1->u4.InPageError = FALSE;
+
+ /* Did we get a PFN for the page table */
+ if (PteFrame)
+ {
+ /* Store it */
+ Pfn1->u4.PteFrame = PteFrame;
+
+ /* Increase its share count so we don't get rid of it */
+ Pfn1 = MiGetPfnEntry(PageFrameIndex);
+ Pfn1->u2.ShareCount++;
+ }
+}
+
/* EOF */
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pool.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pool.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pool.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pool.c [iso-8859-1] Sat Jun 5 00:08:40 2010
@@ -325,20 +325,23 @@
//
ASSERT(PointerPte->u.Hard.Valid == 0);
- //
- // Request a paged pool page and write the PFN for it
- //
- PageFrameNumber = MmAllocPage(MC_PPOOL);
+ /* Request a page */
+ PageFrameNumber = MiRemoveAnyPage(0);
TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
//
// Save it into our double-buffered system page directory
//
/* This seems to be making the assumption that one PDE is one page long
*/
- ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
+ C_ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
MmSystemPagePtes[(ULONG_PTR)PointerPte & (PAGE_SIZE - 1) /
sizeof(MMPTE)] = TempPte;
+ /* Initialize the PFN */
+ MiInitializePfnForOtherProcess(PageFrameNumber,
+ PointerPte,
+ MmSystemPageDirectory[(PointerPte -
(PMMPTE)PDE_BASE) / PDE_COUNT]);
+
/* Write the actual PTE now */
ASSERT(TempPte.u.Hard.Valid == 1);
*PointerPte++ = TempPte;