Skip to content

Commit be0d82c

Browse files
committed
sys/smp: Fix bug where the bottom of the temp_stack was used instead of the top
1 parent 75f6098 commit be0d82c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

common/sys/smp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ struct trampoline_passed_info {
3838
uint64_t smp_tpl_temp_stack;
3939
} __attribute__((packed));
4040

41+
#define TEMP_STACK_SIZE 8192
42+
4143
static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
4244
struct limine_mp_info *info_struct,
4345
int paging_mode, uint32_t pagemap,
@@ -52,7 +54,7 @@ static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
5254

5355
static void *temp_stack = NULL;
5456
if (temp_stack == NULL) {
55-
temp_stack = ext_mem_alloc(8192);
57+
temp_stack = ext_mem_alloc(TEMP_STACK_SIZE);
5658
}
5759

5860
static struct trampoline_passed_info *passed_info = NULL;
@@ -71,7 +73,7 @@ static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
7173
passed_info->smp_tpl_hhdm = hhdm;
7274
passed_info->smp_tpl_bsp_apic_addr_msr = rdmsr(0x1b);
7375
passed_info->smp_tpl_mtrr_restore = (uint64_t)(uintptr_t)mtrr_restore;
74-
passed_info->smp_tpl_temp_stack = (uint64_t)(uintptr_t)temp_stack;
76+
passed_info->smp_tpl_temp_stack = (uint64_t)(uintptr_t)temp_stack + TEMP_STACK_SIZE;
7577

7678
asm volatile ("" ::: "memory");
7779

0 commit comments

Comments
 (0)