From e6f471fb01a3f49660840ed9801fd30057c3f2ec Mon Sep 17 00:00:00 2001
From: sigsegv7 <ian@vegaa.systems>
Date: Wed, 4 Oct 2023 19:28:31 -0400
Subject: kernel/amd64: Add spinlock to cpu_info

Signed-off-by: sigsegv7 <ian@vegaa.systems>
---
 sys/arch/amd64/lapic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'sys/arch/amd64')

diff --git a/sys/arch/amd64/lapic.c b/sys/arch/amd64/lapic.c
index 53a4fd5..76b0f87 100644
--- a/sys/arch/amd64/lapic.c
+++ b/sys/arch/amd64/lapic.c
@@ -249,10 +249,11 @@ lapic_init(void)
     /* Register the timer for scheduler usage */
     register_timer(TIMER_SCHED, &lapic_timer);
 
-    /* Get the current processor, and calibrate LAPIC timer */
+    /* Get the current processor, and lock its structure */
     cur_cpu = this_cpu();
     CPU_INFO_LOCK(cur_cpu);
 
+    /* Calibrate timer */
     lapic_timer_init(&tmr_freq);
     cur_cpu->lapic_tmr_freq = tmr_freq;
 
@@ -260,5 +261,6 @@ lapic_init(void)
     cur_cpu->lapic_id = lapic_get_id();
 
     BSP_KINFO("BSP Local APIC ID: %d\n", cur_cpu->lapic_id);
+    CPU_INFO_UNLOCK(cur_cpu);
 
 }
-- 
cgit v1.2.3