From owner-svn-src-head@freebsd.org Thu Nov 19 18:03:41 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A947047132D; Thu, 19 Nov 2020 18:03:41 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcSGj4JDZz3D4d; Thu, 19 Nov 2020 18:03:41 +0000 (UTC) (envelope-from mhorne@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 853B916A; Thu, 19 Nov 2020 18:03:41 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJI3fDV039668; Thu, 19 Nov 2020 18:03:41 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJI3fS7039667; Thu, 19 Nov 2020 18:03:41 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011191803.0AJI3fS7039667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Thu, 19 Nov 2020 18:03:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367848 - in head: share/man/man4 sys/kern X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: in head: share/man/man4 sys/kern X-SVN-Commit-Revision: 367848 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.34 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, 19 Nov 2020 18:03:41 -0000 Author: mhorne Date: Thu Nov 19 18:03:40 2020 New Revision: 367848 URL: https://svnweb.freebsd.org/changeset/base/367848 Log: Add an option for entering KDB on recursive panics There are many cases where one would choose avoid entering the debugger on a normal panic, opting instead to reboot and possibly save a kernel dump. However, recursive kernel panics are an unusual case that might warrant attention from a human, so provide a secondary tunable, debug.debugger_on_recursive_panic, to allow entering the debugger only when this occurs. For for simplicity in maintaining existing behaviour, the tunable defaults to zero. Reviewed by: cem, markj Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D27271 Modified: head/share/man/man4/ddb.4 head/sys/kern/kern_shutdown.c Modified: head/share/man/man4/ddb.4 ============================================================================== --- head/share/man/man4/ddb.4 Thu Nov 19 17:54:41 2020 (r367847) +++ head/share/man/man4/ddb.4 Thu Nov 19 18:03:40 2020 (r367848) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 17, 2019 +.Dd November 19, 2020 .Dt DDB 4 .Os .Sh NAME @@ -87,6 +87,16 @@ which is the default unless the .Dv KDB_UNATTENDED option is specified. +Similarly, if the +.Va debug.debugger_on_recursive_panic +variable is set to +.Dv 1 , +then the debugger will be invoked on a recursive kernel panic. +This variable has a default value of +.Dv 0 , +and has no effect if +.Va debug.debugger_on_panic +is already set non-zero. .Pp The current location is called .Va dot . Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Thu Nov 19 17:54:41 2020 (r367847) +++ head/sys/kern/kern_shutdown.c Thu Nov 19 18:03:40 2020 (r367848) @@ -127,6 +127,11 @@ SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RWTUN | CTLFLAG_SECURE, &debugger_on_panic, 0, "Run debugger on kernel panic"); +static bool debugger_on_recursive_panic = false; +SYSCTL_BOOL(_debug, OID_AUTO, debugger_on_recursive_panic, + CTLFLAG_RWTUN | CTLFLAG_SECURE, + &debugger_on_recursive_panic, 0, "Run debugger on recursive kernel panic"); + int debugger_on_trap = 0; SYSCTL_INT(_debug, OID_AUTO, debugger_on_trap, CTLFLAG_RWTUN | CTLFLAG_SECURE, @@ -899,6 +904,8 @@ vpanic(const char *fmt, va_list ap) kdb_backtrace(); if (debugger_on_panic) kdb_enter(KDB_WHY_PANIC, "panic"); + else if (!newpanic && debugger_on_recursive_panic) + kdb_enter(KDB_WHY_PANIC, "re-panic"); #endif /*thread_lock(td); */ td->td_flags |= TDF_INPANIC;