Re: [PATCH v4 02/14] iommufd/viommu: Add IOMMU_VDEVICE_ALLOC ioctl

From: Baolu Lu
Date: Mon Oct 21 2024 - 23:41:13 EST


On 2024/10/22 8:20, Nicolin Chen wrote:
Introduce a new ioctl to allocate a vDEVICE object. Since a vDEVICE object
is a connection of an iommufd_iommufd object and an iommufd_viommu object,

nit:

:s/iommufd_iommufd/iommufd_device/g

or not?

require both as the ioctl inputs and take refcounts in the ioctl handler.

Add to the vIOMMU object a "vdevs" xarray, indexed by a per-vIOMMU virtual
device ID, which can be:
- Virtual StreamID on a nested ARM SMMUv3, an index to a Stream Table
- Virtual DeviceID on a nested AMD IOMMU, an index to a Device Table
- Virtual ID on a nested Intel VT-D IOMMU, an index to a Context Table

Then, let the idev structure hold the allocated vdev pointer with a proper
locking protection.

Signed-off-by: Nicolin Chen<nicolinc@xxxxxxxxxx>
---
drivers/iommu/iommufd/iommufd_private.h | 12 +++
include/linux/iommufd.h | 2 +
include/uapi/linux/iommufd.h | 26 ++++++
drivers/iommu/iommufd/device.c | 11 +++
drivers/iommu/iommufd/main.c | 7 ++
drivers/iommu/iommufd/viommu.c | 108 ++++++++++++++++++++++++
6 files changed, 166 insertions(+)

Thanks,
baolu