From dd0ae4117c8bb621424b7b490b20514c93d19011 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 2 Nov 2022 15:28:08 +0100 Subject: [PATCH] Revert "smp/x86: Free up trampoline memory after use" This reverts commit 4b132dc1902aa133ed4266d6f516d3f26c1fca0e. --- common/sys/smp.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/common/sys/smp.c b/common/sys/smp.c index 97c65d28..79655fb7 100644 --- a/common/sys/smp.c +++ b/common/sys/smp.c @@ -42,8 +42,6 @@ struct madt_x2apic { extern symbol smp_trampoline_start; extern size_t smp_trampoline_size; -static void *trampoline = NULL; - struct trampoline_passed_info { uint8_t smp_tpl_booted_flag; uint8_t smp_tpl_target_mode; @@ -57,6 +55,14 @@ static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr, struct smp_information *info_struct, bool longmode, bool lv5, uint32_t pagemap, bool x2apic, bool nx, uint64_t hhdm, bool wp) { + // Prepare the trampoline + static void *trampoline = NULL; + if (trampoline == NULL) { + trampoline = conv_mem_alloc(smp_trampoline_size); + + memcpy(trampoline, smp_trampoline_start, smp_trampoline_size); + } + static struct trampoline_passed_info *passed_info = NULL; if (passed_info == NULL) { passed_info = (void *)(((uintptr_t)trampoline + smp_trampoline_size) @@ -191,14 +197,6 @@ struct smp_information *init_smp(size_t header_hack_size, *cpu_count = 0; // Try to start all APs - - // Prepare the trampoline - if (trampoline == NULL) { - trampoline = conv_mem_alloc(smp_trampoline_size); - - memcpy(trampoline, smp_trampoline_start, smp_trampoline_size); - } - for (uint8_t *madt_ptr = (uint8_t *)madt->madt_entries_begin; (uintptr_t)madt_ptr < (uintptr_t)madt + madt->header.length; madt_ptr += *(madt_ptr + 1)) { @@ -277,9 +275,5 @@ struct smp_information *init_smp(size_t header_hack_size, } } - if (trampoline != NULL) { - pmm_free(trampoline, smp_trampoline_size); - } - return ret; }