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

Samiullah Khawaja
2026-05-04T18:33:12Z

On Fri, May 01, 2026 at 10:08:47PM +0000, David Matlack wrote:
>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.

Are you referring to the "deleted" flag in the HDR of each object? Yes
we don't look for deleted objects in linked-list of arrays and reuse
them for simplicity. I will add a comment that says this.
>
>> + 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++;
>> +}