From aaad77aea5b1ade9678f788b9b9cfb59803faacd Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 7 May 2023 21:40:12 +0100 Subject: [PATCH] x86_64: zero-init BSP and AP CPU cpu_data before use --- arch/x86_64/acpi/smp.cpp | 1 + arch/x86_64/init.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/x86_64/acpi/smp.cpp b/arch/x86_64/acpi/smp.cpp index b753238..bb90f96 100644 --- a/arch/x86_64/acpi/smp.cpp +++ b/arch/x86_64/acpi/smp.cpp @@ -29,6 +29,7 @@ extern "C" void ap_trampoline_exit(void) this_cpu->c_cpu_id = cpu_id; struct cpu_data *self = get_this_cpu(); + memset(self, 0x0, sizeof *self); self->c_flags = CPU_ONLINE; self->c_id = cpu_id; this_cpu->c_data = self; diff --git a/arch/x86_64/init.c b/arch/x86_64/init.c index e9b445c..6d15ce8 100644 --- a/arch/x86_64/init.c +++ b/arch/x86_64/init.c @@ -63,6 +63,8 @@ int ml_init(uintptr_t arg) init_per_cpu_areas(); struct cpu_data *this_cpu = get_this_cpu(); + memset(this_cpu, 0x0, sizeof *this_cpu); + this_cpu->c_flags = CPU_ONLINE; this_cpu->c_id = this_cpu(); g_bootstrap_cpu.c_data = this_cpu;