From patchwork Fri Jul 13 10:16:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9980 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 54F9523E1B for ; Fri, 13 Jul 2012 10:19:13 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 249B7A18238 for ; Fri, 13 Jul 2012 10:19:13 +0000 (UTC) Received: by mail-gg0-f180.google.com with SMTP id f1so3679369ggn.11 for ; Fri, 13 Jul 2012 03:19:13 -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=nhJ4A0lCa4NcX2sAabpzHzViwSGgc92SxnbJEUi6GQVTiSvNCSup0AHndRLXie37DW +w7ZPYH+2YkHfMd2PZAiUcBKeAexbaZvtxI+rLjL4p67rkMM1yauD3u+d4rbgPXyEihD b/s4+3QYiJFSLVUINcJ6SRDKxUE1pLY948Z2W8cvjSIuB9Qz1q6BkFLxOq6uoYL3/Coj pyICDFRGHkB5VZTILeVbVPCZWffO6QT9vBDx5YuArYEnoBrgoQsCFc2aqVP4Yrs+kdWB tfU5cqpvL4+ncI7jMsj7ayuvJHFHAByrVWHx4xQAT+y17ngjv4B0x55zpcn5b80UE1m5 MeFA== Received: by 10.50.46.232 with SMTP id y8mr372510igm.57.1342174752405; Fri, 13 Jul 2012 03:19:12 -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.241.2 with SMTP id lc2csp13692ibb; Fri, 13 Jul 2012 03:19:11 -0700 (PDT) Received: by 10.68.138.166 with SMTP id qr6mr2386524pbb.43.1342174751681; Fri, 13 Jul 2012 03:19:11 -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 pv10si13925349pbb.64.2012.07.13.03.19.11 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Jul 2012 03:19:11 -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 rr4so6369113pbb.37 for ; Fri, 13 Jul 2012 03:19:11 -0700 (PDT) Received: by 10.68.221.10 with SMTP id qa10mr2059041pbc.154.1342174751432; Fri, 13 Jul 2012 03:19:11 -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 pz9sm5747339pbb.61.2012.07.13.03.19.09 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Jul 2012 03:19:10 -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/8] kernel/debug: Mask KGDB NMI upon entry Date: Fri, 13 Jul 2012 03:16:42 -0700 Message-Id: <1342174608-22407-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120713101605.GA16139@lizard> References: <20120713101605.GA16139@lizard> X-Gm-Message-State: ALoCoQnzGPkflczXL202lw2gTbn6/t9u7zbUWj4D0awRvT46bdycMWazYwyHdDrHIiJ84/04Wcd8 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)