From e06018ee71ab361914f6b160364848a9965e6e75 Mon Sep 17 00:00:00 2001 From: Matheus Date: Wed, 10 Jul 2024 19:45:41 -0300 Subject: [PATCH] smp: zero new processors cpu structs on allocation --- kernel-src/arch/x86-64/smp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel-src/arch/x86-64/smp.c b/kernel-src/arch/x86-64/smp.c index ca080977..ccefa7f2 100644 --- a/kernel-src/arch/x86-64/smp.c +++ b/kernel-src/arch/x86-64/smp.c @@ -59,9 +59,11 @@ void arch_smp_wakeup() { printf("smp: %d processor%s\n", response->cpu_count, response->cpu_count > 1 ? "s" : ""); // use physical pages so the other cpus have it on the hhdm - cpu_t *apcpu = pmm_alloc(ROUND_UP(sizeof(cpu_t) * response->cpu_count, PAGE_SIZE) / PAGE_SIZE, PMM_SECTION_DEFAULT); + size_t apcpusize = ROUND_UP(sizeof(cpu_t) * response->cpu_count, PAGE_SIZE); + cpu_t *apcpu = pmm_alloc(apcpusize / PAGE_SIZE, PMM_SECTION_DEFAULT); __assert(apcpu); apcpu = MAKE_HHDM(apcpu); + memset(apcpu, 0, apcpusize); void (*wakeupfn)(struct limine_smp_info *) = cmdline_get("nosmp") ? cpuwakeuphalt : cpuwakeup;