RE: [PATCH v8 05/15] iommufd/device: Associate KVM file pointer with iommufd_device

From: Tian, Kevin

Date: Fri Nov 06 2026 - 02:10:31 EST


> From: Aneesh Kumar K.V (Arm) <aneesh.kumar@xxxxxxxxxx>
> Sent: Thursday, November 5, 2026 12:16 AM
>
> From: Shameer Kolothum <shameerali.kolothum.thodi@xxxxxxxxxx>
>
> TSM vDevice support needs access to the KVM associated with a VFIO device
> after the device has been bound to iommufd.
>
> Extend iommufd_device_bind() to accept the device's KVM file and store it
> in the iommufd_device. The KVM file reference is owned by VFIO and is
> already held for the duration of the device open path.
>
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@xxxxxxxxxx>
> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> [nicolinc: fix build error in iommufd_test_mock_domain()]
> Signed-off-by: Nicolin Chen <nicolinc@xxxxxxxxxx>
> [aneesh.kumar: Switch to use kvm_file]
> Cc: Jason Gunthorpe <jgg@xxxxxxxx>
> Cc: Kevin Tian <kevin.tian@xxxxxxxxx>
> Cc: Joerg Roedel <joro@xxxxxxxxxx>
> Cc: Will Deacon <will@xxxxxxxxxx>
> Cc: Robin Murphy <robin.murphy@xxxxxxx>
> Cc: Alex Williamson <alex@xxxxxxxxxxx>
> Cc: kvm@xxxxxxxxxxxxxxx
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@xxxxxxxxxx>

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

a nit:

> @@ -509,6 +509,8 @@ struct iommufd_device {
> struct list_head group_item;
> /* always the physical device */
> struct device *dev;
> + /* ..and the VM file if available */
> + struct file *kvm_file;

though the comment will be immediately replaced in next patch, let's
remove the pointless "..and" here.