Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1295682

[PATCH 4.4-rc5 v22 4/4] ARM: Allow IPI_CPU_BACKTRACE to exploit FIQ

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Daniel Thompson <daniel.thompson@linaro.org>
Newsgroups linux.kernel
Subject [PATCH 4.4-rc5 v22 4/4] ARM: Allow IPI_CPU_BACKTRACE to exploit FIQ
Date Sun, 20 Dec 2015 22:00:02 +0100
Message-ID <qHTfc-5yd-9@gated-at.bofh.it> (permalink)
References <qHTfc-5yd-11@gated-at.bofh.it>
X-Original-To Thomas Gleixner <tglx@linutronix.de>, Jason Cooper <jason@lakedaemon.net>, Russell King <linux@arm.linux.org.uk>, Marc Zyngier <marc.zyngier@arm.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IWZSPN0rP9tdy/RCzOJnuSLWbjF7LxUnMLSXXarc+H8=; b=O7w2pycBZs2365EmkWPLVDg147BIhDSBDUEOXTCd/a892FDcnFO3ErLPr/F+NyqPQo n1OFYgpUjvoRmY8AQfVx2MJZSMo8nFTQ9tibd9axU+5bQQQE1T3KYB7iG1ETFF+eKcwJ EVPITbgIMUbcGvywoV4nwghwHkn8AgaAqVPTo=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IWZSPN0rP9tdy/RCzOJnuSLWbjF7LxUnMLSXXarc+H8=; b=iKSZr4w2qC2u9rfzYH/l/oHBD9nXmZVYess0IHmQNeSDY9NHdNJHm9enJBF8lLbl+S SQGjP17m25D1Xe5edOxR6PHWSvkIORXREnau0CEkJb1adl7xOAd+oueO6gRKQ4kmNNnp 1sibg07oGwIulkqNYTz0j49+/Hx/r71aG3Eh8VW6ja/vYKSSr0RUozx2/akUU7JvOB2g YwBcWH4Ue7Eo0CczJD/i1Lk4eJNFxuVQx56c8OGari07Xwki5V5bS54jqsVXpnqz/S9d BYdG5ipvg2qpl7dGzImneGOUQTKXHGIFZfNcONfv5Eg+d4EB9knPXdeQ2il1e0SaLMME TVOg==
X-Gm-Message-State ALoCoQlg4IPKR/ttbPRQz2JxCcJ5pHr/WGcS3IeBYLUk9jA9nGw/qxUhlZOTr2HgPNPWHUIwsjj+cT5zIHgKkVT1WUIuUas0Pg==
X-Received by 10.194.117.163 with SMTP id kf3mr16701914wjb.139.1450644787617; Sun, 20 Dec 2015 12:53:07 -0800 (PST)
X-Mailer git-send-email 2.5.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 92
Organization linux.* mail to news gateway
X-Original-Cc Daniel Thompson <daniel.thompson@linaro.org>, Will Deacon <will.deacon@arm.com>, Catalin Marinas <catalin.marinas@arm.com>, Stephen Boyd <sboyd@codeaurora.org>, John Stultz <john.stultz@linaro.org>, Steven Rostedt <rostedt@goodmis.org>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Sumit Semwal <sumit.semwal@linaro.org>, Dirk Behme <dirk.behme@de.bosch.com>, Daniel Drake <drake@endlessm.com>, Dmitry Pervushin <dpervushin@gmail.com>, Tim Sander <tim@krieglstein.org>, Petr Mladek <pmladek@suse.com>
X-Original-Date Sun, 20 Dec 2015 20:52:37 +0000
X-Original-Message-ID <1450644757-18734-5-git-send-email-daniel.thompson@linaro.org>
X-Original-References <1450644757-18734-1-git-send-email-daniel.thompson@linaro.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1295682

Show key headers only | View raw


The GIC (v1 & v2) driver allows its implementation of handle_arch_irq()
to be called from the FIQ handler but currently the ARM code is not
able to exploit this.

Extend handle_fiq_as_nmi() to call handle_arch_irq(). This will affect
all interrupt controllers, including ones that do not support FIQ. This
is OK because a spurious FIQ is normally fatal. Handling a spurious FIQ
like a normal interrupt does risk deadlock but does give us a chance
of surviving long enough to get an error message out.

We also extend the SMP code to indicate to irq drivers which IPIs they
should seek to implement using FIQ.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
---
 arch/arm/include/asm/smp.h | 9 +++++++++
 arch/arm/kernel/smp.c      | 6 ++++++
 arch/arm/kernel/traps.c    | 9 ++++++++-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index 3d6dc8b460e4..daf869cff02e 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -18,6 +18,15 @@
 # error "<asm/smp.h> included in non-SMP build"
 #endif
 
+/*
+ * Identify which IPIs are safe for the irqchip to handle using FIQ.
+ *
+ * This information is advisory. The interrupt controller may not be capable
+ * of routing these IPIs to FIQ and the kernel will continue to work if they
+ * are routed to IRQ as normal.
+ */
+#define SMP_IPI_FIQ_MASK 0x80
+
 #define raw_smp_processor_id() (current_thread_info()->cpu)
 
 struct seq_file;
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index fe517f1e88d8..853089e1aa8a 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -639,6 +639,11 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
 		break;
 
 	case IPI_CPU_BACKTRACE:
+		if (in_nmi()) {
+			nmi_cpu_backtrace(regs);
+			break;
+		}
+
 		irq_enter();
 		nmi_cpu_backtrace(regs);
 		irq_exit();
@@ -750,6 +755,7 @@ static void raise_nmi(cpumask_t *mask)
 	if (cpumask_test_cpu(smp_processor_id(), mask) && irqs_disabled())
 		nmi_cpu_backtrace(NULL);
 
+	BUILD_BUG_ON(SMP_IPI_FIQ_MASK != BIT(IPI_CPU_BACKTRACE));
 	smp_cross_call(mask, IPI_CPU_BACKTRACE);
 }
 
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index bc698383e822..a04426ee7684 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -479,7 +479,14 @@ asmlinkage void __exception_irq_entry handle_fiq_as_nmi(struct pt_regs *regs)
 
 	nmi_enter();
 
-	/* nop. FIQ handlers for special arch/arm features can be added here. */
+	/*
+	 * Either the interrupt controller supports FIQ, meaning it will
+	 * do the right thing with this call, or we will end up treating a
+	 * spurious FIQ (which is normally fatal) as though it were an IRQ
+	 * which, although it risks deadlock, still gives us a sporting
+	 * chance of surviving long enough to log errors.
+	 */
+	handle_arch_irq(regs);
 
 	nmi_exit();
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 4.4-rc5 v22 4/4] ARM: Allow IPI_CPU_BACKTRACE to exploit FIQ Daniel Thompson <daniel.thompson@linaro.org> - 2015-12-20 22:00 +0100
  Re: [PATCH 4.4-rc5 v22 4/4] ARM: Allow IPI_CPU_BACKTRACE to exploit  FIQ kbuild test robot <lkp@intel.com> - 2015-12-20 23:20 +0100
  Re: [PATCH 4.4-rc5 v22 4/4] ARM: Allow IPI_CPU_BACKTRACE to exploit  FIQ kbuild test robot <lkp@intel.com> - 2015-12-21 00:00 +0100

csiph-web