Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] irqchip/gic-v4: Harden against bogus command line
@ 2026-05-26 11:26 Mostafa Saleh
  2026-05-26 12:24 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Mostafa Saleh @ 2026-05-26 11:26 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel; +Cc: maz, tglx, Mostafa Saleh

When accidentally setting “kvm-arm.vgic_v4_enable=1” on the wrong
setup that has no MSI controller device tree node (it exists but
not used) and GICv4, it caused a panic as “gic_domain” is NULL and
the kernel attempted to access its ops.

Originally, I hit this on an older kernel, but was able to reproduce
it on upstream with Qemu by hacking this unreasonable setup.

[   33.145536] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000028
[   33.145658] Mem abort info:
[   33.145751]   ESR = 0x0000000096000006
...
[   33.154057] CPU: 1 UID: 0 PID: 295 Comm: lkvm-static Not tainted 7.1.0-rc4-ge3f15ad3970e #5 PREEMPT
[   33.156922] Hardware name: linux,dummy-virt (DT)
[   33.158780] pstate: 81402005 (Nzcv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
[   33.160340] pc : __irq_domain_instantiate+0x1d4/0x578
[   33.162602] lr : __irq_domain_instantiate+0x1cc/0x578

Set vLPI support to false at init time if the host has no ITS, so it
propagates properly to kvm_vgic_global_state.has_gicv4.

Suggested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Mostafa Saleh <smostafa@google.com>

---
v2: Fix the issue at construction as Marc suggested.
---
 drivers/irqchip/irq-gic-v3-its.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 291d7668cc8d..d02cb9c17c0b 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -5837,6 +5837,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
 		its_acpi_probe();
 
 	if (list_empty(&its_nodes)) {
+		rdists->has_vlpis = false;
 		pr_warn("ITS: No ITS available, not enabling LPIs\n");
 		return -ENXIO;
 	}
-- 
2.54.0.746.g67dd491aae-goog



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

* Re: [PATCH v2] irqchip/gic-v4: Harden against bogus command line
  2026-05-26 11:26 [PATCH v2] irqchip/gic-v4: Harden against bogus command line Mostafa Saleh
@ 2026-05-26 12:24 ` Marc Zyngier
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2026-05-26 12:24 UTC (permalink / raw)
  To: Mostafa Saleh; +Cc: linux-arm-kernel, linux-kernel, tglx

On Tue, 26 May 2026 12:26:18 +0100,
Mostafa Saleh <smostafa@google.com> wrote:
> 

nit: $SUBJECT isn't quite telling the full story, and the command-line
is only a second order effect. Something like:

"irqchip/gic-v4: Don't advertise VLPIs if no ITS is probed"

actually describes the nature of the issue.

> When accidentally setting “kvm-arm.vgic_v4_enable=1” on the wrong
> setup that has no MSI controller device tree node (it exists but
> not used) and GICv4, it caused a panic as “gic_domain” is NULL and
> the kernel attempted to access its ops.
> 
> Originally, I hit this on an older kernel, but was able to reproduce
> it on upstream with Qemu by hacking this unreasonable setup.
> 
> [   33.145536] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000028
> [   33.145658] Mem abort info:
> [   33.145751]   ESR = 0x0000000096000006
> ...
> [   33.154057] CPU: 1 UID: 0 PID: 295 Comm: lkvm-static Not tainted 7.1.0-rc4-ge3f15ad3970e #5 PREEMPT
> [   33.156922] Hardware name: linux,dummy-virt (DT)
> [   33.158780] pstate: 81402005 (Nzcv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
> [   33.160340] pc : __irq_domain_instantiate+0x1d4/0x578
> [   33.162602] lr : __irq_domain_instantiate+0x1cc/0x578
> 
> Set vLPI support to false at init time if the host has no ITS, so it
> propagates properly to kvm_vgic_global_state.has_gicv4.
>
> Suggested-by: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Mostafa Saleh <smostafa@google.com>
> 
> ---
> v2: Fix the issue at construction as Marc suggested.
> ---
>  drivers/irqchip/irq-gic-v3-its.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index 291d7668cc8d..d02cb9c17c0b 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -5837,6 +5837,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
>  		its_acpi_probe();
>  
>  	if (list_empty(&its_nodes)) {
> +		rdists->has_vlpis = false;
>  		pr_warn("ITS: No ITS available, not enabling LPIs\n");
>  		return -ENXIO;
>  	}

With the above fixed:

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.


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

end of thread, other threads:[~2026-05-26 12:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 11:26 [PATCH v2] irqchip/gic-v4: Harden against bogus command line Mostafa Saleh
2026-05-26 12:24 ` Marc Zyngier

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