RE: [PATCH v8 07/15] iommufd/viommu: Keep a reference to the KVM file
From: Tian, Kevin
Date: Fri Nov 06 2026 - 02:18:19 EST
> From: Aneesh Kumar K.V (Arm) <aneesh.kumar@xxxxxxxxxx>
> Sent: Thursday, November 5, 2026 12:16 AM
>
> From: Nicolin Chen <nicolinc@xxxxxxxxxx>
>
> The TSM vDevice operations need access to the KVM associated with the
> device's vIOMMU. Save the device's KVM file in the iommufd_viommu when
> the
> vIOMMU is allocated, and take a file reference so it remains valid for the
> lifetime of the vIOMMU.
>
> Release the reference when the vIOMMU is destroyed.
>
> Reject vdevice allocation when the device's KVM association differs from
> the vIOMMU's, including when only one has a KVM association. Allow
> allocation when both associations are NULL.
>
> Based on an original patch by
> Shameer Kolothum <shameerali.kolothum.thodi@xxxxxxxxxx>
>
> [nicolinc: hold kvm's users_count]
> 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>
> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@xxxxxxxxxx>
Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>