From patchwork Thu Jul 5 23:12:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9873 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3DC9A23E2F for ; Thu, 5 Jul 2012 23:15:08 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id EBCC4A182F4 for ; Thu, 5 Jul 2012 23:15:07 +0000 (UTC) Received: by ghbz12 with SMTP id z12so8668869ghb.11 for ; Thu, 05 Jul 2012 16:15:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=xYn5WSLkhUi7vULu3qtXFy5S5nGW6R6I9R27gYy9YeM=; b=dglXwD7v23ZDz6SRXb9ity33gRmlB1LNHyvYVEEwqfZZEfcrs9OOwAz4hjQyp4x8f/ S/Yz14fQDMSpCsEhQxagkvOb4/cSKtrZBctLT9s3pXT24ENZc/+4XkZH98GD1BZ9RiZG XW2yiE5Qqms875zC60EjeU1UkGkpMIDcZghvsZ7ed3nVU6xI7bwxYS2KKgcF4aYs2GvA TSso37Vw4xtXlJ8S9FyoYDRRu/eTLUEJxTLyvcr8LxpZjfLtpelAeAgyYstxhZfZWpOo vMoicqUPGslWXxe7zz/ol8pLSykcyqMEwGli/Lfq6CE90Fb/iS1S04Yxi2IQ5QJDushi tx5A== Received: by 10.50.195.234 with SMTP id ih10mr1181341igc.0.1341530107124; Thu, 05 Jul 2012 16:15:07 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp1903ibb; Thu, 5 Jul 2012 16:15:06 -0700 (PDT) Received: by 10.66.82.2 with SMTP id e2mr40552093pay.67.1341530106483; Thu, 05 Jul 2012 16:15:06 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id wt7si40242066pbc.172.2012.07.05.16.15.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 16:15:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-pb0-f50.google.com with SMTP id rr4so15920100pbb.37 for ; Thu, 05 Jul 2012 16:15:06 -0700 (PDT) Received: by 10.68.238.232 with SMTP id vn8mr31050342pbc.78.1341530105966; Thu, 05 Jul 2012 16:15:05 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id ny4sm20577400pbb.57.2012.07.05.16.15.04 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 16:15:05 -0700 (PDT) From: Anton Vorontsov To: Russell King , Jason Wessel Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Colin Cross , John Stultz , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com, kgdb-bugreport@lists.sourceforge.net Subject: [PATCH 2/6] kernel/debug: Mask KGDB NMI upon entry Date: Thu, 5 Jul 2012 16:12:36 -0700 Message-Id: <1341529960-18370-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120705231034.GA16931@lizard> References: <20120705231034.GA16931@lizard> X-Gm-Message-State: ALoCoQmsU9MBSFPJxVMycjiZVp0qkBqRKqiU68TNySk8b+m2Vhdm/wpoTu7GowAVJK+Y59enuYFC The new arch callback should manage NMIs that usually cause KGDB to enter. That is, not all NMIs should be enabled/disabled, but only those that issue kgdb_handle_exception(). We must mask it as serial-line interrupt can be used as an NMI, so if the original KGDB-entry cause was say a breakpoint, then every input to KDB console will cause KGDB to reenter, which we don't want. Signed-off-by: Anton Vorontsov --- include/linux/kgdb.h | 9 +++++++++ kernel/debug/debug_core.c | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index c4d2fc1..47e739e 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -221,6 +221,15 @@ extern int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt); */ extern void kgdb_arch_late(void); +/** + * kgdb_arch_enable_nmi - Enable or disable KGDB-entry NMI + * @on: Flag to either enable or disable an NMI + * + * This function manages NMIs that usually cause KGDB to enter. That is, + * not all NMIs should be enabled or disabled, but only those that issue + * kgdb_handle_exception(). + */ +extern void kgdb_arch_enable_nmi(bool on); /** * struct kgdb_arch - Describe architecture specific values. diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 0557f24..e285600 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -214,6 +214,10 @@ int __weak kgdb_skipexception(int exception, struct pt_regs *regs) return 0; } +void __weak kgdb_arch_enable_nmi(bool on) +{ +} + /* * Some architectures need cache flushes when we set/clear a * breakpoint: @@ -672,6 +676,9 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs) { struct kgdb_state kgdb_var; struct kgdb_state *ks = &kgdb_var; + int ret; + + kgdb_arch_enable_nmi(0); ks->cpu = raw_smp_processor_id(); ks->ex_vector = evector; @@ -685,7 +692,10 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs) if (kgdb_info[ks->cpu].enter_kgdb != 0) return 0; - return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER); + ret = kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER); + + kgdb_arch_enable_nmi(1); + return ret; } int kgdb_nmicallback(int cpu, void *regs)