From d4c1b9d311c978a6354574d09c451522ceb74e82 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 10:59:22 -0500 Subject: vm_manager: Make vma_map private This was only ever public so that code could check whether or not a handle was valid or not. Instead of exposing the object directly and allowing external code to potentially mess with the map contents, we just provide a member function that allows checking whether or not a handle is valid. This makes all member variables of the VMManager class private except for the page table. --- src/core/memory.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/core/memory.cpp') diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 41fd2a6a0..76f468c78 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -125,14 +125,13 @@ void RemoveDebugHook(PageTable& page_table, VAddr base, u64 size, MemoryHookPoin * using a VMA from the current process */ static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) { - u8* direct_pointer = nullptr; - - auto& vm_manager = process.VMManager(); + const auto& vm_manager = process.VMManager(); - auto it = vm_manager.FindVMA(vaddr); - ASSERT(it != vm_manager.vma_map.end()); + const auto it = vm_manager.FindVMA(vaddr); + ASSERT(vm_manager.IsValidHandle(it)); - auto& vma = it->second; + u8* direct_pointer = nullptr; + const auto& vma = it->second; switch (vma.type) { case Kernel::VMAType::AllocatedMemoryBlock: direct_pointer = vma.backing_block->data() + vma.offset; -- cgit v1.2.3 From 15e3d4f357f02275bc10818536f563b08f3326c9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 14:21:22 -0500 Subject: memory: Convert ASSERT into a DEBUG_ASSERT within GetPointerFromVMA() Given memory should always be expected to be valid during normal execution, this should be a debug assertion, rather than a check in regular builds. --- src/core/memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/memory.cpp') diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 76f468c78..643afdee8 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -128,7 +128,7 @@ static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) { const auto& vm_manager = process.VMManager(); const auto it = vm_manager.FindVMA(vaddr); - ASSERT(vm_manager.IsValidHandle(it)); + DEBUG_ASSERT(vm_manager.IsValidHandle(it)); u8* direct_pointer = nullptr; const auto& vma = it->second; -- cgit v1.2.3