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: 1481661 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 6FB683FE65 for ; Wed, 19 Sep 2012 23:47:22 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TETxa-0006AE-9U; Wed, 19 Sep 2012 23:45:38 +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 1TETxX-00069i-1c for linux-arm-kernel@lists.infradead.org; Wed, 19 Sep 2012 23:45:35 +0000 Received: by pbbrq8 with SMTP id rq8so3820836pbb.36 for ; Wed, 19 Sep 2012 16:45:34 -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=XjOwYNue3KDnsXFqTlziRFq/Oa1zXrfBYJtVnLyefAA=; b=YYp+gcYpGTkk0o2oA+EVXvDqnww3Gc9bWdaKiw/TZxvdhgdHGDRiC/zFWHSM4TvOKJ AtTUyWsutTjb9qfwZxlM3DeKNrw6tzx0HUZxNA8WdDY8lhqQb2oTYlY+lovGfPhAzogS QJephBcZEP0vwPEgzsuglCa48YU21VJORzJ8QzJtXa2CJSENWs3zVQc/2EbdZzaYSNS4 zYYmVAE5c+74xvOWqlR/iWn6YpaSXQvJjWcYhafSiG5z3KinhBa6UaTg4In0eSNa4jcw CBhad9bqm+EGb1oJjW1pN2gRT83opuRjO06cZisG35q3RBDDhK4S1YjWJ81e8IrSwSa6 RppA== 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 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: ALoCoQnBq1JG8jOuTdAdF1j1AGFu3a8/sfVcFzZffRCwcMx5zuqusGA1ESXWR8GLOYfsX19+Ug9q 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, Brian Swetland , linux-kernel@vger.kernel.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , John Stultz , linux-serial@vger.kernel.org, Colin Cross , kgdb-bugreport@lists.sourceforge.net, Thomas Gleixner , 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 | 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)