From 6cf140f2da14834c8acddcf2d9efdf0e59b0b51d Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Wed, 13 Jan 2021 21:09:40 +0800 Subject: [PATCH] kernel: riscv: don't print valid page faults Some page faults are valid, and shouldn't be printed unless they fail. Signed-off-by: Sean Cross --- kernel/src/arch/riscv/irq.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/src/arch/riscv/irq.rs b/kernel/src/arch/riscv/irq.rs index 70c16c95f..8139f446b 100644 --- a/kernel/src/arch/riscv/irq.rs +++ b/kernel/src/arch/riscv/irq.rs @@ -121,7 +121,7 @@ pub extern "C" fn trap_handler( // it with one if necessary. match ex { RiscvException::StorePageFault(pc, addr) | RiscvException::LoadPageFault(pc, addr) => { - #[cfg(any(feature = "debug-print", feature = "print-panics"))] + #[cfg(all(feature = "debug-print", feature = "print-panics"))] print!( "KERNEL({}): RISC-V fault: {} @ {:08x}, addr {:08x} - ", pid, ex, pc, addr @@ -130,6 +130,11 @@ pub extern "C" fn trap_handler( let entry = crate::arch::mem::pagetable_entry(virt).unwrap_or_else(|x| { // MemoryManagerHandle::get().print_ownership(); MemoryMapping::current().print_map(); + #[cfg(not(any(feature = "debug-print", feature = "print-panics")))] + print!( + "KERNEL({}): RISC-V fault: {} @ {:08x}, addr {:08x} - ", + pid, ex, pc, addr + ); panic!( "error {:?} at {:08x}: memory not mapped or reserved for addr {:08x}", x, pc, addr @@ -164,6 +169,7 @@ pub extern "C" fn trap_handler( flush_mmu(); }; + #[cfg(all(feature = "debug-print", feature = "print-panics"))] println!("Handing page {:08x} to process", new_page); ArchProcess::with_current_mut(|process| { crate::arch::syscall::resume( @@ -171,6 +177,12 @@ pub extern "C" fn trap_handler( process.current_thread(), ) }); + + #[cfg(all(not(feature = "debug-print"), feature = "print-panics"))] + print!( + "KERNEL({}): RISC-V fault: {} @ {:08x}, addr {:08x} - ", + pid, ex, pc, addr + ); } println!("Page was not allocated"); }