From: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: Sascha Bischoff <sascha.bischoff@arm.com>,
Marc Zyngier <maz@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
Radu Rendec <radu@rendec.net>,
Timothy Hayes <timothy.hayes@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Jonathan Cameron <jic23@kernel.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Will Deacon <will@kernel.org>,
Fuad Tabba <tabba@google.com>
Subject: Re: [PATCH v2 00/10] irqchip/gic-v5: Fix misc IRS and ITS host driver issues
Date: Mon, 16 Nov 2026 13:14:50 +0100 [thread overview]
Message-ID: <avrzusx1g1ZICo0Q@red-moon> (raw)
In-Reply-To: <20261112145814.853424-1-fuad.tabba@linux.dev>
On Thu, Nov 12, 2026 at 02:58:14PM +0000, Fuad Tabba wrote:
> Hi Sascha,
>
> I found a couple more issues in the GICv5 host driver while looking
> into pKVM support for GICv5. Rather than explain the fixes, I thought
> I'd send you patches for two of them instead. If you think they're
> useful, please include them in v3. They apply on top of this series.
> Boot tested on the GICv5 FVP with a two-level device table.
>
> For the third one, the thing I spotted is that if the IDLE poll after
> an IRS_MAP_L2_ISTR write times out, gicv5_irs_iste_alloc() clears the
> level 1 entry and frees the level 2 IST, but nothing cancels the map.
> The IRS can still complete it and use the freed table. Keeping the
> table isn't enough either, since the next allocation in that range
> rewrites the level 1 entry while the map may still be running
> (R_SDVFP). vgic_v5_alloc_l2_vmt() and the ITT frees after a timed-out
> invalidate have the same shape. The question is, can an IRS miss the
> poll, or is a timeout here only ever a dead IRS?
Thank you for your patches Fuad.
The latter, though freeing memory on timeout wasn't a good idea given
that there is no way to cancel the respective, pending, mapping.
> Cheers,
> /fuad
>
> --- >8 ---
>
> From: Fuad Tabba <fuad.tabba@linux.dev>
> Subject: [PATCH] irqchip/gic-v5: Invalidate the level 1 DTE when registering a device
>
> With a two-level device table, gicv5_its_device_register() makes a
> level 1 DTE valid when it allocates the level 2 table that it points
> to. However, gicv5_its_device_cache_inv() invalidates the ITS caches
> with ITS_INV_DEVICER.L1 clear, which doesn't invalidate the level 1
> DTE. An update isn't guaranteed to be visible to the ITS until a cache
> invalidation that covers it completes (R_HQFDL in the GICv5
> specification). An ITS that cached the level 1 DTE while it was invalid
> can keep dropping events for the DeviceIDs in its range.
>
> Set ITS_INV_DEVICER.L1 on every device invalidation. It covers the
> level 2 DTE as well, and has no effect with a linear device table.
>
> Fixes: 57d72196dfc85 ("irqchip/gic-v5: Add GICv5 ITS support")
> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
> ---
>
> Notes:
> Setting L1 on every invalidation turns each registration and
> teardown into a range invalidate, both rare paths, and keeps the
> function simple. Setting it only when registration allocates the
> level 2 table would miss a registration that fails after the
> allocation, which leaves the level 1 DTE valid.
I can't follow. I agree that we have to invalidate the L1 DTE on
L2 allocation but that's a one-off, I don't understand what issues
you are pointing out in the Notes above, if you can point out please
the code paths it refers to that'd help.
Thanks,
Lorenzo
> drivers/irqchip/irq-gic-v5-its.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/irqchip/irq-gic-v5-its.c b/drivers/irqchip/irq-gic-v5-its.c
> index 101aceec68f63..83952e30178b1 100644
> --- a/drivers/irqchip/irq-gic-v5-its.c
> +++ b/drivers/irqchip/irq-gic-v5-its.c
> @@ -372,10 +372,11 @@ static int gicv5_its_device_cache_inv(struct gicv5_its_chip_data *its,
> u64 didr;
>
> didr = FIELD_PREP(GICV5_ITS_DIDR_DEVICEID, its_dev->device_id);
> + /* L1 also covers an L1 DTE that a registration may have just made valid. */
> devicer = FIELD_PREP(GICV5_ITS_INV_DEVICER_I, 0x1) |
> FIELD_PREP(GICV5_ITS_INV_DEVICER_EVENTID_BITS,
> its_dev->itt_cfg.event_id_bits) |
> - FIELD_PREP(GICV5_ITS_INV_DEVICER_L1, 0x0);
> + FIELD_PREP(GICV5_ITS_INV_DEVICER_L1, 0x1);
>
> guard(raw_spinlock_irqsave)(&its->inv_lock);
>
>
> --- >8 ---
>
> From: Fuad Tabba <fuad.tabba@linux.dev>
> Subject: [PATCH] irqchip/gic-v5: Clean a level 2 device table before making it valid
>
> gicv5_its_alloc_l2_devtab() allocates a zeroed level 2 device table and
> writes the level 1 DTE that points to it with VALID set. Unlike the
> other ITS tables, the new table isn't cleaned to the PoC first. On a
> non-coherent ITS, the zeroes can still sit in the CPU caches when the
> ITS reads the table, so it can take stale memory as a valid level 2 DTE
> for a DeviceID that nothing has registered.
>
> Clean the table before the level 1 DTE is written.
>
> Fixes: 57d72196dfc85 ("irqchip/gic-v5: Add GICv5 ITS support")
> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
> ---
> drivers/irqchip/irq-gic-v5-its.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/irqchip/irq-gic-v5-its.c b/drivers/irqchip/irq-gic-v5-its.c
> index 83952e30178b1..b2d61ba3828cb 100644
> --- a/drivers/irqchip/irq-gic-v5-its.c
> +++ b/drivers/irqchip/irq-gic-v5-its.c
> @@ -416,6 +416,8 @@ static int gicv5_its_alloc_l2_devtab(struct gicv5_its_chip_data *its,
> if (!l2devtab)
> return -ENOMEM;
>
> + gicv5_its_dcache_clean(its, l2devtab, BIT(span) * sizeof(*l2devtab));
> +
> its->devtab_cfgr.l2.l2ptrs[l1_index] = l2devtab;
>
> l1dte = FIELD_PREP(GICV5_DTL1E_SPAN, span) |
prev parent reply other threads:[~2026-11-16 12:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 17:47 Sascha Bischoff
2026-11-04 17:47 ` [PATCH v2 01/10] irqchip/gic-v5: Reject SPIs not backed by an IRS Sascha Bischoff
2026-11-05 7:35 ` Lorenzo Pieralisi
2026-11-04 17:47 ` [PATCH v2 02/10] irqchip/gic-v5: Only set IRS DPS when 1ofN routing is supported Sascha Bischoff
2026-11-04 17:47 ` [PATCH v2 03/10] irqchip/gic-v5: Serialise IRS synchronisation requests Sascha Bischoff
2026-11-05 7:48 ` Lorenzo Pieralisi
2026-11-04 17:47 ` [PATCH v2 04/10] irqchip/gic-v5: Serialise ITS invalidation commands Sascha Bischoff
2026-11-05 8:31 ` Lorenzo Pieralisi
2026-11-04 17:47 ` [PATCH v2 05/10] irqchip/gic-v5: Use linear DT and ITT when L2 covers all IDs Sascha Bischoff
2026-11-04 17:48 ` [PATCH v2 06/10] irqchip/gic-v5: Honour ACPI ITS noncoherent flag Sascha Bischoff
2026-11-04 17:48 ` [PATCH v2 07/10] irqchip/gic-v5: Use firmware node name in ITS warning Sascha Bischoff
2026-11-04 17:48 ` [PATCH v2 08/10] irqchip/gic-v5: Invalidate ITS device cache before freeing ITT Sascha Bischoff
2026-11-04 17:48 ` [PATCH v2 09/10] irqchip/gic-v5: Clean the allocated linear device table size Sascha Bischoff
2026-11-05 7:37 ` Lorenzo Pieralisi
2026-11-04 17:48 ` [PATCH v2 10/10] irqchip/gic-v5: Release ITS MMIO region on DT probe failure Sascha Bischoff
2026-11-12 14:58 ` [PATCH v2 00/10] irqchip/gic-v5: Fix misc IRS and ITS host driver issues Fuad Tabba
2026-11-16 12:14 ` Lorenzo Pieralisi [this message]
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=avrzusx1g1ZICo0Q@red-moon \
--to=lpieralisi@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=radu@rendec.net \
--cc=rafael.j.wysocki@intel.com \
--cc=sascha.bischoff@arm.com \
--cc=tabba@google.com \
--cc=tglx@kernel.org \
--cc=timothy.hayes@arm.com \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®