[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.

svn path=/trunk/; revision=47579
This commit is contained in:
Sir Richard 2010-06-04 22:08:40 +00:00
parent c25fc39e6f
commit 25bf23bfc1
4 changed files with 63 additions and 18 deletions

View file

@ -706,6 +706,14 @@ MiInitializePfn(
IN BOOLEAN Modified
);
VOID
NTAPI
MiInitializePfnForOtherProcess(
IN PFN_NUMBER PageFrameIndex,
IN PMMPTE PointerPte,
IN PFN_NUMBER PteFrame
);
VOID
NTAPI
MiDecrementShareCount(

View file

@ -65,7 +65,7 @@ MiCheckPdeForPagedPool(IN PVOID Address)
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

View file

@ -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 @@ do { \
(x)->Flink != LIST_HEAD && \
(x)->Blink != LIST_HEAD)); \
} while (0)
#else
#define ASSERT_LIST_INVARIANT(x)
#endif
/* GLOBALS ********************************************************************/
@ -58,7 +62,6 @@ MiInsertInListTail(IN PMMPFNLIST ListHead,
IN PMMPFN Entry)
{
PFN_NUMBER OldBlink, EntryIndex = MiGetPfnEntryIndex(Entry);
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT_LIST_INVARIANT(ListHead);
@ -133,6 +136,7 @@ MiInsertZeroListAtBack(IN PFN_NUMBER EntryIndex)
/* 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;
@ -152,8 +156,6 @@ MiInsertZeroListAtBack(IN PFN_NUMBER EntryIndex)
KeSetEvent(MiHighMemoryEvent, 0, FALSE);
}
ASSERT_LIST_INVARIANT(ListHead);
#if 0
/* Get the page color */
Color = EntryIndex & MmSecondaryColorMask;
@ -328,6 +330,7 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex,
}
/* 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 */
@ -335,8 +338,6 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex,
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 */
ColorTable = &MmFreePagesByColor[ListName][Color];
@ -433,11 +434,10 @@ MiRemoveAnyPage(IN ULONG Color)
(Pfn1->u3.e1.PageLocation == ZeroedPageList));
ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
ASSERT(Pfn1->u2.ShareCount == 0);
/* Return the page */
ASSERT_LIST_INVARIANT(&MmFreePageListHead);
ASSERT_LIST_INVARIANT(&MmZeroedPageListHead);
/* Return the page */
return PageIndex;
}
@ -447,7 +447,6 @@ MiRemoveHeadList(IN PMMPFNLIST ListHead)
{
PFN_NUMBER Entry, Flink;
PMMPFN Pfn1;
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT_LIST_INVARIANT(ListHead);
@ -474,7 +473,6 @@ MiRemoveHeadList(IN PMMPFNLIST ListHead)
/* 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 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
/* 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;
@ -557,8 +556,6 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
KeSetEvent(MiHighMemoryEvent, 0, FALSE);
}
ASSERT_LIST_INVARIANT(ListHead);
#if 0 // When using ARM3 PFN
/* Get the page color */
Color = PageFrameIndex & MmSecondaryColorMask;
@ -762,4 +759,41 @@ MiDecrementShareCount(IN PMMPFN Pfn1,
}
}
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 */

View file

@ -325,20 +325,23 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
//
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;