From e89c9ed2cac7f27a3a38e2cad944a7ce50dd00e9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 3 Apr 2022 17:31:58 +0200 Subject: [PATCH] Kernel: Stop exposing RegionTree API for VM range allocation ...and remove the last remaining client of the API. It's no longer possible to ask the RegionTree for a VM range. You can only ask it to place your Region somewhere in available space. --- Kernel/Memory/MemoryManager.cpp | 5 +++-- Kernel/Memory/RegionTree.h | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index b0c1ecb88a..a14c287d18 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -456,8 +456,9 @@ UNMAP_AFTER_INIT void MemoryManager::initialize_physical_pages() // Allocate a virtual address range for our array // This looks awkward, but it basically creates a dummy region to occupy the address range permanently. - auto range = MUST(m_region_tree.try_allocate_anywhere(physical_page_array_pages * PAGE_SIZE)); - MUST(m_region_tree.place_specifically(*MUST(Region::create_unbacked()).leak_ptr(), range)); + auto& region = *MUST(Region::create_unbacked()).leak_ptr(); + MUST(m_region_tree.place_anywhere(region, physical_page_array_pages * PAGE_SIZE)); + auto range = region.range(); // Now that we have our special m_physical_pages_region region with enough pages to hold the entire array // try to map the entire region into kernel space so we always have it diff --git a/Kernel/Memory/RegionTree.h b/Kernel/Memory/RegionTree.h index ec1aa82ee0..81b530aebc 100644 --- a/Kernel/Memory/RegionTree.h +++ b/Kernel/Memory/RegionTree.h @@ -39,13 +39,13 @@ public: ErrorOr> create_identity_mapped_region(PhysicalAddress, size_t); + void delete_all_regions_assuming_they_are_unmapped(); + +private: ErrorOr try_allocate_anywhere(size_t size, size_t alignment = PAGE_SIZE); ErrorOr try_allocate_specific(VirtualAddress base, size_t size); ErrorOr try_allocate_randomized(size_t size, size_t alignment = PAGE_SIZE); - void delete_all_regions_assuming_they_are_unmapped(); - -private: Spinlock m_lock; IntrusiveRedBlackTree<&Region::m_tree_node> m_regions;