Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Sascha Bischoff <Sascha.Bischoff@arm.com>
To: "lpieralisi@kernel.org" <lpieralisi@kernel.org>
Cc: "yuzenghui@huawei.com" <yuzenghui@huawei.com>,
	Suzuki Poulose <Suzuki.Poulose@arm.com>, nd <nd@arm.com>,
	"kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
	"oupton@kernel.org" <oupton@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Joey Gouly <Joey.Gouly@arm.com>,
	"maz@kernel.org" <maz@kernel.org>
Subject: Re: [PATCH 2/5] irqchip/gic-v5: Clear per-CPU IRS data on teardown
Date: Tue, 11 Aug 2026 15:03:48 +0000	[thread overview]
Message-ID: <3ca3458f7215c0e1d68657a2a1b2677ec8522fbb.camel@arm.com> (raw)
In-Reply-To: <anm3snqnGHcqUogW@red-moon>

On Mon, 2026-08-10 at 13:36 +0200, Lorenzo Pieralisi wrote:
> On Mon, Aug 10, 2026 at 10:28:07AM +0000, Sascha Bischoff wrote:
> > 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
> > clear
> > the per-CPU IAFFID state for any CPUs that were tied to the IRS
> > before
> > it was freed.
> > 
> > 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 | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> 
> Thank you Sascha, a minor comment below otherwise:
> 
> Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org>

Thanks!

> 
> > diff --git a/drivers/irqchip/irq-gic-v5-irs.c
> > b/drivers/irqchip/irq-gic-v5-irs.c
> > index f3fce0b1e25d9..67940ea9e39b7 100644
> > --- a/drivers/irqchip/irq-gic-v5-irs.c
> > +++ b/drivers/irqchip/irq-gic-v5-irs.c
> > @@ -651,6 +651,19 @@ 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).iaffid = 0;
> 
> As long we set valid to false this is not necessarily needed, 0 is a
> valid
> value.

Thanks, Lorenzo. That's a good point. I've dropped the setting of
iaffid to 0 as marking it as invalid should be sufficient.

Sascha

> 
> Thanks,
> Lorenzo
> 
> > +			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 +786,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 +801,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 +966,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


  reply	other threads:[~2026-08-11 15:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 10:27 [PATCH 0/5] arm64: gic-v5: Fixes from GICv5 KVM IRS review Sascha Bischoff
2026-08-10 10:27 ` [PATCH 1/5] KVM: arm64: vgic: Free gic_kvm_info on initialization failure Sascha Bischoff
2026-08-10 10:28 ` [PATCH 2/5] irqchip/gic-v5: Clear per-CPU IRS data on teardown Sascha Bischoff
2026-08-10 10:47   ` sashiko-bot
2026-08-10 11:45     ` Lorenzo Pieralisi
2026-08-10 11:36   ` Lorenzo Pieralisi
2026-08-11 15:03     ` Sascha Bischoff [this message]
2026-08-10 10:28 ` [PATCH 3/5] irqchip/gic-v5: Synchronize CPU interface disable Sascha Bischoff
2026-08-10 10:54   ` sashiko-bot
2026-08-11 14:55     ` Sascha Bischoff
2026-08-10 10:29 ` [PATCH 4/5] KVM: arm64: vgic: Prevent speculative SPI array underflow Sascha Bischoff
2026-08-10 10:29 ` [PATCH 5/5] KVM: arm64: vgic: Reject out-of-range GICv5 PPI IDs Sascha Bischoff
2026-08-10 11:16   ` sashiko-bot
2026-08-11 14:59     ` Sascha Bischoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ca3458f7215c0e1d68657a2a1b2677ec8522fbb.camel@arm.com \
    --to=sascha.bischoff@arm.com \
    --cc=Joey.Gouly@arm.com \
    --cc=Suzuki.Poulose@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lpieralisi@kernel.org \
    --cc=maz@kernel.org \
    --cc=nd@arm.com \
    --cc=oupton@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox