mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] irqchip/gic-v3: Configure all interrupts as non-secure Group-1
@ 2016-05-10 10:21 Marc Zyngier
  2016-05-10 10:43 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Zyngier @ 2016-05-10 10:21 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper; +Cc: Peter Maydell, linux-kernel

The GICv3 driver wrongly assumes that it runs on the non-secure
side of a secure-enabled system, while it could be on a system
with a single security state, or a GICv3 with GICD_CTLR.DS set.

Either way, it is important to configure this properly, or
interrupts will simply not be delivered on this HW.

Cc: stable@vger.kernel.org
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
It is getting a bit late for 4.6, so I plan to put this on top of
the 4.7 stuff, and let it trickle down to the stable trees (hence
the CC to stable).

Thanks,

	M.

 drivers/irqchip/irq-gic-v3.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index c3870a8..1a1ea4f 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -393,6 +393,15 @@ static void __init gic_dist_init(void)
 	writel_relaxed(0, base + GICD_CTLR);
 	gic_dist_wait_for_rwp();
 
+	/*
+	 * Configure SPIs as non-secure Group-1. This will only matter
+	 * if the GIC only has a single security state. This will not
+	 * do the right thing if the kernel is running in secure mode,
+	 * but that's not the intended use case anyway.
+	 */
+	for (i = 32; i < gic_data.irq_nr; i += 32)
+		writel_relaxed(~0, base + GICD_IGROUPR + i / 8);
+
 	gic_dist_config(base, gic_data.irq_nr, gic_dist_wait_for_rwp);
 
 	/* Enable distributor with ARE, Group1 */
@@ -510,6 +519,9 @@ static void gic_cpu_init(void)
 
 	rbase = gic_data_rdist_sgi_base();
 
+	/* Configure SGIs/PPIs as non-secure Group-1 */
+	writel_relaxed(~0, rbase + GICR_IGROUPR0);
+
 	gic_cpu_config(rbase, gic_redist_wait_for_rwp);
 
 	/* Give LPIs a spin */
-- 
2.1.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] irqchip/gic-v3: Configure all interrupts as non-secure Group-1
  2016-05-10 10:21 [PATCH] irqchip/gic-v3: Configure all interrupts as non-secure Group-1 Marc Zyngier
@ 2016-05-10 10:43 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2016-05-10 10:43 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: Thomas Gleixner, Jason Cooper, lkml - Kernel Mailing List

On 10 May 2016 at 11:21, Marc Zyngier <marc.zyngier@arm.com> wrote:
> The GICv3 driver wrongly assumes that it runs on the non-secure
> side of a secure-enabled system, while it could be on a system
> with a single security state, or a GICv3 with GICD_CTLR.DS set.
>
> Either way, it is important to configure this properly, or
> interrupts will simply not be delivered on this HW.
>
> Cc: stable@vger.kernel.org
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> It is getting a bit late for 4.6, so I plan to put this on top of
> the 4.7 stuff, and let it trickle down to the stable trees (hence
> the CC to stable).

Tested-by: Peter Maydell <peter.maydell@linaro.org>

(using a QEMU with GICv3 emulation, which is how I found this bug
in the first place.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-10 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10 10:21 [PATCH] irqchip/gic-v3: Configure all interrupts as non-secure Group-1 Marc Zyngier
2016-05-10 10:43 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®