Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3151364imu; Sun, 9 Dec 2018 18:43:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/WHVeddn+l+c+CiNBwLkozdWljpCi2TMsiA9PudSylWfRuy2GeUtVqfvtmuSHMl5zaSlRcG X-Received: by 2002:a62:6408:: with SMTP id y8mr10690997pfb.202.1544409792766; Sun, 09 Dec 2018 18:43:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544409792; cv=none; d=google.com; s=arc-20160816; b=tA4imPw+M1olg/HfRO47iA8X3WOvtJO3xrTz2G/HiDlMrIfEYtL+X8MhrVtkwGjZ3g caNfBOLf1xCDzFqomvf1E08P8kBi2vLUGBUA2YwrBQP5QhkUNlA5OK1vzcXb8Q3e0Ld6 rV3GTV2GGA7ZnNl9rMA1D7c7wGodLIkmOVMMg8CLA3Ir17hxyIc5CT8lnenjK0P18dm+ jZp52QwSvEo9CNxf0Iq0mtgxkSF5hyHmPQnUnVnpIOYXYhiqo/8Tc8/wrCyY92Kz13Xr 5K3sufFO6uJXCp9P8mU/i+Y9f09v5I8v2eyv14KFmDaC/D53L4qbHs/PwK4IlUUbEowD TOOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2I3FgBsmgwiN9LGZSFfLY9YBknYQAXhTGYoZTcvMOeY=; b=hxNx8OApqArYiqTlPd+HBzhtcre68bGH4eXiXGJGn9Ds5GNSOuqXik20i8gxw2ejNr imr6hm+EimCVSUKFVUBV3NTjO8qP626K8/9FGo5J4U+U+vuvQpV4qqXXESFNszH7Rid6 aJr3vmVDnMrcBzOvDzgw0iT54iEVe5DPGFpHsntjoTXHvBBD6o3FLU/NgaC0etoC5rOL t0XlceaKo03kHHbElZ42iimEf+jgaHUkqy991Is+6DZLlTxtDdQDROydSu/A9HVYX2ow f7utrPKJSm0ajeY2LDoQrSyJE2mLdjTPJ2XVOTo0bq7VPW5er7P6cuxpb2kGkr2qmP5T syTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OvxtBFTx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s59si9044477plb.237.2018.12.09.18.42.26; Sun, 09 Dec 2018 18:43:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OvxtBFTx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726363AbeLJChX (ORCPT + 99 others); Sun, 9 Dec 2018 21:37:23 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43191 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbeLJChW (ORCPT ); Sun, 9 Dec 2018 21:37:22 -0500 Received: by mail-pg1-f194.google.com with SMTP id v28so4244794pgk.10 for ; Sun, 09 Dec 2018 18:37:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2I3FgBsmgwiN9LGZSFfLY9YBknYQAXhTGYoZTcvMOeY=; b=OvxtBFTxwTPsjINYGxGsZHKHM9cnzDHKUz+TbNJUWl89598FhUfFxtq0++JmogoZGA 32kxneoeJOeWhUG8WPKg2omtlYUDP9yYQumWml+zSlo0eZ7kQtiPflL4Tg6yFBuVSu+h 2zx4wj/1jEZZKFT8DC6jBluowQ0JNrc2tAsOc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2I3FgBsmgwiN9LGZSFfLY9YBknYQAXhTGYoZTcvMOeY=; b=Cvo82hU4QAfY3qQAMOysrY9BLsL6xKiKa+Igp1duFG8VPidzudUvzFSNxDAWhtkk4O UQYhg1UnGNZK6CRzX7uMicjAQD2Y7HT+JwsZCjL7k1kN6B2YZXyGjFzgkklRYGGEXsfW bl73Bhzba0FBQRAVrhuPou/C/MccH6H5ns23JarHz+n8Y3Pa+Sv1Wv0UhtTSmm0eYaBO numApcxtRgBB+S4Hn3mGvOFU+rzcOFi8cjcsGfHfNMYj3AmyNkm6lbh1DdiJjIJO6tds Tyh6HP7+SVjEoSo+3GS+gPrp8Ib1rFYpZ06amxJv4IkhHjIH/TCrYbUmhr0hB9whyZlO d8yQ== X-Gm-Message-State: AA+aEWasE5E0U8ZBXXxrrL8lZ1tHDb+8eJkXSrR8YlGwtS5Bf6TNJ16z +iXVpJeN9pnKy/wXU8lggLe4WleEqBo= X-Received: by 2002:a63:e80e:: with SMTP id s14mr9395032pgh.30.1544409441635; Sun, 09 Dec 2018 18:37:21 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:c8e0:70d7:4be7:a36]) by smtp.gmail.com with ESMTPSA id 84sm18400660pfk.134.2018.12.09.18.37.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Dec 2018 18:37:20 -0800 (PST) From: Douglas Anderson To: Jason Wessel , Daniel Thompson Cc: briannorris@chromium.org, Douglas Anderson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] debug: Allow forcing entering debug mode on panic/exception Date: Sun, 9 Dec 2018 18:36:49 -0800 Message-Id: <20181210023649.229271-1-dianders@chromium.org> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ever since commit 5516fd7b92a7 ("debug: prevent entering debug mode on panic/exception.") (yes, years ago) my kgdb workflow has been broken. On Chrome OS we have 'kernel.panic = -1' in '/etc/sysctl.d/00-sysctl.conf'. That means that when userspace starts up it will tell the kernel "please reboot on panic". ...and so when I get a panic then the system reboots instead of letting me debug it. While I could go in an change the 'sysctl.conf' and I could go in and hack the kernel myself, these things are inconvenient. I either need to keep a private kernel patch or or remember to edit a file every time I install an updated version of Chrome OS. What is convenient (for me) is to have a CONFIG option that makes kgdb override the panic request. This is because the Chrome OS build system makes it very easy for me to add some extra CONFIG "fragments" to my debug kernels. Hopefully having this extra config option is OK and useful to others who would also prefer to make sure that kgdb is always entered on a panic no matter what userspace might request. Signed-off-by: Douglas Anderson --- kernel/debug/debug_core.c | 5 +++-- lib/Kconfig.kgdb | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 65c0f1363788..d4a38543fcdd 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -703,7 +703,8 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs) * reboot on panic. We don't want to get stuck waiting for input * on such systems, especially if its "just" an oops. */ - if (signo != SIGTRAP && panic_timeout) + if (!IS_ENABLED(CONFIG_KGDB_ALWAYS_ENTER_ON_PANIC) && + signo != SIGTRAP && panic_timeout) return 1; memset(ks, 0, sizeof(struct kgdb_state)); @@ -843,7 +844,7 @@ static int kgdb_panic_event(struct notifier_block *self, * panic_timeout indicates the system should automatically * reboot on panic. */ - if (panic_timeout) + if (!IS_ENABLED(CONFIG_KGDB_ALWAYS_ENTER_ON_PANIC) && panic_timeout) return NOTIFY_DONE; if (dbg_kdb_mode) diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb index ab4ff0eea776..f12c6e1394c6 100644 --- a/lib/Kconfig.kgdb +++ b/lib/Kconfig.kgdb @@ -67,6 +67,16 @@ config KGDB_LOW_LEVEL_TRAP exception handler which will allow kgdb to step through a notify handler. +config KGDB_ALWAYS_ENTER_ON_PANIC + bool "KGDB: Enter kgdb on panic even if reboot specified" + default n + help + If kgdb is enabled and the system is configured to reboot on + panic then there's a question of whether we should drop into + kgdb on panic or whether we should reboot on panic. If you + say yes here then we'll enter kgdb. If you say no here then + we'll reboot. + config KGDB_KDB bool "KGDB_KDB: include kdb frontend for kgdb" default n -- 2.20.0.rc2.403.gdbc3b29805-goog