Skip to content

Commit 773c05f

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
irqchip/gic-v3: Work around insecure GIC integrations
It appears that the relatively popular RK3399 SoC has been put together using a large amount of illicit substances, as experiments reveal that its integration of GIC500 exposes the *secure* programming interface to non-secure. This has some pretty bad effects on the way priorities are handled, and results in a dead machine if booting with pseudo-NMI enabled (irqchip.gicv3_pseudo_nmi=1) if the kernel contains 18fdb63 ("arm64: irqchip/gic-v3: Select priorities at boot time"), which relies on the priorities being programmed using the NS view. Let's restore some sanity by going one step further and disable security altogether in this case. This is not any worse, and puts us in a mode where priorities actually make some sense. Huge thanks to Mark Kettenis who initially identified this issue on OpenBSD, and to Chen-Yu Tsai who reported the problem in Linux. Fixes: 18fdb63 ("arm64: irqchip/gic-v3: Select priorities at boot time") Reported-by: Mark Kettenis <mark.kettenis@xs4all.nl> Reported-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Chen-Yu Tsai <wens@csie.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20241213141037.3995049-1-maz@kernel.org
1 parent a1855f1 commit 773c05f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

drivers/irqchip/irq-gic-v3.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,22 @@ static bool cpus_have_group0 __ro_after_init;
161161

162162
static void __init gic_prio_init(void)
163163
{
164-
cpus_have_security_disabled = gic_dist_security_disabled();
164+
bool ds;
165+
166+
ds = gic_dist_security_disabled();
167+
if (!ds) {
168+
u32 val;
169+
170+
val = readl_relaxed(gic_data.dist_base + GICD_CTLR);
171+
val |= GICD_CTLR_DS;
172+
writel_relaxed(val, gic_data.dist_base + GICD_CTLR);
173+
174+
ds = gic_dist_security_disabled();
175+
if (ds)
176+
pr_warn("Broken GIC integration, security disabled");
177+
}
178+
179+
cpus_have_security_disabled = ds;
165180
cpus_have_group0 = gic_has_group0();
166181

167182
/*

0 commit comments

Comments
 (0)