From 07f3d09c55226bd3f2e1ad7139521268a347d136 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 3 Apr 2022 17:12:39 +0200 Subject: Kernel: Make VM allocation atomic for userspace regions This patch move AddressSpace (the per-process memory manager) to using the new atomic "place" APIs in RegionTree as well, just like we did for MemoryManager in the previous commit. This required updating quite a few places where VM allocation and actually committing a Region object to the AddressSpace were separated by other code. All you have to do now is call into AddressSpace once and it'll take care of everything for you. --- Kernel/Interrupts/APIC.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'Kernel/Interrupts') diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp index 75bf6cecfd..fc1d67a64b 100644 --- a/Kernel/Interrupts/APIC.cpp +++ b/Kernel/Interrupts/APIC.cpp @@ -319,16 +319,6 @@ UNMAP_AFTER_INIT bool APIC::init_bsp() return true; } -UNMAP_AFTER_INIT static ErrorOr> create_identity_mapped_region(PhysicalAddress paddr, size_t size) -{ - auto vmobject = TRY(Memory::AnonymousVMObject::try_create_for_physical_range(paddr, size)); - auto region = TRY(Memory::Region::create_unplaced(move(vmobject), 0, {}, Memory::Region::Access::ReadWriteExecute)); - Memory::VirtualRange range { VirtualAddress { paddr.get() }, size }; - TRY(MM.region_tree().place_specifically(*region, range)); - TRY(region->map(MM.kernel_page_directory())); - return region; -} - UNMAP_AFTER_INIT void APIC::setup_ap_boot_environment() { VERIFY(!m_ap_boot_environment); @@ -342,7 +332,7 @@ UNMAP_AFTER_INIT void APIC::setup_ap_boot_environment() constexpr u64 apic_startup_region_base = 0x8000; auto apic_startup_region_size = Memory::page_round_up(apic_ap_start_size + (2 * aps_to_enable * sizeof(FlatPtr))).release_value_but_fixme_should_propagate_errors(); VERIFY(apic_startup_region_size < USER_RANGE_BASE); - auto apic_startup_region = MUST(create_identity_mapped_region(PhysicalAddress(apic_startup_region_base), apic_startup_region_size)); + auto apic_startup_region = MUST(MM.region_tree().create_identity_mapped_region(PhysicalAddress(apic_startup_region_base), apic_startup_region_size)); u8* apic_startup_region_ptr = apic_startup_region->vaddr().as_ptr(); memcpy(apic_startup_region_ptr, reinterpret_cast(apic_ap_start), apic_ap_start_size); -- cgit v1.2.3