Re: [PATCH v3 04/11] iommufd/viommu: Add IOMMU_VIOMMU_ALLOC ioctl

From: Jason Gunthorpe
Date: Thu Oct 17 2024 - 12:41:15 EST


On Wed, Oct 09, 2024 at 09:38:04AM -0700, Nicolin Chen wrote:
> Add a new ioctl for user space to do a vIOMMU allocation. It must be based
> on a nesting parent HWPT, so take its refcount.
>
> As an initial version, define an IOMMU_VIOMMU_TYPE_DEFAULT type. Using it,
> the object will be allocated by the iommufd core.
>
> If an IOMMU driver supports a driver-managed vIOMMU object, it must define
> its own IOMMU_VIOMMU_TYPE_ in the uAPI header and implement a viommu_alloc
> op in its iommu_ops.
>
> Signed-off-by: Nicolin Chen <nicolinc@xxxxxxxxxx>
> ---
> drivers/iommu/iommufd/Makefile | 3 +-
> drivers/iommu/iommufd/iommufd_private.h | 3 +
> include/uapi/linux/iommufd.h | 40 +++++++++++
> drivers/iommu/iommufd/main.c | 6 ++
> drivers/iommu/iommufd/viommu.c | 91 +++++++++++++++++++++++++
> 5 files changed, 142 insertions(+), 1 deletion(-)
> create mode 100644 drivers/iommu/iommufd/viommu.c

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason