From ec3307ef64cf57d9133679d69921e64b69ac72ca Mon Sep 17 00:00:00 2001 From: ReactOS Portable Systems Group Date: Sun, 21 Jun 2009 05:33:48 +0000 Subject: [PATCH] - Define a new consumer: MC_SYSTEM: - Right now, it is only used for allocating new page tables for kernel-mode mappings. - This consumer's pages are never zeroed automatically (this is a more endemic ReactOS problem -- kernel pages are zeroed when they shouldn't be). - New page tables, however, should indeed be zeroed, so now they are zeroed manually with RtlZeroMemory. - The page zero function is not called anymore, and a useless zero-space hyperspace mapping is thus saved each time this happens. - Because of this, zero-space hyperspace mappings are required much later in the Memory Manager's initialization steps than before. svn path=/trunk/; revision=41508 --- reactos/ntoskrnl/include/internal/mm.h | 3 ++- reactos/ntoskrnl/mm/freelist.c | 2 +- reactos/ntoskrnl/mm/i386/page.c | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index ac776199304..75fd0e5ce7d 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -102,7 +102,8 @@ typedef ULONG PFN_TYPE, *PPFN_TYPE; #define MC_USER (1) #define MC_PPOOL (2) #define MC_NPPOOL (3) -#define MC_MAXIMUM (4) +#define MC_SYSTEM (4) +#define MC_MAXIMUM (5) #define PAGED_POOL_MASK 1 #define MUST_SUCCEED_POOL_MASK 2 diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index 426bd57e2cf..6ee34130982 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -777,7 +777,7 @@ MmAllocPage(ULONG Consumer, SWAPENTRY SwapEntry) KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql); PfnOffset = PageDescriptor - MmPfnDatabase; - if (NeedClear) + if ((NeedClear) && (Consumer != MC_SYSTEM)) { MiZeroPage(PfnOffset); } diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index f5b7fe4590a..9d2509f2005 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -310,7 +310,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) { return NULL; } - Status = MmRequestPageMemoryConsumer(MC_NPPOOL, FALSE, &Pfn); + Status = MmRequestPageMemoryConsumer(MC_SYSTEM, FALSE, &Pfn); if (!NT_SUCCESS(Status) || Pfn == 0) { KeBugCheck(MEMORY_MANAGEMENT); @@ -322,8 +322,11 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) } if(0 != InterlockedCompareExchangePte(&MmGlobalKernelPageDirectory[PdeOffset], Entry, 0)) { - MmReleasePageMemoryConsumer(MC_NPPOOL, Pfn); + MmReleasePageMemoryConsumer(MC_SYSTEM, Pfn); } + InterlockedExchangePte(PageDir, MmGlobalKernelPageDirectory[PdeOffset]); + RtlZeroMemory(MiPteToAddress(PageDir), PAGE_SIZE); + return (PULONG)MiAddressToPte(Address); } InterlockedExchangePte(PageDir, MmGlobalKernelPageDirectory[PdeOffset]); }