From f827a8f12475f0c62339626d4d8efca6c2485a11 Mon Sep 17 00:00:00 2001 From: David Welch Date: Sun, 18 Feb 2001 17:43:32 +0000 Subject: [PATCH] Fixed reference counting of page tables Don't print addresses that aren't in the text segment of a module svn path=/trunk/; revision=1627 --- reactos/ntoskrnl/ke/i386/exp.c | 8 ++++++-- reactos/ntoskrnl/mm/i386/page.c | 22 +++++++++++++++++----- reactos/ntoskrnl/mm/section.c | 16 ++++++++-------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/reactos/ntoskrnl/ke/i386/exp.c b/reactos/ntoskrnl/ke/i386/exp.c index 48d9e24259b..705b4da3515 100644 --- a/reactos/ntoskrnl/ke/i386/exp.c +++ b/reactos/ntoskrnl/ke/i386/exp.c @@ -57,7 +57,8 @@ extern ULONG init_stack_top; extern unsigned int _text_start__, _text_end__; -static void print_address(PVOID address) +STATIC BOOLEAN +print_address(PVOID address) { PLIST_ENTRY current_entry; PMODULE_OBJECT current; @@ -75,12 +76,15 @@ static void print_address(PVOID address) { DbgPrint("<%wZ: %x>", ¤t->Name, address - current->Base); - return; + return(TRUE); } current_entry = current_entry->Flink; } +#if 0 DbgPrint("<%x>", address); +#endif + return(FALSE); } ULONG diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index db3ad1957b6..7be3f436eeb 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -1,4 +1,4 @@ -/* $Id: page.c,v 1.19 2001/02/10 22:51:11 dwelch Exp $ +/* $Id: page.c,v 1.20 2001/02/18 17:43:32 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -173,8 +173,9 @@ VOID MmFreePageTable(PEPROCESS Process, PVOID Address) { if (PageTable[i] != 0) { - DbgPrint("Page table entry not clear\n"); - KeBugCheck(0); + DbgPrint("Page table entry not clear at %x/%x (is %x)\n", + ((ULONG)Address / 4*1024*1024), i, PageTable[i]); + KeBugCheck(0); } } npage = *(ADDR_TO_PDE(Address)); @@ -324,7 +325,7 @@ VOID MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOL FreePage) Ptrc = Process->AddressSpace.PageTableRefCountTable; Ptrc[ADDR_TO_PAGE_TABLE(Address)]--; -#if 0 +#if 1 if (Ptrc[ADDR_TO_PAGE_TABLE(Address)] == 0) { MmFreePageTable(Process, Address); @@ -441,9 +442,20 @@ NTSTATUS MmCreateVirtualMapping(PEPROCESS Process, if (!MmIsUsablePage((PVOID)PhysicalAddress)) { + DPRINT1("Page not usable\n"); KeBugCheck(0); } - + if (Process == NULL && Address < (PVOID)KERNEL_BASE) + { + DPRINT1("No process\n"); + KeBugCheck(0); + } + if (Process != NULL && Address >= (PVOID)KERNEL_BASE) + { + DPRINT1("Setting kernel address with process context\n"); + KeBugCheck(0); + } + Attributes = ProtectToPTE(flProtect); if (Process != NULL && Process != CurrentProcess) diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 9f08c663e49..09f535e4bd4 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -1,4 +1,4 @@ -/* $Id: section.c,v 1.46 2001/02/14 02:53:53 dwelch Exp $ +/* $Id: section.c,v 1.47 2001/02/18 17:43:32 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -218,7 +218,7 @@ MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace, * and have a reference to a page containing valid data for the * section offset. Set the page and return success. */ - Status = MmCreateVirtualMapping(NULL, + Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, Attributes, (ULONG)Page); @@ -294,7 +294,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, /* * Just map the desired physical page */ - Status = MmCreateVirtualMapping(NULL, + Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, MemoryArea->Attributes, Offset.QuadPart); @@ -329,7 +329,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, MmLockSectionSegment(Segment); Page = MmAllocPage(0); } - Status = MmCreateVirtualMapping(NULL, + Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, MemoryArea->Attributes, (ULONG)Page); @@ -406,7 +406,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, Page = (PVOID)Entry; MmReferencePage(Page); - Status = MmCreateVirtualMapping(NULL, + Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, Attributes, (ULONG)Page); @@ -500,7 +500,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, */ MmSetWaitPage(Page); - Status = MmCreateVirtualMapping(NULL, + Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, Attributes, (ULONG)Page); @@ -541,7 +541,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, Page = (PVOID)Entry; MmReferencePage(Page); - Status = MmCreateVirtualMapping(NULL, + Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, Attributes, (ULONG)Page); @@ -626,7 +626,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace, memcpy(NewAddress, (PVOID)PAGE_ROUND_DOWN(Address), PAGESIZE); ExUnmapPage(NewAddress); - Status = MmCreateVirtualMapping(NULL, + Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Address, MemoryArea->Attributes, (ULONG)NewPage);