diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 1b4577400..bf6d36cd7 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -28,10 +28,6 @@ bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const { type != next.type) { return false; } - if (type == VMAType::AllocatedMemoryBlock && - (backing_block != next.backing_block || offset + size != next.offset)) { - return false; - } if (type == VMAType::BackingMemory && backing_memory + size != next.backing_memory) { return false; } @@ -71,28 +67,6 @@ VMManager::VMAHandle VMManager::FindVMA(VAddr target) const { } } -ResultVal VMManager::MapMemoryBlock(VAddr target, - std::shared_ptr> block, - std::size_t offset, u32 size, - MemoryState state) { - ASSERT(block != nullptr); - ASSERT(offset + size <= block->size()); - - // This is the appropriately sized VMA that will turn into our allocation. - CASCADE_RESULT(VMAIter vma_handle, CarveVMA(target, size)); - VirtualMemoryArea& final_vma = vma_handle->second; - ASSERT(final_vma.size == size); - - final_vma.type = VMAType::AllocatedMemoryBlock; - final_vma.permissions = VMAPermission::ReadWrite; - final_vma.meminfo_state = state; - final_vma.backing_block = block; - final_vma.offset = offset; - UpdatePageTableForVMA(final_vma); - - return MakeResult(MergeAdjacent(vma_handle)); -} - ResultVal VMManager::MapBackingMemoryToBase(VAddr base, u32 region_size, u8* memory, u32 size, MemoryState state) { @@ -197,8 +171,6 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) { vma.permissions = VMAPermission::None; vma.meminfo_state = MemoryState::Free; - vma.backing_block = nullptr; - vma.offset = 0; vma.backing_memory = nullptr; vma.paddr = 0; @@ -246,17 +218,6 @@ ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_p return RESULT_SUCCESS; } -void VMManager::RefreshMemoryBlockMappings(const std::vector* block) { - // If this ever proves to have a noticeable performance impact, allow users of the function to - // specify a specific range of addresses to limit the scan to. - for (const auto& p : vma_map) { - const VirtualMemoryArea& vma = p.second; - if (block == vma.backing_block.get()) { - UpdatePageTableForVMA(vma); - } - } -} - void VMManager::LogLayout(Log::Level log_level) const { for (const auto& p : vma_map) { const VirtualMemoryArea& vma = p.second; @@ -355,9 +316,6 @@ VMManager::VMAIter VMManager::SplitVMA(VMAIter vma_handle, u32 offset_in_vma) { switch (new_vma.type) { case VMAType::Free: break; - case VMAType::AllocatedMemoryBlock: - new_vma.offset += offset_in_vma; - break; case VMAType::BackingMemory: new_vma.backing_memory += offset_in_vma; break; @@ -395,10 +353,6 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { case VMAType::Free: Memory::UnmapRegion(page_table, vma.base, vma.size); break; - case VMAType::AllocatedMemoryBlock: - Memory::MapMemoryRegion(page_table, vma.base, vma.size, - vma.backing_block->data() + vma.offset); - break; case VMAType::BackingMemory: Memory::MapMemoryRegion(page_table, vma.base, vma.size, vma.backing_memory); break; diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 865c3ee99..db48d7aed 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -18,13 +18,10 @@ namespace Kernel { enum class VMAType : u8 { /// VMA represents an unmapped region of the address space. Free, - /// VMA is backed by a ref-counted allocate memory block. - AllocatedMemoryBlock, /// VMA is backed by a raw, unmanaged pointer. BackingMemory, /// VMA is mapped to MMIO registers at a fixed PAddr. MMIO, - // TODO(yuriks): Implement MemoryAlias to support MAP/UNMAP }; /// Permissions for mapped memory blocks @@ -72,12 +69,6 @@ struct VirtualMemoryArea { /// Tag returned by svcQueryMemory. Not otherwise used. MemoryState meminfo_state = MemoryState::Free; - // Settings for type = AllocatedMemoryBlock - /// Memory block backing this VMA. - std::shared_ptr> backing_block = nullptr; - /// Offset into the backing_memory the mapping starts from. - std::size_t offset = 0; - // Settings for type = BackingMemory /// Pointer backing this VMA. It will not be destroyed or freed when the VMA is removed. u8* backing_memory = nullptr; @@ -133,18 +124,6 @@ public: // TODO(yuriks): Should these functions actually return the handle? - /** - * Maps part of a ref-counted block of memory at a given address. - * - * @param target The guest address to start the mapping at. - * @param block The block to be mapped. - * @param offset Offset into `block` to map from. - * @param size Size of the mapping. - * @param state MemoryState tag to attach to the VMA. - */ - ResultVal MapMemoryBlock(VAddr target, std::shared_ptr> block, - std::size_t offset, u32 size, MemoryState state); - /** * Maps part of a ref-counted block of memory at the first free address after the given base. * @@ -203,12 +182,6 @@ public: /// Changes the permissions of a range of addresses, splitting VMAs as necessary. ResultCode ReprotectRange(VAddr target, u32 size, VMAPermission new_perms); - /** - * Scans all VMAs and updates the page table range of any that use the given vector as backing - * memory. This should be called after any operation that causes reallocation of the vector. - */ - void RefreshMemoryBlockMappings(const std::vector* block); - /// Dumps the address space layout to the log, for debugging void LogLayout(Log::Level log_level) const; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index ed5a04c9a..6469aa80b 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -92,9 +92,6 @@ static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) { auto& vma = it->second; switch (vma.type) { - case Kernel::VMAType::AllocatedMemoryBlock: - direct_pointer = vma.backing_block->data() + vma.offset; - break; case Kernel::VMAType::BackingMemory: direct_pointer = vma.backing_memory; break; diff --git a/src/tests/core/memory/vm_manager.cpp b/src/tests/core/memory/vm_manager.cpp index 9fb365df2..775a254a7 100644 --- a/src/tests/core/memory/vm_manager.cpp +++ b/src/tests/core/memory/vm_manager.cpp @@ -39,7 +39,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") { auto vma = manager->FindVMA(Memory::HEAP_VADDR); CHECK(vma != manager->vma_map.end()); CHECK(vma->second.type == Kernel::VMAType::Free); - CHECK(vma->second.backing_block == nullptr); + CHECK(vma->second.backing_memory == nullptr); } SECTION("changing memory permissions") {