bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH gnumach] i386/apic.c: Pre-initialize the lapic pointer with a dum


From: Damien Zammit
Subject: [PATCH gnumach] i386/apic.c: Pre-initialize the lapic pointer with a dummy structure
Date: Tue, 20 Jun 2023 10:29:38 +0000

Fixes an early crash when APIC is defined, NCPUS > 1 and LINUX_DEV is not 
defined.

CPU_NUMBER can now be called before the local apic pointer is properly
initialized.
---
 i386/i386/apic.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/i386/i386/apic.c b/i386/i386/apic.c
index ff7ba3e2..c399074d 100644
--- a/i386/i386/apic.c
+++ b/i386/i386/apic.c
@@ -27,7 +27,13 @@
 #include <kern/kalloc.h>
 
 
-volatile ApicLocalUnit* lapic = NULL;
+/*
+ * This dummy structure is needed so that CPU_NUMBER can be called
+ * before the lapic pointer is initialized to point to the real Local Apic.
+ * It causes the apic_id to be faked as 0, which is the master processor.
+ */
+static ApicLocalUnit dummy_lapic = {0};
+volatile ApicLocalUnit* lapic = &dummy_lapic;
 
 ApicInfo apic_data;
 
-- 
2.39.0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]