diff options
author | Andreas Kling <kling@serenityos.org> | 2022-04-03 17:12:39 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-03 21:51:58 +0200 |
commit | 07f3d09c55226bd3f2e1ad7139521268a347d136 (patch) | |
tree | 26e9e4b3f4bea1fd317004e83f9063bd8d315141 /Kernel/Interrupts | |
parent | e852a69a069de6176cd6ff3534d5a606d383f396 (diff) | |
download | serenity-07f3d09c55226bd3f2e1ad7139521268a347d136.zip |
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.
Diffstat (limited to 'Kernel/Interrupts')
-rw-r--r-- | Kernel/Interrupts/APIC.cpp | 12 |
1 files changed, 1 insertions, 11 deletions
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<NonnullOwnPtr<Memory::Region>> 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<void const*>(apic_ap_start), apic_ap_start_size); |