* [PATCH v3 0/5] irqchip/gic-v3-its: Fixes to table allocation and the ITT pool
@ 2026-11-27 12:06 Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 1/5] irqchip/gic-v3-its: Order table zeroing before the GIC can see it Fuad Tabba
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-27 12:06 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Radu Rendec, Zenghui Yu, Lorenzo Pieralisi, Steven Price,
Suzuki K Poulose, Aneesh Kumar K . V, Will Deacon, Fuad Tabba,
linux-arm-kernel, linux-kernel
Hi folks,
Changes since v2 [1]:
- Dropped __GFP_ZERO from the pages added to the ITT pool. (Marc)
- Added Cc: stable to patch 3. (Marc)
- Changed patch 2's prefix to irqchip/gic-v4.1. (Zenghui)
- Collected Reviewed-by from Zenghui. (thanks!)
Five fixes to how the ITS driver sets up the memory the GIC reads.
The first adds the barrier that was missing between zeroing a table
page and the write that makes the page visible to the GIC. The second
cleans the GICv4.1 vPE table to PoC, as the driver already does for the
pending table. Without the clean, only a redistributor that accesses
the table as non-shareable can read stale contents from it.
The other three fix the ITT pool. Its 1-byte granule keeps ITTs aligned
only while every ITT's size is a multiple of 256, which holds for
power-of-two ITE sizes but not for QEMU's 12-byte ones. The third gives
the pool a 256-byte granule. The fourth zeroes an ITT reused from the
pool, as MAPD requires. The fifth frees the page when gen_pool_add()
fails.
With patch 4, a pKVM guest shares each new pool page with the host
before anything zeroes it. The pkvm-guest patch [2] makes
pkvm_set_memory_decrypted() zero what it shares, which closes that.
Based on Linux 7.4-rc3 (aebb727447640).
Cheers,
/fuad
[1] https://lore.kernel.org/all/20261116192933.3266502-1-fuad.tabba@linux.dev/
[2] https://lore.kernel.org/all/20261116110549.1863653-1-fuad.tabba@linux.dev/
Fuad Tabba (5):
irqchip/gic-v3-its: Order table zeroing before the GIC can see it
irqchip/gic-v4.1: Clean the vPE table to PoC
irqchip/gic-v3-its: Align sub-page ITTs to 256 bytes
irqchip/gic-v3-its: Zero ITTs reused from the ITT pool
irqchip/gic-v3-its: Free the page when gen_pool_add() fails
drivers/irqchip/irq-gic-v3-its.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/5] irqchip/gic-v3-its: Order table zeroing before the GIC can see it
2026-11-27 12:06 [PATCH v3 0/5] irqchip/gic-v3-its: Fixes to table allocation and the ITT pool Fuad Tabba
@ 2026-11-27 12:06 ` Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 2/5] irqchip/gic-v4.1: Clean the vPE table to PoC Fuad Tabba
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-27 12:06 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Radu Rendec, Zenghui Yu, Lorenzo Pieralisi, Steven Price,
Suzuki K Poulose, Aneesh Kumar K . V, Will Deacon, Fuad Tabba,
linux-arm-kernel, linux-kernel
The ITS driver allocates the ITS tables and the vPE tables as zeroed
pages. It exposes each table with a single store: a relaxed
GICR_VPROPBASER write with Valid set, the relaxed GITS_CTLR write that
enables the ITS, or a valid level-1 entry for a level-2 page.
However, on a shareable table the zeroing isn't ordered before that
store, so the GIC can read the page's previous contents as table
entries, which the spec makes UNPREDICTABLE (IHI 0069H.b 5.2.1, and
GICR_VPROPBASER.Z in 12.11.39). A level-2 page is exposed at runtime,
when the GIC may already be walking the level-1 table for other IDs.
Add a dsb(ishst) at the end of its_alloc_pages_node(), as
its_flush_cmd() does for a command. The allocator doesn't take a
shareability argument, so the barrier is unconditional. On a
non-shareable table it doesn't hurt.
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
drivers/irqchip/irq-gic-v3-its.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index c952c069f9373..9900c6a53526e 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -233,6 +233,9 @@ static struct page *its_alloc_pages_node(int node, gfp_t gfp,
if (ret)
return NULL;
+ /* Order the zeroing before any store that exposes the page to the GIC */
+ dsb(ishst);
+
return page;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/5] irqchip/gic-v4.1: Clean the vPE table to PoC
2026-11-27 12:06 [PATCH v3 0/5] irqchip/gic-v3-its: Fixes to table allocation and the ITT pool Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 1/5] irqchip/gic-v3-its: Order table zeroing before the GIC can see it Fuad Tabba
@ 2026-11-27 12:06 ` Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 3/5] irqchip/gic-v3-its: Align sub-page ITTs to 256 bytes Fuad Tabba
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-27 12:06 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Radu Rendec, Zenghui Yu, Lorenzo Pieralisi, Steven Price,
Suzuki K Poulose, Aneesh Kumar K . V, Will Deacon, Fuad Tabba,
linux-arm-kernel, linux-kernel
On a GICv4.1 system, allocate_vpe_l1_table() sets Z and Valid in
GICR_VPROPBASER and points it at a freshly zeroed vPE table, but leaves
the zeroes in the CPU's cache. A redistributor that accesses the table
as non-shareable reads it from memory, where it might not be zero, and
the spec makes that UNPREDICTABLE (GICR_VPROPBASER.Z, IHI 0069H.b
12.11.39).
Clean the table to PoC unconditionally, as the driver does for the
pending table. Testing rdists_support_shareable() isn't enough, since
GICR_VPROPBASER can read back as non-shareable even when the helper
returns true. allocate_vpe_l2_table() already cleans the level-2 pages
in that case. A vPE table inherited from an ITS is cleaned by
its_setup_baser() when the ITS is non-shareable.
Fixes: 5e5168461c22c ("irqchip/gic-v4.1: VPE table (aka GICR_VPROPBASER) allocation")
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
drivers/irqchip/irq-gic-v3-its.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 9900c6a53526e..6932dd0a02c42 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -3007,6 +3007,9 @@ static int allocate_vpe_l1_table(void)
pa = virt_to_phys(page_address(page));
WARN_ON(!IS_ALIGNED(pa, psz));
+ /* Make sure the GIC will observe the zeroed table */
+ gic_flush_dcache_to_poc(page_address(page), np * PAGE_SIZE);
+
val |= FIELD_PREP(GICR_VPROPBASER_4_1_ADDR, pa >> 12);
if (rdists_support_shareable()) {
val |= GICR_VPROPBASER_RaWb;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/5] irqchip/gic-v3-its: Align sub-page ITTs to 256 bytes
2026-11-27 12:06 [PATCH v3 0/5] irqchip/gic-v3-its: Fixes to table allocation and the ITT pool Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 1/5] irqchip/gic-v3-its: Order table zeroing before the GIC can see it Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 2/5] irqchip/gic-v4.1: Clean the vPE table to PoC Fuad Tabba
@ 2026-11-27 12:06 ` Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 4/5] irqchip/gic-v3-its: Zero ITTs reused from the ITT pool Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 5/5] irqchip/gic-v3-its: Free the page when gen_pool_add() fails Fuad Tabba
4 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-27 12:06 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Radu Rendec, Zenghui Yu, Lorenzo Pieralisi, Steven Price,
Suzuki K Poulose, Aneesh Kumar K . V, Will Deacon, Fuad Tabba,
linux-arm-kernel, linux-kernel, stable
Commit e36d4165f0796 ("irqchip/gic-v3-its: Rely on genpool alignment")
dropped the ALIGN() of the ITT address in MAPD, on the premise that the
ITT pool returns 256-byte aligned blocks. However, the pool's minimum
allocation order is get_order(ITS_ITT_ALIGN), which is 0, so its
granule is a single byte. An ITT whose size is not a multiple of 256
leaves the next device's ITT misaligned. MAPD drops the low bits of its
address, so that device's ITEs land on the previous device's ITT.
QEMU's emulated ITS has 12-byte ITEs, so two devices with 32 vectors
each are enough to hit it.
Create the pool with a granule of ITS_ITT_ALIGN.
Fixes: e36d4165f0796 ("irqchip/gic-v3-its: Rely on genpool alignment")
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
drivers/irqchip/irq-gic-v3-its.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 6932dd0a02c42..5756ffe4ec13e 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -5854,7 +5854,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
bool has_v4_1 = false;
int err;
- itt_pool = gen_pool_create(get_order(ITS_ITT_ALIGN), -1);
+ itt_pool = gen_pool_create(ilog2(ITS_ITT_ALIGN), -1);
if (!itt_pool)
return -ENOMEM;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 4/5] irqchip/gic-v3-its: Zero ITTs reused from the ITT pool
2026-11-27 12:06 [PATCH v3 0/5] irqchip/gic-v3-its: Fixes to table allocation and the ITT pool Fuad Tabba
` (2 preceding siblings ...)
2026-11-27 12:06 ` [PATCH v3 3/5] irqchip/gic-v3-its: Align sub-page ITTs to 256 bytes Fuad Tabba
@ 2026-11-27 12:06 ` Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 5/5] irqchip/gic-v3-its: Free the page when gen_pool_add() fails Fuad Tabba
4 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-27 12:06 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Radu Rendec, Zenghui Yu, Lorenzo Pieralisi, Steven Price,
Suzuki K Poulose, Aneesh Kumar K . V, Will Deacon, Fuad Tabba,
linux-arm-kernel, linux-kernel
Commit b08e2f42e86b5 ("irqchip/gic-v3-its: Share ITS tables with a
non-trusted hypervisor") moved sub-page ITTs from kzalloc_node() to a
genpool. An ITT freed back to the pool goes to the next device as the
previous one left it. MAPD is then UNPREDICTABLE: "When V == 1, the
specified ITT does not contain all zeros" (IHI 0069H.b, 5.3.10).
Zero every ITT that comes from the pool. The ITS then no longer needs
the pages added to the pool zeroed, so drop __GFP_ZERO from their
allocation. A pKVM guest shares each new pool page with the host,
though, and pkvm_set_memory_decrypted() doesn't zero what it shares, so
the host now sees that page's old contents.
Fixes: b08e2f42e86b5 ("irqchip/gic-v3-its: Share ITS tables with a non-trusted hypervisor")
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
drivers/irqchip/irq-gic-v3-its.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 5756ffe4ec13e..6eb2dbec5f0ed 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -270,10 +270,12 @@ static void *itt_alloc_pool(int node, int size)
do {
addr = gen_pool_alloc(itt_pool, size);
- if (addr)
+ if (addr) {
+ memset((void *)addr, 0, size);
break;
+ }
- page = its_alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0);
+ page = its_alloc_pages_node(node, GFP_KERNEL, 0);
if (!page)
break;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 5/5] irqchip/gic-v3-its: Free the page when gen_pool_add() fails
2026-11-27 12:06 [PATCH v3 0/5] irqchip/gic-v3-its: Fixes to table allocation and the ITT pool Fuad Tabba
` (3 preceding siblings ...)
2026-11-27 12:06 ` [PATCH v3 4/5] irqchip/gic-v3-its: Zero ITTs reused from the ITT pool Fuad Tabba
@ 2026-11-27 12:06 ` Fuad Tabba
4 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-27 12:06 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Radu Rendec, Zenghui Yu, Lorenzo Pieralisi, Steven Price,
Suzuki K Poulose, Aneesh Kumar K . V, Will Deacon, Fuad Tabba,
linux-arm-kernel, linux-kernel
When the ITT pool has no room, itt_alloc_pool() grows it by a page and
retries. gen_pool_add() fails when it cannot allocate its chunk
descriptor, but its return is ignored, so the page is leaked and the
retry allocates another page to leak, until an add succeeds or a page
allocation fails.
Free the page and fail the allocation instead.
Fixes: b08e2f42e86b5 ("irqchip/gic-v3-its: Share ITS tables with a non-trusted hypervisor")
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
drivers/irqchip/irq-gic-v3-its.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 6eb2dbec5f0ed..cb352ce69147d 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -279,7 +279,10 @@ static void *itt_alloc_pool(int node, int size)
if (!page)
break;
- gen_pool_add(itt_pool, (unsigned long)page_address(page), PAGE_SIZE, node);
+ if (gen_pool_add(itt_pool, (unsigned long)page_address(page), PAGE_SIZE, node)) {
+ its_free_pages(page_address(page), 0);
+ break;
+ }
} while (!addr);
return (void *)addr;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-27 12:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 12:06 [PATCH v3 0/5] irqchip/gic-v3-its: Fixes to table allocation and the ITT pool Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 1/5] irqchip/gic-v3-its: Order table zeroing before the GIC can see it Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 2/5] irqchip/gic-v4.1: Clean the vPE table to PoC Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 3/5] irqchip/gic-v3-its: Align sub-page ITTs to 256 bytes Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 4/5] irqchip/gic-v3-its: Zero ITTs reused from the ITT pool Fuad Tabba
2026-11-27 12:06 ` [PATCH v3 5/5] irqchip/gic-v3-its: Free the page when gen_pool_add() fails Fuad Tabba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox