From patchwork Mon Sep 24 21:27:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11684 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 42DFC23E41 for ; Mon, 24 Sep 2012 21:31:17 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id DA314A18299 for ; Mon, 24 Sep 2012 21:31:16 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so11249367iej.11 for ; Mon, 24 Sep 2012 14:31:16 -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=V15wsU/+E0PyoQGiwQLWWdt7fhO2WxLfLGNcxh5UkOg=; b=OMhEa/P8WBFCrtAAE1fw4kgNtVuB4HPX0IVHq91WF3ugNC9NbCO/v710M+3KdCmXrd uvx1ndKO1BCYnIz58gMiyrpzXXRXcUPeWUtvUuyda2Q19YeGI8vygYpTmalfxeWE7cmK 3BbPBB67NiwwOYy+8CNyngp2/K4jatVtafQJMLt6hTyyLl8rLRIvf83LDEEdo1ZGraZg gA8O9tWnP68ESMWHfWzDmje2jgG2BV2ZlOl/+6xCs9wE7rw1jZfPdrAccxoPaSYvzvvY EiNCvKp/lN8Sie3vPcbLAas5u31fzw2Rq1akqBDKVB4cA75htYnwU71OnnKQ5ve004Ya ucNQ== Received: by 10.50.0.193 with SMTP id 1mr6526300igg.0.1348522276587; Mon, 24 Sep 2012 14:31:16 -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.50.184.232 with SMTP id ex8csp263579igc; Mon, 24 Sep 2012 14:31:16 -0700 (PDT) Received: by 10.66.85.4 with SMTP id d4mr35634213paz.11.1348522275384; Mon, 24 Sep 2012 14:31:15 -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 ts2si20850902pbc.86.2012.09.24.14.31.15 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 14:31:15 -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 pbcmd12 with SMTP id md12so13997645pbc.37 for ; Mon, 24 Sep 2012 14:31:15 -0700 (PDT) Received: by 10.66.77.7 with SMTP id o7mr35641577paw.37.1348522274940; Mon, 24 Sep 2012 14:31:14 -0700 (PDT) Received: from localhost (ip-64-134-232-154.public.wayport.net. [64.134.232.154]) by mx.google.com with ESMTPS id jw14sm8925603pbb.36.2012.09.24.14.30.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 14:31:14 -0700 (PDT) From: Anton Vorontsov To: Greg Kroah-Hartman , Russell King Cc: Alan Cox , Jason Wessel , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Colin Cross , Brian Swetland , 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, linux-serial@vger.kernel.org Subject: [PATCH 01/11] kernel/debug: Mask KGDB NMI upon entry Date: Mon, 24 Sep 2012 14:27:50 -0700 Message-Id: <1348522080-32629-1-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.12 In-Reply-To: <20120924212648.GA27605@lizard> References: <20120924212648.GA27605@lizard> X-Gm-Message-State: ALoCoQletCiVNareUXwa/iSJzD5MNqOoCRQwCK8Hv/tiKcx9PTqmOLdxe5sqj9MtXMsYPQ22P+FC 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 Acked-by: Jason Wessel --- include/linux/kgdb.h | 3 +++ kernel/debug/debug_core.c | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index c4d2fc1..7800cce 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -240,6 +240,7 @@ extern void kgdb_arch_late(void); * hardware breakpoints. * @correct_hw_break: Allow an architecture to specify how to correct the * hardware debug registers. + * @enable_nmi: Manage NMI-triggered entry to KGDB */ struct kgdb_arch { unsigned char gdb_bpt_instr[BREAK_INSTR_SIZE]; @@ -252,6 +253,8 @@ struct kgdb_arch { void (*disable_hw_break)(struct pt_regs *regs); void (*remove_all_hw_break)(void); void (*correct_hw_break)(void); + + void (*enable_nmi)(bool on); }; /** diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 0557f24..17e073c 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -672,6 +672,10 @@ 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 = 0; + + if (arch_kgdb_ops.enable_nmi) + arch_kgdb_ops.enable_nmi(0); ks->cpu = raw_smp_processor_id(); ks->ex_vector = evector; @@ -681,11 +685,15 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs) ks->linux_regs = regs; if (kgdb_reenter_check(ks)) - return 0; /* Ouch, double exception ! */ + goto out; /* Ouch, double exception ! */ if (kgdb_info[ks->cpu].enter_kgdb != 0) - return 0; + goto out; - return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER); + ret = kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER); +out: + if (arch_kgdb_ops.enable_nmi) + arch_kgdb_ops.enable_nmi(1); + return ret; } int kgdb_nmicallback(int cpu, void *regs)