diff options
author | Ian Moffett <ian@osmora.org> | 2025-07-13 00:24:08 +0000 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-07-13 00:24:08 +0000 |
commit | a789a2d36560f64952dcfc25d330f1ac04206c14 (patch) | |
tree | 516073a81cf273a4f8d0129e4d4706168abc71d1 /sys/arch | |
parent | 85ddd63bddfa20bedce3a387c69dcf66f882a8ea (diff) |
kernel: Avoid using kprintf() during panic
Avoid using kprintf() during a system panic event as it relies on
internal locking that may hang the system preventing diagnostics from
being logged
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 9b65d6e..af00c5a 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -44,6 +44,8 @@ #include <machine/intr.h> #include <machine/cdefs.h> #include <machine/isa/i8042var.h> +#include <dev/cons/cons.h> +#include <string.h> #define pr_trace(fmt, ...) kprintf("cpu: " fmt, ##__VA_ARGS__) #define pr_error(...) pr_trace(__VA_ARGS__) @@ -224,6 +226,7 @@ md_backtrace(void) uintptr_t rip; off_t off; const char *name; + char line[256]; __ASMV("mov %%rbp, %0" : "=r" (rbp) :: "memory"); while (1) { @@ -236,7 +239,8 @@ md_backtrace(void) if (name == NULL) name = "???"; - kprintf(OMIT_TIMESTAMP "%p @ <%s+0x%x>\n", rip, name, off); + snprintf(line, sizeof(line), "%p @ <%s+0x%x>\n", rip, name, off); + cons_putstr(&g_root_scr, line, strlen(line)); } } |