[NTOS]: Fix definition of unused MI_MAKE_SOFTWARE_PTE macro.

[NTOS]: Correctly setup the PFN entries for freshly allocated paged pool pages. Fixes a problem where the page could've still had stale/garbage data.
[NTOS]: Add some extra assertions in the code to catch memory corruption and detect invalid logic.
[NTOS]: Fix some typos in the code (comments/whitespace).
[NTOS]: Make the dreaded page fault message that breaks paged pool on some systems more verbose for future debugging.

svn path=/trunk/; revision=47189
This commit is contained in:
Sir Richard 2010-05-12 22:47:46 +00:00
parent 931fc122a0
commit df33b38ed0
5 changed files with 19 additions and 22 deletions

View file

@ -491,7 +491,7 @@ MiFreeContiguousMemory(IN PVOID BaseAddress)
StartPfn = Pfn1; StartPfn = Pfn1;
Pfn1->u3.e1.StartOfAllocation = 0; Pfn1->u3.e1.StartOfAllocation = 0;
/* Look the PFNs until we find the one that marks the end of the allocation */ /* Loop the PFNs until we find the one that marks the end of the allocation */
do do
{ {
/* Make sure these are the pages we setup in the allocation routine */ /* Make sure these are the pages we setup in the allocation routine */
@ -536,8 +536,8 @@ MiFreeContiguousMemory(IN PVOID BaseAddress)
// //
// Free each one, and move on // Free each one, and move on
// //
MmReleasePageMemoryConsumer(MC_NPPOOL, PageFrameIndex); MmReleasePageMemoryConsumer(MC_NPPOOL, PageFrameIndex++);
} while (++PageFrameIndex < LastPage); } while (PageFrameIndex < LastPage);
// //
// Release the PFN lock // Release the PFN lock

View file

@ -117,7 +117,7 @@
// //
// Creates a software PTE with the given protection // Creates a software PTE with the given protection
// //
#define MI_MAKE_SOFTWARE_PTE(x) ((x) << MM_PTE_SOFTWARE_PROTECTION_BITS) #define MI_MAKE_SOFTWARE_PTE(p, x) ((p)->u.Long = (x << MM_PTE_SOFTWARE_PROTECTION_BITS))
// //
// Special values for LoadedImports // Special values for LoadedImports

View file

@ -324,7 +324,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction,
// //
// This might happen...not sure yet // This might happen...not sure yet
// //
DPRINT1("FAULT ON PAGE TABLES!\n"); DPRINT1("FAULT ON PAGE TABLES: %p %lx %lx!\n", Address, *PointerPte, *PointerPde);
// //
// Map in the page table // Map in the page table

View file

@ -595,14 +595,15 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
// //
PageFrameNumber = MmAllocPage(MC_NPPOOL); PageFrameNumber = MmAllocPage(MC_NPPOOL);
// /* Get the PFN entry for it and fill it out */
// Get the PFN entry for it
//
Pfn1 = MiGetPfnEntry(PageFrameNumber); Pfn1 = MiGetPfnEntry(PageFrameNumber);
Pfn1->u3.e2.ReferenceCount = 1;
Pfn1->u2.ShareCount = 1;
Pfn1->PteAddress = PointerPte;
Pfn1->u3.e1.PageLocation = ActiveAndValid;
Pfn1->u4.VerifierAllocation = 0;
// /* Write the PTE for it */
// Write the PTE for it
//
TempPte.u.Hard.PageFrameNumber = PageFrameNumber; TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
ASSERT(PointerPte->u.Hard.Valid == 0); ASSERT(PointerPte->u.Hard.Valid == 0);
ASSERT(TempPte.u.Hard.Valid == 1); ASSERT(TempPte.u.Hard.Valid == 1);

View file

@ -153,7 +153,6 @@ MmCreateKernelStack(IN BOOLEAN GuiStack,
// Next PTE // Next PTE
// //
PointerPte++; PointerPte++;
ASSERT(PointerPte->u.Hard.Valid == 0);
// //
// Get a page // Get a page
@ -164,6 +163,8 @@ MmCreateKernelStack(IN BOOLEAN GuiStack,
// //
// Write it // Write it
// //
ASSERT(PointerPte->u.Hard.Valid == 0);
ASSERT(TempPte.u.Hard.Valid == 1);
*PointerPte = TempPte; *PointerPte = TempPte;
} }
@ -249,20 +250,15 @@ MmGrowKernelStackEx(IN PVOID StackPointer,
// //
while (LimitPte >= NewLimitPte) while (LimitPte >= NewLimitPte)
{ {
//
// Sanity check
//
ASSERT(LimitPte->u.Hard.Valid == 0);
// //
// Get a page // Get a page
// //
PageFrameIndex = MmAllocPage(MC_NPPOOL); PageFrameIndex = MmAllocPage(MC_NPPOOL);
TempPte.u.Hard.PageFrameNumber = PageFrameIndex; TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
// /* Write the valid PTE */
// Write it ASSERT(LimitPte->u.Hard.Valid == 0);
// ASSERT(TempPte.u.Hard.Valid == 1);
*LimitPte-- = TempPte; *LimitPte-- = TempPte;
} }