From patchwork Thu Jul 5 23:12:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 1162421 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id A6E963FE4F for ; Thu, 5 Jul 2012 23:20:25 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmvHR-0003MM-Kx; Thu, 05 Jul 2012 23:16:13 +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 1SmvGO-0003GT-M7 for linux-arm-kernel@lists.infradead.org; Thu, 05 Jul 2012 23:15:09 +0000 Received: by pbbrq13 with SMTP id rq13so15061702pbb.36 for ; Thu, 05 Jul 2012 16:15:06 -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=PKbod3zhxc6JlJSX6oNKzvuw49xGCNATIJvQWPCyHKtIU6H+VdDy/WvOtaZhE9nTGP neqonP3yVJWJWX5feLZ6ckH8kCkmviz0Vqxg64kepDI9i2SMS21LpQSHu68Q1w8QfAbQ SrAjfiRm8Gwn8UGmwO+/c2tP7msBYgC+qbtZ7RP2dTmrscVgEp9+ayLkGoSu33YpODo8 E4wgLUBk2+5aU4ydLs/CgYps8BzTl0AjSS7CnzLUbkD+5rmZNqLOmbsCEEKTkGd7A9I2 JvLbzPESD2o17gZWLL72zblB4kO/eSUbQ3yYaOcSpSUW5WaR5RhiZgleXqvR+1a2Qb3O qi4A== Received: by 10.68.238.232 with SMTP id vn8mr31050342pbc.78.1341530105966; Thu, 05 Jul 2012 16:15:05 -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 ny4sm20577400pbb.57.2012.07.05.16.15.04 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 16:15:05 -0700 (PDT) From: Anton Vorontsov To: Russell King , Jason Wessel Subject: [PATCH 2/6] kernel/debug: Mask KGDB NMI upon entry Date: Thu, 5 Jul 2012 16:12:36 -0700 Message-Id: <1341529960-18370-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120705231034.GA16931@lizard> References: <20120705231034.GA16931@lizard> X-Gm-Message-State: ALoCoQklwEYlyNuUbAdogVkPvSATJhqOO2gIeTRgIH0J7X9j7W/JHEcOxnNUgmsyhVDWJiqMofr3 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)