From 75983b1ade50941fbc9942428f71d22ad9c1bea8 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Tue, 16 Aug 2005 20:36:03 +0000 Subject: [PATCH] - Fixed the offset calculation in MmWritePagePhysicalAddress and MmPageOutPhysicalAddress. - Add some code which will check for adding of multiple rmap entries. svn path=/trunk/; revision=17415 --- reactos/ntoskrnl/mm/rmap.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/mm/rmap.c b/reactos/ntoskrnl/mm/rmap.c index 3372b6c2b76..65423bf48de 100644 --- a/reactos/ntoskrnl/mm/rmap.c +++ b/reactos/ntoskrnl/mm/rmap.c @@ -21,6 +21,9 @@ typedef struct _MM_RMAP_ENTRY struct _MM_RMAP_ENTRY* Next; PEPROCESS Process; PVOID Address; +#ifdef DBG + PVOID Caller; +#endif } MM_RMAP_ENTRY, *PMM_RMAP_ENTRY; @@ -110,8 +113,8 @@ MmWritePagePhysicalAddress(PFN_TYPE Page) Type = MemoryArea->Type; if (Type == MEMORY_AREA_SECTION_VIEW) { - Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress; - + Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress + + MemoryArea->Data.SectionData.ViewOffset; /* * Get or create a pageop */ @@ -234,7 +237,8 @@ MmPageOutPhysicalAddress(PFN_TYPE Page) Type = MemoryArea->Type; if (Type == MEMORY_AREA_SECTION_VIEW) { - Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress; + Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress + + MemoryArea->Data.SectionData.ViewOffset;; /* * Get or create a pageop @@ -381,6 +385,9 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process, } new_entry->Address = Address; new_entry->Process = Process; +#ifdef DBG + new_entry->Caller = __builtin_return_address(0); +#endif if (MmGetPfnForProcess(Process, Address) != Page) { @@ -394,6 +401,22 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process, ExAcquireFastMutex(&RmapListLock); current_entry = MmGetRmapListHeadPage(Page); new_entry->Next = current_entry; +#ifdef DBG + while (current_entry) + { + if (current_entry->Address == new_entry->Address && current_entry->Process == new_entry->Process) + { + DbgPrint("MmInsertRmap tries to add a second rmap entry for address %p\n current caller ", + current_entry->Address); + KeRosPrintAddress(new_entry->Caller); + DbgPrint("\n previous caller "); + KeRosPrintAddress(current_entry->Caller); + DbgPrint("\n"); + KeBugCheck(0); + } + current_entry = current_entry->Next; + } +#endif MmSetRmapListHeadPage(Page, new_entry); ExReleaseFastMutex(&RmapListLock); if (Process == NULL)