From owner-svn-src-head@freebsd.org Thu Nov 1 21:34:20 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B10CB10D94FF; Thu, 1 Nov 2018 21:34:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 613068D2E1; Thu, 1 Nov 2018 21:34:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4220521629; Thu, 1 Nov 2018 21:34:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wA1LYKa6012809; Thu, 1 Nov 2018 21:34:20 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wA1LYIjm012800; Thu, 1 Nov 2018 21:34:18 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201811012134.wA1LYIjm012800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 1 Nov 2018 21:34:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340020 - in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 kern mips/mips powerpc/powerpc sys X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 kern mips/mips powerpc/powerpc sys X-SVN-Commit-Revision: 340020 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2018 21:34:21 -0000 Author: jhb Date: Thu Nov 1 21:34:17 2018 New Revision: 340020 URL: https://svnweb.freebsd.org/changeset/base/340020 Log: 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. Reviewed by: kib, avg MFC after: 2 months Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D17768 Modified: head/sys/amd64/amd64/trap.c head/sys/arm/arm/trap-v4.c head/sys/arm/arm/trap-v6.c head/sys/arm64/arm64/trap.c head/sys/i386/i386/trap.c head/sys/kern/kern_shutdown.c head/sys/mips/mips/trap.c head/sys/powerpc/powerpc/trap.c head/sys/sys/kdb.h Modified: head/sys/amd64/amd64/trap.c ============================================================================== --- head/sys/amd64/amd64/trap.c Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/amd64/amd64/trap.c Thu Nov 1 21:34:17 2018 (r340020) @@ -916,7 +916,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: head/sys/arm/arm/trap-v4.c ============================================================================== --- head/sys/arm/arm/trap-v4.c Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/arm/arm/trap-v4.c Thu Nov 1 21:34:17 2018 (r340020) @@ -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: head/sys/arm/arm/trap-v6.c ============================================================================== --- head/sys/arm/arm/trap-v6.c Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/arm/arm/trap-v6.c Thu Nov 1 21:34:17 2018 (r340020) @@ -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: head/sys/arm64/arm64/trap.c ============================================================================== --- head/sys/arm64/arm64/trap.c Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/arm64/arm64/trap.c Thu Nov 1 21:34:17 2018 (r340020) @@ -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: head/sys/i386/i386/trap.c ============================================================================== --- head/sys/i386/i386/trap.c Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/i386/i386/trap.c Thu Nov 1 21:34:17 2018 (r340020) @@ -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: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/kern/kern_shutdown.c Thu Nov 1 21:34:17 2018 (r340020) @@ -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: head/sys/mips/mips/trap.c ============================================================================== --- head/sys/mips/mips/trap.c Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/mips/mips/trap.c Thu Nov 1 21:34:17 2018 (r340020) @@ -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: head/sys/powerpc/powerpc/trap.c ============================================================================== --- head/sys/powerpc/powerpc/trap.c Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/powerpc/powerpc/trap.c Thu Nov 1 21:34:17 2018 (r340020) @@ -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: head/sys/sys/kdb.h ============================================================================== --- head/sys/sys/kdb.h Thu Nov 1 21:28:22 2018 (r340019) +++ head/sys/sys/kdb.h Thu Nov 1 21:34:17 2018 (r340020) @@ -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. */