svn commit: r368527 - head/sys/riscv/riscv

Mitchell Horne mhorne at FreeBSD.org
Thu Dec 10 22:20:21 UTC 2020


Author: mhorne
Date: Thu Dec 10 22:20:20 2020
New Revision: 368527
URL: https://svnweb.freebsd.org/changeset/base/368527

Log:
  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

Modified:
  head/sys/riscv/riscv/trap.c

Modified: head/sys/riscv/riscv/trap.c
==============================================================================
--- head/sys/riscv/riscv/trap.c	Thu Dec 10 21:12:25 2020	(r368526)
+++ head/sys/riscv/riscv/trap.c	Thu Dec 10 22:20:20 2020	(r368527)
@@ -179,6 +179,9 @@ page_fault_handler(struct trapframe *frame, int usermo
 	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);
 }
 


More information about the svn-src-head mailing list