[PATCH v9 04/13] iommufd/device: Associate KVM file pointer with iommufd_device
Aneesh Kumar K.V
aneesh.kumar at kernel.org
Mon Nov 23 20:01:43 PST 2026
Baolu Lu <baolu.lu at linux.intel.com> writes:
> On 11/16/2026 4:19 PM, Aneesh Kumar K.V (Arm) wrote:
>> From: Shameer Kolothum<shameerali.kolothum.thodi at huawei.com>
>>
>> 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.
>>
>> Reviewed-by: Kevin Tian<kevin.tian at intel.com>
>> Reviewed-by: Jason Gunthorpe<jgg at nvidia.com>
>> Signed-off-by: Shameer Kolothum<shameerali.kolothum.thodi at huawei.com>
>> [nicolinc: fix build error in iommufd_test_mock_domain()]
>> Signed-off-by: Nicolin Chen<nicolinc at nvidia.com>
>> [aneesh.kumar: Switch to use kvm_file]
>> Cc: Jason Gunthorpe<jgg at ziepe.ca>
>> Cc: Kevin Tian<kevin.tian at intel.com>
>> Cc: Joerg Roedel<joro at 8bytes.org>
>> Cc: Will Deacon<will at kernel.org>
>> Cc: Robin Murphy<robin.murphy at arm.com>
>> Cc: Alex Williamson<alex at shazbot.org>
>> Cc:iommu at lists.linux.dev
>> Signed-off-by: Aneesh Kumar K.V (Arm)<aneesh.kumar at kernel.org>
>> ---
>> drivers/iommu/iommufd/device.c | 7 ++++++-
>> drivers/iommu/iommufd/iommufd_private.h | 2 ++
>> drivers/iommu/iommufd/selftest.c | 2 +-
>> drivers/vfio/iommufd.c | 3 ++-
>> include/linux/iommufd.h | 4 +++-
>> 5 files changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
>> index 1b0bdf57ac8a..935f42616a65 100644
>> --- a/drivers/iommu/iommufd/device.c
>> +++ b/drivers/iommu/iommufd/device.c
>> @@ -295,6 +295,7 @@ static int iommufd_bind_noiommu(struct iommufd_device *idev)
>> * iommufd_device_bind - Bind a physical device to an iommu fd
>> * @ictx: iommufd file descriptor
>> * @dev: Pointer to a physical device struct
>> + * @kvm_file: VM file if device belongs to a KVM VM
>> * @id: Output ID number to return to userspace for this device
>> *
>> * A successful bind establishes an ownership over the device and returns
>
> As discussed during the v8 review, how does this series address the risk
> that the KVM file pointer could become invalid if REMOVE_WAIT times out?
> The changelog says the extra KVM file reference was dropped. Is the
> timeout expected never to occur, or should it be addressed by a broader
> fix if it does? How about explaining this in the commit message so
> future readers understand why the extra reference isn’t needed.
>
The conclusion was not to fix it.
https://lore.kernel.org/all/20261112174009.GB2532299@ziepe.ca
-aneesh
More information about the linux-arm-kernel
mailing list