chore: kernel/riscv/trap: panic when trap in kernel mode

This commit is contained in:
Paul Pan 2024-08-23 20:35:46 +08:00
parent 753515700f
commit 917629f16e

View File

@ -18,8 +18,7 @@ extern "C" {
#[no_mangle] #[no_mangle]
extern "C" fn kernel_trap_handler(tf: &mut TrapContext) { extern "C" fn kernel_trap_handler(tf: &mut TrapContext) {
// No trap in kernel, except from IDLE thread // No trap in kernel
// TODO: Replace CONSOLE Mutex to ReentrantLock
unsafe { CONSOLE.force_unlock() } unsafe { CONSOLE.force_unlock() }
tf.handle_trap(true); tf.handle_trap(true);
} }
@ -76,6 +75,10 @@ impl TrapContextOps for TrapContext {
}; };
} }
if from_kernel {
panic_fatal!("Buggy kernel: trap in kernel mode");
}
let tcb = self.as_object_mut(); let tcb = self.as_object_mut();
match scause.cause() { match scause.cause() {