Date: Fri, 8 Mar 2019 00:20:37 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344905 - in stable: 11/sys/amd64/amd64 11/sys/arm/arm 11/sys/arm64/arm64 11/sys/i386/i386 11/sys/kern 11/sys/mips/mips 11/sys/powerpc/powerpc 11/sys/sys 12/sys/amd64/amd64 12/sys/arm/a... Message-ID: <201903080020.x280KbkJ070892@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Fri Mar 8 00:20:37 2019 New Revision: 344905 URL: https://svnweb.freebsd.org/changeset/base/344905 Log: MFC 340020: Don't enter DDB for fatal traps before panic by default. Add a new 'debugger_on_trap' knob separate from 'debugger_on_panic' and make the calls to kdb_trap() in MD fatal trap handlers prior to calling panic() conditional on this new knob instead of 'debugger_on_panic'. Disable the new knob by default. Developers who wish to recover from a fatal fault by adjusting saved register state and retrying the faulting instruction can still do so by enabling the new knob. However, for the more common case this makes the user experience for panics due to a fatal fault match the user experience for other panics, e.g. 'c' in DDB will generate a crash dump and reboot the system rather than being stuck in an infinite loop of fatal fault messages and DDB prompts. Modified: stable/12/sys/amd64/amd64/trap.c stable/12/sys/arm/arm/trap-v4.c stable/12/sys/arm/arm/trap-v6.c stable/12/sys/arm64/arm64/trap.c stable/12/sys/i386/i386/trap.c stable/12/sys/kern/kern_shutdown.c stable/12/sys/mips/mips/trap.c stable/12/sys/powerpc/powerpc/trap.c stable/12/sys/sys/kdb.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/amd64/amd64/trap.c stable/11/sys/arm/arm/trap-v4.c stable/11/sys/arm/arm/trap-v6.c stable/11/sys/arm64/arm64/trap.c stable/11/sys/i386/i386/trap.c stable/11/sys/kern/kern_shutdown.c stable/11/sys/mips/mips/trap.c stable/11/sys/powerpc/powerpc/trap.c stable/11/sys/sys/kdb.h Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/amd64/amd64/trap.c ============================================================================== --- stable/12/sys/amd64/amd64/trap.c Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/amd64/amd64/trap.c Fri Mar 8 00:20:37 2019 (r344905) @@ -933,7 +933,7 @@ trap_fatal(frame, eva) curproc->p_pid, curthread->td_name); #ifdef KDB - if (debugger_on_panic) { + if (debugger_on_trap) { kdb_why = KDB_WHY_TRAP; handled = kdb_trap(type, 0, frame); kdb_why = KDB_WHY_UNSET; Modified: stable/12/sys/arm/arm/trap-v4.c ============================================================================== --- stable/12/sys/arm/arm/trap-v4.c Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/arm/arm/trap-v4.c Fri Mar 8 00:20:37 2019 (r344905) @@ -456,7 +456,7 @@ dab_fatal(struct trapframe *tf, u_int fsr, u_int far, printf(", pc =%08x\n\n", tf->tf_pc); #ifdef KDB - if (debugger_on_panic) { + if (debugger_on_trap) { kdb_why = KDB_WHY_TRAP; handled = kdb_trap(fsr, 0, tf); kdb_why = KDB_WHY_UNSET; Modified: stable/12/sys/arm/arm/trap-v6.c ============================================================================== --- stable/12/sys/arm/arm/trap-v6.c Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/arm/arm/trap-v6.c Fri Mar 8 00:20:37 2019 (r344905) @@ -599,7 +599,7 @@ abort_fatal(struct trapframe *tf, u_int idx, u_int fsr printf(", pc =%08x\n\n", tf->tf_pc); #ifdef KDB - if (debugger_on_panic) { + if (debugger_on_trap) { kdb_why = KDB_WHY_TRAP; kdb_trap(fsr, 0, tf); kdb_why = KDB_WHY_UNSET; Modified: stable/12/sys/arm64/arm64/trap.c ============================================================================== --- stable/12/sys/arm64/arm64/trap.c Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/arm64/arm64/trap.c Fri Mar 8 00:20:37 2019 (r344905) @@ -256,7 +256,7 @@ no_pmap_fault: printf(" esr: %.8lx\n", esr); #ifdef KDB - if (debugger_on_panic) { + if (debugger_on_trap) { kdb_why = KDB_WHY_TRAP; handled = kdb_trap(ESR_ELx_EXCEPTION(esr), 0, frame); Modified: stable/12/sys/i386/i386/trap.c ============================================================================== --- stable/12/sys/i386/i386/trap.c Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/i386/i386/trap.c Fri Mar 8 00:20:37 2019 (r344905) @@ -977,7 +977,7 @@ trap_fatal(frame, eva) curproc->p_pid, curthread->td_name); #ifdef KDB - if (debugger_on_panic) { + if (debugger_on_trap) { kdb_why = KDB_WHY_TRAP; frame->tf_err = eva; /* smuggle fault address to ddb */ handled = kdb_trap(type, 0, frame); Modified: stable/12/sys/kern/kern_shutdown.c ============================================================================== --- stable/12/sys/kern/kern_shutdown.c Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/kern/kern_shutdown.c Fri Mar 8 00:20:37 2019 (r344905) @@ -115,13 +115,18 @@ SYSCTL_INT(_kern, OID_AUTO, panic_reboot_wait_time, CT #ifdef KDB #ifdef KDB_UNATTENDED -int debugger_on_panic = 0; +static int debugger_on_panic = 0; #else -int debugger_on_panic = 1; +static int debugger_on_panic = 1; #endif SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RWTUN | CTLFLAG_SECURE, &debugger_on_panic, 0, "Run debugger on kernel panic"); + +int debugger_on_trap = 0; +SYSCTL_INT(_debug, OID_AUTO, debugger_on_trap, + CTLFLAG_RWTUN | CTLFLAG_SECURE, + &debugger_on_trap, 0, "Run debugger on kernel trap before panic"); #ifdef KDB_TRACE static int trace_on_panic = 1; Modified: stable/12/sys/mips/mips/trap.c ============================================================================== --- stable/12/sys/mips/mips/trap.c Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/mips/mips/trap.c Fri Mar 8 00:20:37 2019 (r344905) @@ -1100,7 +1100,7 @@ err: #endif #ifdef KDB - if (debugger_on_panic) { + if (debugger_on_trap) { kdb_why = KDB_WHY_TRAP; kdb_trap(type, 0, trapframe); kdb_why = KDB_WHY_UNSET; Modified: stable/12/sys/powerpc/powerpc/trap.c ============================================================================== --- stable/12/sys/powerpc/powerpc/trap.c Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/powerpc/powerpc/trap.c Fri Mar 8 00:20:37 2019 (r344905) @@ -455,7 +455,7 @@ trap_fatal(struct trapframe *frame) printtrap(frame->exc, frame, 1, (frame->srr1 & PSL_PR)); #ifdef KDB - if (debugger_on_panic) { + if (debugger_on_trap) { kdb_why = KDB_WHY_TRAP; handled = kdb_trap(frame->exc, 0, frame); kdb_why = KDB_WHY_UNSET; Modified: stable/12/sys/sys/kdb.h ============================================================================== --- stable/12/sys/sys/kdb.h Thu Mar 7 23:03:39 2019 (r344904) +++ stable/12/sys/sys/kdb.h Fri Mar 8 00:20:37 2019 (r344905) @@ -62,7 +62,7 @@ struct kdb_dbbe { DATA_SET(kdb_dbbe_set, name##_dbbe) extern u_char kdb_active; /* Non-zero while in debugger. */ -extern int debugger_on_panic; /* enter the debugger on panic. */ +extern int debugger_on_trap; /* enter the debugger on trap. */ extern struct kdb_dbbe *kdb_dbbe; /* Default debugger backend or NULL. */ extern struct trapframe *kdb_frame; /* Frame to kdb_trap(). */ extern struct pcb *kdb_thrctx; /* Current context. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903080020.x280KbkJ070892>