Re: [PATCH v2 03/16] iommu: Implement IOMMU domain preservation

David Matlack
2026-05-01T22:08:52Z

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@google.com>

> +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++;
> +}