From a789a2d36560f64952dcfc25d330f1ac04206c14 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 13 Jul 2025 00:24:08 +0000 Subject: 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 --- sys/arch/amd64/amd64/machdep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sys/arch') 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 #include #include +#include +#include #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)); } } -- cgit v1.2.3