From e0ea82ad2ffd856da1c351a5ea7f4afd6d103d0e Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 14 May 2024 19:12:43 -0400 Subject: kernel/amd64: Fix early panic triple fault Check for a valid CPU structure and ensure the Local APIC base address has been set before trying to broadcast IPIs Signed-off-by: Ian Moffett --- sys/arch/amd64/amd64/machdep.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 93bf664..a075532 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -253,7 +253,19 @@ machine_panic(void) void cpu_halt_others(void) { - lapic_send_ipi(0, IPI_SHORTHAND_OTHERS, SYSVEC_HLT); + struct cpu_info *ci = this_cpu(); + + /* Is the current CPU structure even valid? */ + if (ci == NULL) + return; + + /* + * If the Local APIC base address is NULL, we can't + * use lapic_send_ipi() but we we can assume the APs + * are still parked. + */ + if (ci->lapic_base != NULL) + lapic_send_ipi(0, IPI_SHORTHAND_OTHERS, SYSVEC_HLT); } int -- cgit v1.2.3