aboutsummaryrefslogtreecommitdiff
path: root/sys/riscv/riscv
diff options
context:
space:
mode:
authorMitchell Horne <mhorne@FreeBSD.org>2020-12-10 22:20:20 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2020-12-10 22:20:20 +0000
commit5a28499f2ff58dbdc2666c8791ca82cddc6ec4e0 (patch)
tree3cf366292c04710c3b693f4bbd29cfd7dd3ac9a7 /sys/riscv/riscv
parent78adacd4eab39a3508bd8c65f0aba94fc6b907ce (diff)
downloadsrc-5a28499f2ff58dbdc2666c8791ca82cddc6ec4e0.tar.gz
src-5a28499f2ff58dbdc2666c8791ca82cddc6ec4e0.zip
riscv: handle debug.debugger_on_trap for fatal page faults
Allows recovery or diagnosis of a fatal page fault before panicking the system. Reviewed by: jhb, kp Differential Revision: https://reviews.freebsd.org/D27534
Notes
Notes: svn path=/head/; revision=368527
Diffstat (limited to 'sys/riscv/riscv')
-rw-r--r--sys/riscv/riscv/trap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c
index 6ba82980bc17..599fd64b56be 100644
--- a/sys/riscv/riscv/trap.c
+++ b/sys/riscv/riscv/trap.c
@@ -179,6 +179,9 @@ page_fault_handler(struct trapframe *frame, int usermode)
vm_offset_t va;
struct proc *p;
int error, sig, ucode;
+#ifdef KDB
+ bool handled;
+#endif
#ifdef KDB
if (kdb_active) {
@@ -250,6 +253,15 @@ done:
fatal:
dump_regs(frame);
+#ifdef KDB
+ if (debugger_on_trap) {
+ kdb_why = KDB_WHY_TRAP;
+ handled = kdb_trap(frame->tf_scause & SCAUSE_CODE, 0, frame);
+ kdb_why = KDB_WHY_UNSET;
+ if (handled)
+ return;
+ }
+#endif
panic("Fatal page fault at %#lx: %#016lx", frame->tf_sepc, stval);
}