From ac0487dfa5f64a94fa2e13f1c0d3e07ff8168947 Mon Sep 17 00:00:00 2001 From: ReactOS Portable Systems Group Date: Sun, 27 Jul 2008 20:58:23 +0000 Subject: [PATCH] - Fix a couple of bugs, and majorly refactor MmDeleteVirtualMapping to sync it to the x86 version somewhat more. svn path=/trunk/; revision=34859 --- reactos/ntoskrnl/mm/arm/stubs.c | 74 ++++++++------------------------- 1 file changed, 18 insertions(+), 56 deletions(-) diff --git a/reactos/ntoskrnl/mm/arm/stubs.c b/reactos/ntoskrnl/mm/arm/stubs.c index 7f3780fc4ae..c8d5c020db8 100644 --- a/reactos/ntoskrnl/mm/arm/stubs.c +++ b/reactos/ntoskrnl/mm/arm/stubs.c @@ -569,80 +569,42 @@ MmDeleteVirtualMapping(IN PEPROCESS Process, { PMMPTE PointerPte; MMPTE Pte; + PFN_NUMBER Pfn = 0; // // Get the PTE // PointerPte = MiGetPageTableForProcess(NULL, Address, FALSE); - if (!PointerPte) - { + if (PointerPte) + { // - // Invalid PDE + // Save and destroy the PTE // - if (WasDirty) *WasDirty = FALSE; - if (Page) *Page = 0; - return; - } - - // - // Save the PTE - // - Pte = *PointerPte; - if (PointerPte->u.Hard.L1.Fault.Type == FaultPte) - { + Pte = *PointerPte; + PointerPte->u.Hard.AsUlong = 0; + // - // Invalid PTE + // Flush the TLB // - if (WasDirty) *WasDirty = FALSE; - if (Page) *Page = 0; - return; - } - - // - // Destroy the PTE - // - PointerPte->u.Hard.AsUlong = 0; - ASSERT(PointerPte->u.Hard.L2.Fault.Type == FaultPte); - - // - // Flush the TLB - // - MiFlushTlb(PointerPte, Address); - - // - // Check if the PTE was valid - // - if (Pte.u.Hard.L2.Fault.Type != FaultPte) - { + MiFlushTlb(PointerPte, Address); + // - // Mark the page as unmapped + // Unmap the PFN // - MmMarkPageUnmapped(Pte.u.Hard.L2.Small.BaseAddress); - } - else - { + Pfn = Pte.u.Hard.L2.Small.BaseAddress; + if (Pfn) MmMarkPageUnmapped(Pfn); + // - // Make it sane + // Release the PFN if it was ours // - Pte.u.Hard.L2.Small.BaseAddress = 0; - } - - // - // Check if this was our page, and valid - // - if ((FreePage) && (Pte.u.Hard.L2.Fault.Type != FaultPte)) - { - // - // Release it - // - MmReleasePageMemoryConsumer(MC_NPPOOL, Pte.u.Hard.L2.Small.BaseAddress); + if ((FreePage) && (Pfn)) MmReleasePageMemoryConsumer(MC_NPPOOL, Pfn); } // // Return if the page was dirty // - if (WasDirty) *WasDirty = TRUE; // LIE!!! - if (Page) *Page = Pte.u.Hard.L2.Small.BaseAddress; + if (WasDirty) *WasDirty = FALSE; // LIE!!! + if (Page) *Page = Pfn; } PVOID