feat(ke/panic): add panic lock

This commit is contained in:
Loïc Grégoire
2026-05-02 12:14:45 -04:00
parent 07cc976467
commit c82f9759b4
2 changed files with 7 additions and 1 deletions
+6 -1
View File
@@ -70,14 +70,18 @@ fn walk_stack_frame(base: usize) void {
}
}
pub var panic_lock: ke.SpinLock = .init();
pub fn panic_with_frame(
msg: []const u8,
frame: usize,
) noreturn {
std.log.err("KERNEL PANIC: {s}", .{msg});
std.log.err("KERNEL PANIC: {s} on CPU {}, curthread is {*}", .{ msg, ke.cpu.current(), ki.sched.percpu.local().current_thread.? });
std.log.err("Stack trace:", .{});
walk_stack_frame(frame);
panic_lock.release_no_ipl();
while (true) {}
}
@@ -88,5 +92,6 @@ pub fn panic(
if (config.arch == .um) {
std.debug.defaultPanic(msg, first_trace_addr);
}
panic_lock.acquire_no_ipl();
panic_with_frame(msg, @frameAddress());
}