* [PATCH v2 0/2] irqchip/gic-v5: GICv5 KVM IRS review fixes
@ 2026-08-11 15:26 Sascha Bischoff
2026-08-11 15:27 ` [PATCH v2 1/2] irqchip/gic-v5: Clear per-CPU IRS data on teardown Sascha Bischoff
2026-08-11 15:27 ` [PATCH v2 2/2] irqchip/gic-v5: Synchronize CPU interface disable Sascha Bischoff
0 siblings, 2 replies; 4+ messages in thread
From: Sascha Bischoff @ 2026-08-11 15:26 UTC (permalink / raw)
To: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: nd, maz@kernel.org, lpieralisi@kernel.org
Hi all,
v1 [1] combined irqchip and KVM fixes identified by Sashiko [2] while
reviewing the GICv5 KVM IRS series [3]. Following feedback, v2 splits
the fixes into separate irqchip and KVM postings. This posting
contains the irqchip fixes; the KVM fixes are posted separately.
Changes since v1:
* Split the combined series into irqchip and KVM postings.
* Dropped the setting of a CPU's IAFFID to 0 on clear as this might be a valid
IAFFID.
* Added a reviewed by tag to "irqchip/gic-v5: Clear per-CPU IRS data
on teardown".
The fixes are:
* Clear the per-CPU IRS pointer and IAFFID state when host IRS
initialisation fails or an IRS is removed. This prevents the per-CPU
state from retaining a pointer to freed IRS data.
* Add an isb() after disabling the GICv5 CPU interface. This ensures
that interrupts are disabled before the helper returns.
These changes are based on v7.2-rc7.
Thanks,
Sascha
[1] https://lore.kernel.org/all/20260810102652.758719-1-sascha.bischoff@arm.com/
[2] https://sashiko.dev/#/patchset/20260724104819.1296803-1-sascha.bischoff%40arm.com
[3] https://lore.kernel.org/all/20260724104819.1296803-1-sascha.bischoff@arm.com/
Sascha Bischoff (2):
irqchip/gic-v5: Clear per-CPU IRS data on teardown
irqchip/gic-v5: Synchronize CPU interface disable
drivers/irqchip/irq-gic-v5-irs.c | 15 +++++++++++++++
drivers/irqchip/irq-gic-v5.c | 1 +
2 files changed, 16 insertions(+)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] irqchip/gic-v5: Clear per-CPU IRS data on teardown
2026-08-11 15:26 [PATCH v2 0/2] irqchip/gic-v5: GICv5 KVM IRS review fixes Sascha Bischoff
@ 2026-08-11 15:27 ` Sascha Bischoff
2026-08-11 15:27 ` [PATCH v2 2/2] irqchip/gic-v5: Synchronize CPU interface disable Sascha Bischoff
1 sibling, 0 replies; 4+ messages in thread
From: Sascha Bischoff @ 2026-08-11 15:27 UTC (permalink / raw)
To: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: nd, maz@kernel.org, lpieralisi@kernel.org
IRS affinity setup publishes an IRS pointer and IAFFID state in the
per-CPU data before the remaining IRS initialization can fail. The
error path then frees the IRS data without clearing that published
state, leaving CPUs associated with freed memory.
On initialization failure and normal IRS teardown, clear the per-CPU
IRS association by removing the stale pointer to irs_data. Also
invalidate the per-CPU IAFFID state for any CPUs that were tied to the
IRS before it was freed.
Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Fixes: 5cb1b6dab2de ("irqchip/gic-v5: Add GICv5 IRS/SPI support")
Fixes: 35866efa52fe ("irqchip/gic-v5: Add ACPI IRS probing")
Link: https://sashiko.dev/#/patchset/20260724104819.1296803-1-sascha.bischoff@arm.com?part=2
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
drivers/irqchip/irq-gic-v5-irs.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v5-irs.c b/drivers/irqchip/irq-gic-v5-irs.c
index f3fce0b1e25d9..3028a8bbbf68b 100644
--- a/drivers/irqchip/irq-gic-v5-irs.c
+++ b/drivers/irqchip/irq-gic-v5-irs.c
@@ -651,6 +651,18 @@ static int __init gicv5_irs_of_init_affinity(struct device_node *node,
return ret;
}
+static void __init gicv5_irs_clear_affinity(struct gicv5_irs_chip_data *irs_data)
+{
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+ if (per_cpu(per_cpu_irs_data, cpu) == irs_data) {
+ per_cpu(cpu_iaffid, cpu).valid = false;
+ per_cpu(per_cpu_irs_data, cpu) = NULL;
+ }
+ }
+}
+
static void irs_setup_pri_bits(u32 idr1)
{
switch (FIELD_GET(GICV5_IRS_IDR1_PRIORITY_BITS, idr1)) {
@@ -773,6 +785,7 @@ static int __init gicv5_irs_of_init(struct device_node *node)
return ret;
out_iomem:
+ gicv5_irs_clear_affinity(irs_data);
iounmap(irs_base);
out_err:
kfree(irs_data);
@@ -787,6 +800,7 @@ void __init gicv5_irs_remove(void)
gicv5_deinit_lpis();
list_for_each_entry_safe(irs_data, tmp_data, &irs_nodes, entry) {
+ gicv5_irs_clear_affinity(irs_data);
iounmap(irs_data->irs_base);
list_del(&irs_data->entry);
kfree(irs_data);
@@ -951,6 +965,7 @@ static int __init gic_acpi_parse_madt_irs(union acpi_subtable_headers *header,
return 0;
out_map:
+ gicv5_irs_clear_affinity(irs_data);
iounmap(irs_base);
out_release:
release_mem_region(r->start, resource_size(r));
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] irqchip/gic-v5: Synchronize CPU interface disable
2026-08-11 15:26 [PATCH v2 0/2] irqchip/gic-v5: GICv5 KVM IRS review fixes Sascha Bischoff
2026-08-11 15:27 ` [PATCH v2 1/2] irqchip/gic-v5: Clear per-CPU IRS data on teardown Sascha Bischoff
@ 2026-08-11 15:27 ` Sascha Bischoff
2026-08-11 16:31 ` Lorenzo Pieralisi
1 sibling, 1 reply; 4+ messages in thread
From: Sascha Bischoff @ 2026-08-11 15:27 UTC (permalink / raw)
To: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: nd, maz@kernel.org, lpieralisi@kernel.org
The write disabling the GICv5 CPU interface is only guaranteed to take
effect after a context synchronization event. Without one, execution can
return from gicv5_cpu_disable_interrupts() while an interrupt is still
able to be taken.
Add an ISB after the ICC_CR0_EL1 write to ensure interrupts are
disabled before the function returns. No corresponding ISB is added
when enabling the interface, as interrupt delivery is asynchronous and
there is no obvious benefit to waiting for it.
Fixes: 7ec80fb3f025 ("irqchip/gic-v5: Add GICv5 PPI support")
Link: https://sashiko.dev/#/patchset/20260724104819.1296803-1-sascha.bischoff@arm.com?part=6
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
---
drivers/irqchip/irq-gic-v5.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/irqchip/irq-gic-v5.c b/drivers/irqchip/irq-gic-v5.c
index e9d1795235a66..6a99c541b559b 100644
--- a/drivers/irqchip/irq-gic-v5.c
+++ b/drivers/irqchip/irq-gic-v5.c
@@ -983,6 +983,7 @@ static void gicv5_cpu_disable_interrupts(void)
cr0 = FIELD_PREP(ICC_CR0_EL1_EN, 0);
write_sysreg_s(cr0, SYS_ICC_CR0_EL1);
+ isb();
}
static void gicv5_cpu_enable_interrupts(void)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] irqchip/gic-v5: Synchronize CPU interface disable
2026-08-11 15:27 ` [PATCH v2 2/2] irqchip/gic-v5: Synchronize CPU interface disable Sascha Bischoff
@ 2026-08-11 16:31 ` Lorenzo Pieralisi
0 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Pieralisi @ 2026-08-11 16:31 UTC (permalink / raw)
To: Sascha Bischoff
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, nd, maz@kernel.org
On Tue, Aug 11, 2026 at 03:27:31PM +0000, Sascha Bischoff wrote:
> The write disabling the GICv5 CPU interface is only guaranteed to take
> effect after a context synchronization event. Without one, execution can
> return from gicv5_cpu_disable_interrupts() while an interrupt is still
> able to be taken.
>
> Add an ISB after the ICC_CR0_EL1 write to ensure interrupts are
> disabled before the function returns. No corresponding ISB is added
> when enabling the interface, as interrupt delivery is asynchronous and
> there is no obvious benefit to waiting for it.
>
> Fixes: 7ec80fb3f025 ("irqchip/gic-v5: Add GICv5 PPI support")
> Link: https://sashiko.dev/#/patchset/20260724104819.1296803-1-sascha.bischoff@arm.com?part=6
> Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
> ---
> drivers/irqchip/irq-gic-v5.c | 1 +
> 1 file changed, 1 insertion(+)
Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
> diff --git a/drivers/irqchip/irq-gic-v5.c b/drivers/irqchip/irq-gic-v5.c
> index e9d1795235a66..6a99c541b559b 100644
> --- a/drivers/irqchip/irq-gic-v5.c
> +++ b/drivers/irqchip/irq-gic-v5.c
> @@ -983,6 +983,7 @@ static void gicv5_cpu_disable_interrupts(void)
>
> cr0 = FIELD_PREP(ICC_CR0_EL1_EN, 0);
> write_sysreg_s(cr0, SYS_ICC_CR0_EL1);
> + isb();
> }
>
> static void gicv5_cpu_enable_interrupts(void)
> --
> 2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-11 16:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 15:26 [PATCH v2 0/2] irqchip/gic-v5: GICv5 KVM IRS review fixes Sascha Bischoff
2026-08-11 15:27 ` [PATCH v2 1/2] irqchip/gic-v5: Clear per-CPU IRS data on teardown Sascha Bischoff
2026-08-11 15:27 ` [PATCH v2 2/2] irqchip/gic-v5: Synchronize CPU interface disable Sascha Bischoff
2026-08-11 16:31 ` Lorenzo Pieralisi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox