Re: [PATCH 1/2] irqchip/gic-v3-its: Zero shared pages after conversion

From: Marc Zyngier

Date: Thu Aug 20 2026 - 08:34:17 EST


On Thu, 20 Aug 2026 11:50:24 +0100,
Steven Price <steven.price@xxxxxxx> wrote:
>
> its_alloc_pages_node() passes __GFP_ZERO to the page allocator before
> calling set_memory_decrypted(). This assumes that converting a page from
> private to shared preserves its contents.
>
> For Arm CCA with MEC (Memory Encryption Contexts) the key used to access
> the page will change, and so by default the visible data will change.
> The host could ensure that it zeros the page, but rather than relying on
> the host's behaviour it's best if the guest simply zeros after the
> decryption rather than before. Specifically in this case the ITS tables
> are required to be zeroed.

What are the guarantees that we want to enforce post decryption? My
recollection is that the RME firmware cleans the caches to the PoPA,
making the data immediately visible to the hypervisor. Obviously, this
isn't the case anymore, since the zeroing comes after that, and I
don't see any CMO enforcing this.

I'm concerned that this relies on undocumented behaviours that may
hold today on some undisclosed combinations of HW and hypervisors, but
that are not guaranteed at all. set_memory_decrypted() doesn't really
say anything, and I have the feeling that we may want some hypervisor
specific hook to perform the correct CMO magic. I don't think this is
required right now, but I'm not excluding anything!

>
> Mask out __GFP_ZERO from the allocation request, and do the zeroing as a
> separate step after decryption.
>
> Fixes: b08e2f42e86b ("irqchip/gic-v3-its: Share ITS tables with a non-trusted hypervisor")
> Signed-off-by: Steven Price <steven.price@xxxxxxx>
> ---
> drivers/irqchip/irq-gic-v3-its.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index 6f5811aae59c..c954bbe9f4db 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -213,10 +213,12 @@ static gfp_t gfp_flags_quirk;
> static struct page *its_alloc_pages_node(int node, gfp_t gfp,
> unsigned int order)
> {
> + bool want_zero = gfp & __GFP_ZERO;
> struct page *page;
> int ret = 0;
>
> - page = alloc_pages_node(node, gfp | gfp_flags_quirk, order);
> + page = alloc_pages_node(node, (gfp & ~__GFP_ZERO) | gfp_flags_quirk,
> + order);
>
> if (!page)
> return NULL;
> @@ -231,6 +233,9 @@ static struct page *its_alloc_pages_node(int node, gfp_t gfp,
> if (ret)
> return NULL;
>
> + if (want_zero)
> + clear_pages(page_address(page), 1 << order);
> +

nit: please use BIT(order), which matches the type required for
clear_pages().

But I'd really like some discussion about the CMO side of things.

M.

--
Jazz isn't dead. It just smells funny.