From patchwork Tue Nov 18 12:08:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiran Kumar Raparthy X-Patchwork-Id: 41013 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6959E241C9 for ; Tue, 18 Nov 2014 12:09:40 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf2159950wiv.5 for ; Tue, 18 Nov 2014 04:09:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=5VDJ9bhO6yg9ITFAMThVd+6s+S+xGt9BF7xtJBsWVuM=; b=AwUO+N3tBiWNCMNO00YSs+uqaPH9uGmFk9eHvLCfnbYV+QnQcpvsI1dJ/9aKKGbDUT epYO8P1ma8GLyeoRKPOUtgOh+DJ9KV+9j1efCboSKMtZYelHj3EoNmpJZWag2e0fxzCm YfkaMrxRiwilk7q/cND8iS9tL/23oiTzQkFmXl/AGhaER/FidP3pTzpKUfJElshwV6yw 8oY/93E1UPHW3JDftrBCNeGXWmzBv2ZdQAqOtx62PK8UzjpMGurnU+whyevwJ4JuW7HN esz3A0O39IgYfTRlg/iaUFOmTQZAnGFdQwSCnin8jG6wpHIAKJE5DF+EAVicvaU0Zv+2 hNeQ== X-Gm-Message-State: ALoCoQkMojcE0XwQZTxjc1SBlnDCZJqep/QzjZUI8liUJF1NUY2YEDVv9xE8eKKEDqiZ5yFzf4dM X-Received: by 10.112.166.102 with SMTP id zf6mr354946lbb.12.1416312579717; Tue, 18 Nov 2014 04:09:39 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.1 with SMTP id bc1ls766438lab.24.gmail; Tue, 18 Nov 2014 04:09:39 -0800 (PST) X-Received: by 10.112.184.70 with SMTP id es6mr18121382lbc.85.1416312579521; Tue, 18 Nov 2014 04:09:39 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id xt9si52871007lbb.11.2014.11.18.04.09.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Nov 2014 04:09:39 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so162954lab.20 for ; Tue, 18 Nov 2014 04:09:39 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr35190897lbc.66.1416312579412; Tue, 18 Nov 2014 04:09:39 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp1316391lbc; Tue, 18 Nov 2014 04:09:38 -0800 (PST) X-Received: by 10.70.89.165 with SMTP id bp5mr10455087pdb.144.1416312576702; Tue, 18 Nov 2014 04:09:36 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12si11447658pdi.189.2014.11.18.04.09.35 for ; Tue, 18 Nov 2014 04:09:36 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754089AbaKRMJd (ORCPT + 26 others); Tue, 18 Nov 2014 07:09:33 -0500 Received: from mail-pd0-f176.google.com ([209.85.192.176]:39822 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753791AbaKRMJc (ORCPT ); Tue, 18 Nov 2014 07:09:32 -0500 Received: by mail-pd0-f176.google.com with SMTP id y10so3930759pdj.21 for ; Tue, 18 Nov 2014 04:09:31 -0800 (PST) X-Received: by 10.68.201.226 with SMTP id kd2mr35975656pbc.75.1416312571568; Tue, 18 Nov 2014 04:09:31 -0800 (PST) Received: from c-krapar-linux.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id pc10sm37772675pbb.21.2014.11.18.04.09.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 18 Nov 2014 04:09:30 -0800 (PST) From: Kiran Kumar Raparthy To: linux-kernel@vger.kernel.org Cc: Colin Cross , Jason Wessel , kgdb-bugreport@lists.sourceforge.net, Android Kernel Team , John Stultz , Sumit Semwal , Kiran Raparthy Subject: [RFC] debug: add parameters to prevent entering debug mode on errors Date: Tue, 18 Nov 2014 17:38:36 +0530 Message-Id: <1416312516-4551-1-git-send-email-kiran.kumar@linaro.org> X-Mailer: git-send-email 1.8.2.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kiran.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Colin Cross debug: add parameters to prevent entering debug mode on errors On non-developer devices kgdb prevents CONFIG_PANIC_TIMEOUT from rebooting the device after a panic. Add module parameters debug_core.break_on_exception and debug_core.break_on_panic to allow skipping debug on panics and exceptions respectively. Both default to true to preserve existing behavior. Cc: Jason Wessel Cc: kgdb-bugreport@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Cc: Android Kernel Team Cc: John Stultz Cc: Sumit Semwal Signed-off-by: Colin Cross [Kiran: Added context to commit message] Signed-off-by: Kiran Raparthy --- This is one of the number of patches from the Android AOSP common.git tree, which is used on almost all Android devices. I wanted to submit it for review to see if it should go upstream. kernel/debug/debug_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 1adf62b..af06122 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -87,6 +87,10 @@ static int kgdb_use_con; bool dbg_is_early = true; /* Next cpu to become the master debug core */ int dbg_switch_cpu; +/* Flag for entering kdb when a panic occurs */ +static bool break_on_panic = true; +/* Flag for entering kdb when an exception occurs */ +static bool break_on_exception = true; /* Use kdb or gdbserver mode */ int dbg_kdb_mode = 1; @@ -101,6 +105,8 @@ early_param("kgdbcon", opt_kgdb_con); module_param(kgdb_use_con, int, 0644); module_param(kgdbreboot, int, 0644); +module_param(break_on_panic, bool, 0644); +module_param(break_on_exception, bool, 0644); /* * Holds information about breakpoints in a kernel. These breakpoints are @@ -690,6 +696,9 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs) if (arch_kgdb_ops.enable_nmi) arch_kgdb_ops.enable_nmi(0); + if (unlikely(signo != SIGTRAP && !break_on_exception)) + return 1; + memset(ks, 0, sizeof(struct kgdb_state)); ks->cpu = raw_smp_processor_id(); ks->ex_vector = evector; @@ -821,6 +830,9 @@ static int kgdb_panic_event(struct notifier_block *self, unsigned long val, void *data) { + if (!break_on_panic) + return NOTIFY_DONE; + if (dbg_kdb_mode) kdb_printf("PANIC: %s\n", (char *)data); kgdb_breakpoint();