diff options
author | Tom <tomut@yahoo.com> | 2022-02-21 10:11:02 -0700 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2022-02-21 20:44:09 +0200 |
commit | a5ce5564a9abcf9b95ee84bc544716b193efbf1e (patch) | |
tree | 364fe4dce20722ee344d18950c78ffce24c35741 | |
parent | 5fa75dbcda74a3bc02cffbc7d336cc2f1f044a15 (diff) | |
download | serenity-a5ce5564a9abcf9b95ee84bc544716b193efbf1e.zip |
Kernel: Fix allocating identity-mapped APIC memory on x86_64
We were not allocating enough memory due to using u32 instead of
FlatPtr for each AP's stack pointer.
-rw-r--r-- | Kernel/Interrupts/APIC.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp index 9031aec6a5..b1244e2ab8 100644 --- a/Kernel/Interrupts/APIC.cpp +++ b/Kernel/Interrupts/APIC.cpp @@ -345,8 +345,9 @@ UNMAP_AFTER_INIT void APIC::setup_ap_boot_environment() // * aps_to_enable u32 values for ap_cpu_init_stacks // * aps_to_enable u32 values for ap_cpu_init_processor_info_array constexpr u64 apic_startup_region_base = 0x8000; - VERIFY(apic_startup_region_base + apic_ap_start_size < USER_RANGE_BASE); - auto apic_startup_region = create_identity_mapped_region(PhysicalAddress(apic_startup_region_base), Memory::page_round_up(apic_ap_start_size + (2 * aps_to_enable * sizeof(u32))).release_value_but_fixme_should_propagate_errors()); + 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 = 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<const void*>(apic_ap_start), apic_ap_start_size); |