From patchwork Wed Sep 19 23:41:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11511 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 D53B923E41 for ; Wed, 19 Sep 2012 23:45:36 +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 25208A18B08 for ; Wed, 19 Sep 2012 23:45:36 +0000 (UTC) Received: by ieje10 with SMTP id e10so2020369iej.11 for ; Wed, 19 Sep 2012 16:45:35 -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=XjOwYNue3KDnsXFqTlziRFq/Oa1zXrfBYJtVnLyefAA=; b=f0CM6AR4YybOvHhlgpiuFB35i/heqA/bNGNNFLPTrssnURr+FGVEiWHSTKSggGCUm3 OKaWoYPFw4rdBcahGDs3zy0IdwMzhXM+sDaFTHRhaL0yDSfMGkIhpPq72i0c++oPUPTb Ersizrs991pFkPNyvdFSHsTP000ztd45xBCsKrO9LbtVmt6oDxwyOzjkivGdNf7AR0ts /NWeLM8gmvIwRvyIRuIz2G5AJZzcFSsoxZE39ILqxwkkw1r6r5irrT5gT65HrNQglKrg CT30+Dp2ynvPqIv4Pz+Xn1TVj+IG26PNgA0F+Mfi+K3u3ZOkf3wLfNEoGYD8yWd9GuLw R43w== Received: by 10.50.7.212 with SMTP id l20mr86898iga.43.1348098335465; Wed, 19 Sep 2012 16:45:35 -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 ex8csp49670igc; Wed, 19 Sep 2012 16:45:34 -0700 (PDT) Received: by 10.66.75.168 with SMTP id d8mr865921paw.63.1348098334490; Wed, 19 Sep 2012 16:45:34 -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 s7si2186373pax.74.2012.09.19.16.45.34 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Sep 2012 16:45:34 -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 md12so3888025pbc.37 for ; Wed, 19 Sep 2012 16:45:34 -0700 (PDT) Received: by 10.68.221.225 with SMTP id qh1mr2040174pbc.50.1348098334077; Wed, 19 Sep 2012 16:45:34 -0700 (PDT) Received: from localhost (ip-64-134-220-225.public.wayport.net. [64.134.220.225]) by mx.google.com with ESMTPS id bm8sm1443764pab.3.2012.09.19.16.45.10 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Sep 2012 16:45:33 -0700 (PDT) From: Anton Vorontsov To: Andrew Morton , Russell King , Jason Wessel , Greg Kroah-Hartman , Alan Cox Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Colin Cross , Brian Swetland , John Stultz , Thomas Gleixner , 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: Wed, 19 Sep 2012 16:41:52 -0700 Message-Id: <1348098122-11041-1-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <20120919234003.GA24143@lizard> References: <20120919234003.GA24143@lizard> X-Gm-Message-State: ALoCoQl5T6KOEryfX5c3HrapZaP/7Y+C9NkRk6pPiN6AjdHYCqv5OGr/4VzqlMJXiKeSrAVgFAry 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 | 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)