Re: [PATCH v2 03/16] iommu: Implement IOMMU domain preservation
From: David Matlack
Date: Fri May 01 2026 - 18:09:04 EST
On 2026-04-27 05:56 PM, Samiullah Khawaja wrote:
> Add IOMMU domain ops that can be implemented by the IOMMU drivers if
> they support IOMMU domain preservation across liveupdate. The new IOMMU
> domain preserve, unpreserve and restore APIs call these ops to perform
> respective live update operations.
>
> Signed-off-by: Samiullah Khawaja <skhawaja@xxxxxxxxxx>
> +static int alloc_object_ser(struct iommu_array_hdr_ser **curr_array_ptr, u64 max_objs)
> +{
> + struct iommu_array_hdr_ser *curr_array = *curr_array_ptr;
> + struct iommu_array_hdr_ser *next_array;
> +
There's a trade-off being made in this function to leak deleted array
elements instead of trying to reuse them that warrants a comment.
> + if (curr_array->nr_objects >= max_objs) {
> + next_array = kho_alloc_preserve(PAGE_SIZE);
> + if (IS_ERR(next_array))
> + return PTR_ERR(next_array);
> +
> + curr_array->next_array_phys = virt_to_phys(next_array);
> + *curr_array_ptr = next_array;
> + curr_array = next_array;
> + }
> +
> + return curr_array->nr_objects++;
> +}