Re: [PATCH 1/2] irqchip/gic-v3-its: Share ITS tables with a non-trusted hypervisor

From: Catalin Marinas
Date: Fri Sep 06 2024 - 12:36:29 EST


On Thu, Sep 05, 2024 at 10:17:37AM +0100, Steven Price wrote:
> +static struct page *its_alloc_pages_node(int node, gfp_t gfp,
> + unsigned int order)
> +{
> + struct page *page;
> + int ret = 0;
> +
> + page = alloc_pages_node(node, gfp, order);
> +
> + if (!page)
> + return NULL;
> +
> + ret = set_memory_decrypted((unsigned long)page_address(page),
> + 1 << order);
> + if (WARN_ON(ret))
> + return NULL;

I think we discussed this but forgot the details. If
set_memory_decrypted() failed, I guess it's not safe to free the page
back as we don't know the state it is in. It might be worth adding a
comment if you respin for other reasons.

> +static void *itt_alloc_pool(int node, int size)
> +{
> + unsigned long addr;
> + struct page *page;
> +
> + if (size >= PAGE_SIZE) {
> + page = its_alloc_pages_node(node,
> + GFP_KERNEL | __GFP_ZERO,
> + get_order(size));
> +
> + return page_address(page);
> + }

Since its_alloc_pages_node() can return NULL, we should check for this
as page_address() would not be valid.

Otherwise the patch looks fine:

Reviewed-by: Catalin Marinas <catalin.marinas@xxxxxxx>