[PATCH v9 09/13] iommufd/viommu: Select vIOMMU operations before allocation
Aneesh Kumar K.V
aneesh.kumar at kernel.org
Mon Nov 23 20:12:12 PST 2026
Jacob Pan <jacob.pan at linux.microsoft.com> writes:
> Hi Aneesh,
>
> On Mon, 16 Nov 2026 13:49:31 +0530
> "Aneesh Kumar K.V (Arm)" <aneesh.kumar at kernel.org> wrote:
>
>> Physical IOMMU drivers currently provide the vIOMMU size and
>> initialization callbacks through iommu_ops. The initialization
>> callback then selects and installs the corresponding
>> iommufd_viommu_ops.
>>
>> Add iommu_ops::get_viommu_ops() to select the operations from the
>> physical device and requested vIOMMU type before allocation. Move the
>> size and initialization callbacks into iommufd_viommu_ops. The core
>> can then validate the selected operations, allocate the driver
>> structure, initialize it, and install the operations.
> The patch title is slightly misleading since it does not change the
> order between setting viommu_ops and allocation. IMHO, it is more like:
> "Move vIOMMU ops selection into the core"
>
previously we did
ops = iommu_dev->ops;
viommu_size = ops->get_viommu_size(idev->dev, cmd->type);
viommu = (struct iommufd_viommu *)_iommufd_object_alloc_ucmd(
ucmd, viommu_size, IOMMUFD_OBJ_VIOMMU);
rc = ops->viommu_init(viommu, hwpt_paging->common.domain,
user_data.len ? &user_data : NULL);
if (rc)
and viommu_ini did things like
viommu->ops = &arm_vsmmu_ops;
With this patch it becomes
ops = iommu_dev->ops->get_viommu_ops(idev->dev, cmd->type);
viommu_size = ops->get_viommu_size(idev->dev, cmd->type);
viommu = (struct iommufd_viommu *)_iommufd_object_alloc_ucmd(
ucmd, viommu_size, IOMMUFD_OBJ_VIOMMU);
rc = ops->viommu_init(viommu, idev->dev,
That is, we now select the vIOMMU ops before allocation.
-aneesh
More information about the linux-arm-kernel
mailing list