Revert "smp/x86: Free up trampoline memory after use"

This reverts commit ae771dd8a1.
This commit is contained in:
mintsuki 2022-11-02 15:28:07 +01:00
parent f9e422b571
commit 9ae0bcefc9
1 changed files with 16 additions and 22 deletions

View File

@ -64,8 +64,6 @@ struct madt_gicc {
uint16_t spe_overflow_gsiv;
} __attribute__((packed));
static void *trampoline = NULL;
#if defined (__x86_64__) || defined (__i386__)
struct trampoline_passed_info {
@ -81,6 +79,14 @@ static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
struct limine_smp_info *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)
@ -211,14 +217,6 @@ struct limine_smp_info *init_smp(size_t *cpu_count,
*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)) {
@ -297,10 +295,6 @@ struct limine_smp_info *init_smp(size_t *cpu_count,
}
}
if (trampoline != NULL) {
pmm_free(trampoline, smp_trampoline_size);
}
return ret;
}
@ -332,6 +326,14 @@ static bool try_start_ap(int boot_method, uint64_t method_ptr,
struct limine_smp_info *info_struct,
uint64_t ttbr0, uint64_t ttbr1, uint64_t mair,
uint64_t tcr, uint64_t sctlr) {
// Prepare the trampoline
static void *trampoline = NULL;
if (trampoline == NULL) {
trampoline = ext_mem_alloc(0x1000);
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 + 0x1000)
@ -486,14 +488,6 @@ static struct limine_smp_info *try_acpi_smp(size_t *cpu_count,
*cpu_count = 0;
// Try to start all APs
// Prepare the trampoline
if (trampoline == NULL) {
trampoline = ext_mem_alloc(0x1000);
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)) {