fix: stacks at top of user VA in own 1 MiB band (guard, heap kept below), 8/16 pages default; kernel fault msg names pid, kind, flags stack overflow; flaky OVERFLOW + spawntest/test-qemu check it
This commit is contained in:
@@ -182,17 +182,29 @@ fn handle_exception(frame: &mut TrapFrame, scause: usize) {
|
||||
.is_some_and(|ctx| fp::first_use(frame, ctx)) => {}
|
||||
_ => {
|
||||
let uart = crate::hw::uart::Uart::new();
|
||||
uart.write_str("FAULT: scause=");
|
||||
uart.write_hex(scause);
|
||||
let stval: usize;
|
||||
unsafe { core::arch::asm!("csrr {0}, stval", out(reg) stval) };
|
||||
uart.write_str(" stval=");
|
||||
let kern = kern();
|
||||
uart.write_str("FAULT pid=");
|
||||
let pid = kern.current_thread().and_then(|t| kern.thread_process(t));
|
||||
uart.write_hex(pid.map_or(usize::MAX, |p| p.raw() as usize));
|
||||
uart.write_str(": ");
|
||||
uart.write_str(match scause {
|
||||
2 => "illegal instruction",
|
||||
5 | 13 => "load fault",
|
||||
7 | 15 => "store fault",
|
||||
12 => "instruction fetch fault",
|
||||
_ => "fault",
|
||||
});
|
||||
uart.write_str(" at ");
|
||||
uart.write_hex(stval);
|
||||
uart.write_str(" sepc=");
|
||||
if matches!(scause, 5 | 7 | 13 | 15) && types::layout::is_stack_overflow(stval) {
|
||||
uart.write_str(" (stack overflow: give it more stack)");
|
||||
}
|
||||
uart.write_str(", pc ");
|
||||
uart.write_hex(frame.sepc);
|
||||
uart.put_char(b'\n');
|
||||
|
||||
let kern = kern();
|
||||
if let Some(current_tid) = kern.current_thread() {
|
||||
let fault = match scause {
|
||||
2 => domain::fault::Fault::IllegalInstruction,
|
||||
|
||||
Reference in New Issue
Block a user