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: 1194921 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id E2747DFFFD for ; Fri, 13 Jul 2012 10:27:30 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Spd0d-0003F1-GG; Fri, 13 Jul 2012 10:22:03 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Spcxy-0002wH-6T for linux-arm-kernel@lists.infradead.org; Fri, 13 Jul 2012 10:19:20 +0000 Received: by pbbrq13 with SMTP id rq13so5962073pbb.36 for ; Fri, 13 Jul 2012 03:19:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=xYn5WSLkhUi7vULu3qtXFy5S5nGW6R6I9R27gYy9YeM=; b=cyzeih6NewfNirWV9xBdXxCHRsO5S4Y8iRCcj0xdPNkBAgdAOkx7kycVx1K9E0ETER bzXyt3DhyckDLj9GKERg/ZmIq0i4Lk9oMdjUXetDzX6yutAFT9C7u9DTc62sm8FUJGIt JkZc6yk/665Ej0twxSl2GKi+hRHVXnuiuiNm7NJrOfeC5U0P3LvYwEi25dZv++AvsLWY 5yedvWgAAhZiDVUiGpLspLpF3koFJD0dGCIgaG+k2rVqw7ophoYbbVx26+lkflM+wmLn xJ3+ELyUkmdktVI8iEsnWnoVv7M3YBFEzOJcspOGHwhrNjZxltriumKnSazLnYRDF1OT DBeQ== 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 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: ALoCoQmeI1XfDGzreM9NnsbSuCzqIHUTI3EzLCvg8K49coK7sysO9UEW4mFnA/uqsXxKRziPuxIP X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , John Stultz , Colin Cross , kernel-team@android.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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)