From 7ed5ce81ccd6f7a546ea504d998419452b18fc20 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 20 Aug 2025 23:28:17 -0400 Subject: kernel/amd64: Do not hit self in cpu_halt_others() Previously the logic for cpu_halt_others() would fall back to halting the current processor. However this is not correct and we should instead bail if there are no other processors to halt. Signed-off-by: Ian Moffett --- sys/arch/amd64/amd64/machdep.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 72de150..76c1a5f 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -481,14 +481,13 @@ void cpu_halt_others(void) { struct cpu_info *curcpu, *ci; - uint32_t ncpu; + uint32_t ncpu = cpu_count(); - if (rdmsr(IA32_GS_BASE) == 0) { - __ASMV("cli; hlt"); + if (rdmsr(IA32_GS_BASE) == 0 || ncpu <= 1) { + return; } curcpu = this_cpu(); - ncpu = cpu_count(); for (int i = 0; i < ncpu; ++i) { if ((ci = cpu_get(i)) == NULL) -- cgit v1.2.3