From patchwork Mon Jul 30 11:58:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 10360 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 110BC23E02 for ; Mon, 30 Jul 2012 12:01:44 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id D4CDDA18AD0 for ; Mon, 30 Jul 2012 12:01:43 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so4587829yen.11 for ; Mon, 30 Jul 2012 05:01:43 -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=8AMLnNKRAeLtOc2iJoTAXw60hagUNqgIcXDaUV9sEIs=; b=WGhD0zCOTNbnoJYpGGrVN4uBfc+nXEbDEJ22Rk3GksMtcco3lEC5p3xTZ4MK5V/Cdi HqOGW2fV8y2HJoAdNGWZxb2buRGLWq7uyh6KbbMqXYe5HfWw+958YGAaeDl4/8KrytIn lsXezGscjxy9jzSJlOvJvOme7vjdgEz/S/R2ZVagT5+p1yJz7BO9PRXZiUMX9h4WM+wC SSmo6qCBImAr/hRkFeZSqNGJvJ/NQKDxdtUOHKYh8ILLipGGR8edUuijNIl5OOzqDp1h u1PpjyT1GYkpfEkE6J3z/hab1YmTxufn6HNHwFnah89xp4ojZRgRmgPNqPQRBmUhfFvE ZlXA== Received: by 10.50.94.166 with SMTP id dd6mr8003182igb.11.1343649703459; Mon, 30 Jul 2012 05:01:43 -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.87.40 with SMTP id u8csp84578igz; Mon, 30 Jul 2012 05:01:43 -0700 (PDT) Received: by 10.66.84.137 with SMTP id z9mr24253038pay.18.1343649702758; Mon, 30 Jul 2012 05:01:42 -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 tv8si17383013pbc.32.2012.07.30.05.01.42 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Jul 2012 05:01:42 -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 pbbrr4 with SMTP id rr4so11040174pbb.37 for ; Mon, 30 Jul 2012 05:01:42 -0700 (PDT) Received: by 10.68.223.164 with SMTP id qv4mr34755650pbc.20.1343649702343; Mon, 30 Jul 2012 05:01:42 -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 nk3sm7816420pbc.27.2012.07.30.05.01.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Jul 2012 05:01:41 -0700 (PDT) From: Anton Vorontsov To: Russell King , Jason Wessel , Greg Kroah-Hartman , Alan Cox 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 02/11] kernel/debug: Mask KGDB NMI upon entry Date: Mon, 30 Jul 2012 04:58:11 -0700 Message-Id: <1343649500-18491-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120730115719.GA5742@lizard> References: <20120730115719.GA5742@lizard> X-Gm-Message-State: ALoCoQkQvi6nTYL/lQtC4dw+hKxQRjxgwsgHgnuULJsVrmP40Fcb4/3VqpZoZLj0Ogef4Qd39PX+ 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 | 13 +++++++++++++ kernel/debug/debug_core.c | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index c4d2fc1..e0c0a2e 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -221,6 +221,19 @@ 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(). + * + * The call counts disable/enable requests, it returns 1 if NMI has been + * actually enabled after the call, and a value <= 0 if it is still + * disabled. + */ +extern int 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..38b0ab2 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -214,6 +214,11 @@ int __weak kgdb_skipexception(int exception, struct pt_regs *regs) return 0; } +int __weak kgdb_arch_enable_nmi(bool on) +{ + return 0; +} + /* * Some architectures need cache flushes when we set/clear a * breakpoint: @@ -672,6 +677,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 +693,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)