Author: sir_richard Date: Thu May 13 00:47:46 2010 New Revision: 47189
URL: http://svn.reactos.org/svn/reactos?rev=47189&view=rev Log: [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.
Modified: trunk/reactos/ntoskrnl/mm/ARM3/contmem.c trunk/reactos/ntoskrnl/mm/ARM3/miarm.h trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c trunk/reactos/ntoskrnl/mm/ARM3/pool.c trunk/reactos/ntoskrnl/mm/ARM3/procsup.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/contmem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/contmem.c?... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/contmem.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/contmem.c [iso-8859-1] Thu May 13 00:47:46 2010 @@ -491,7 +491,7 @@ StartPfn = Pfn1; 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 { /* Make sure these are the pages we setup in the allocation routine */ @@ -530,14 +530,14 @@ // // Loop all the pages // - LastPage = PageFrameIndex + PageCount; + LastPage = PageFrameIndex + PageCount; do { // // Free each one, and move on // - MmReleasePageMemoryConsumer(MC_NPPOOL, PageFrameIndex); - } while (++PageFrameIndex < LastPage); + MmReleasePageMemoryConsumer(MC_NPPOOL, PageFrameIndex++); + } while (PageFrameIndex < LastPage);
// // Release the PFN lock
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?re... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Thu May 13 00:47:46 2010 @@ -117,7 +117,7 @@ // // 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
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c [iso-8859-1] Thu May 13 00:47:46 2010 @@ -324,7 +324,7 @@ // // 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
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pool.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pool.c?rev... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/pool.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/pool.c [iso-8859-1] Thu May 13 00:47:46 2010 @@ -595,14 +595,15 @@ // PageFrameNumber = MmAllocPage(MC_NPPOOL);
- // - // Get the PFN entry for it - // + /* Get the PFN entry for it and fill it out */ Pfn1 = MiGetPfnEntry(PageFrameNumber); - - // - // Write the PTE for it - // + 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 */ TempPte.u.Hard.PageFrameNumber = PageFrameNumber; ASSERT(PointerPte->u.Hard.Valid == 0); ASSERT(TempPte.u.Hard.Valid == 1);
Modified: trunk/reactos/ntoskrnl/mm/ARM3/procsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/procsup.c?... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] Thu May 13 00:47:46 2010 @@ -153,7 +153,6 @@ // Next PTE // PointerPte++; - ASSERT(PointerPte->u.Hard.Valid == 0);
// // Get a page @@ -164,6 +163,8 @@ // // Write it // + ASSERT(PointerPte->u.Hard.Valid == 0); + ASSERT(TempPte.u.Hard.Valid == 1); *PointerPte = TempPte; }
@@ -243,26 +244,21 @@ // Acquire the PFN DB lock // OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + // // Loop each stack page // while (LimitPte >= NewLimitPte) { - // - // Sanity check - // - ASSERT(LimitPte->u.Hard.Valid == 0); - // // Get a page // PageFrameIndex = MmAllocPage(MC_NPPOOL); TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
- // - // Write it - // + /* Write the valid PTE */ + ASSERT(LimitPte->u.Hard.Valid == 0); + ASSERT(TempPte.u.Hard.Valid == 1); *LimitPte-- = TempPte; }