diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-16 20:07:43 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-16 20:19:29 -0400 |
commit | fb4002d54b25ab70d46649a76bf536c67cb92bf4 (patch) | |
tree | 693c650a3af6c21f828b7f3df3876356a749b7a9 /sys/kern | |
parent | 9e83d053812096b795fb8b511c49a65e4ad18a44 (diff) |
kernel: Add cpu_halt_others() and harden panic()
Ensure interrupts are disabled at the start of panic()
to prevent any interrupts from further degrading the
state of the system. Also adds a newline before "panic: "
to clean up the logs.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_panic.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/kern/kern_panic.c b/sys/kern/kern_panic.c index 950ea8f..7660fff 100644 --- a/sys/kern/kern_panic.c +++ b/sys/kern/kern_panic.c @@ -31,6 +31,8 @@ #include <sys/spinlock.h> #include <sys/syslog.h> #include <sys/reboot.h> +#include <machine/cdefs.h> +#include <machine/cpu.h> /* * Burn and sizzle - the core logic that really ends @@ -69,8 +71,12 @@ panic(const char *fmt, ...) { va_list ap; + /* Shut everything else up */ + md_intoff(); + cpu_halt_others(); + va_start(ap, fmt); - kprintf(OMIT_TIMESTAMP "panic: "); + kprintf(OMIT_TIMESTAMP "\npanic: "); vkprintf(fmt, &ap); bas(true, REBOOT_HALT); |