Skip to content

Commit a5ce556

Browse files
tomutaIdanHo
authored andcommitted
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.
1 parent 5fa75db commit a5ce556

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Kernel/Interrupts/APIC.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,9 @@ UNMAP_AFTER_INIT void APIC::setup_ap_boot_environment()
345345
// * aps_to_enable u32 values for ap_cpu_init_stacks
346346
// * aps_to_enable u32 values for ap_cpu_init_processor_info_array
347347
constexpr u64 apic_startup_region_base = 0x8000;
348-
VERIFY(apic_startup_region_base + apic_ap_start_size < USER_RANGE_BASE);
349-
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());
348+
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();
349+
VERIFY(apic_startup_region_size < USER_RANGE_BASE);
350+
auto apic_startup_region = create_identity_mapped_region(PhysicalAddress(apic_startup_region_base), apic_startup_region_size);
350351
u8* apic_startup_region_ptr = apic_startup_region->vaddr().as_ptr();
351352
memcpy(apic_startup_region_ptr, reinterpret_cast<const void*>(apic_ap_start), apic_ap_start_size);
352353

0 commit comments

Comments
 (0)