Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Dec 2020 22:20:21 +0000 (UTC)
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r368527 - head/sys/riscv/riscv
Message-ID:  <202012102220.0BAMKLrj097091@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012102220.0BAMKLrj097091>