Re: [PATCH v2 1/3] iommufd/viommu: Allow associating a KVM VM fd with a vIOMMU

From: Nicolin Chen

Date: Fri Mar 13 2026 - 02:40:59 EST


On Mon, Mar 09, 2026 at 04:47:02PM +0530, Aneesh Kumar K.V (Arm) wrote:
> Add optional KVM association to IOMMU_VIOMMU_ALLOC by introducing
> IOMMU_VIOMMU_KVM_FD and iommu_viommu_alloc::kvm_vm_fd.
>
> When the flag is set, iommufd validates that kvm_vm_fd refers to a KVM
> VM file and stores a referenced struct file in the vIOMMU object, so
> later iommufd operations can safely resolve the owning VM.
>
> This is preparatory plumbing for subsequent patches that bind TDI state
> to the associated KVM VM.
>
> The patch also switch file_is_kvm from EXPORT_SYMBOL_FOR_KVM_INTERNAL to
> EXPORT_SYMBOL_GPL so that iommu module can use that.

struct vfio_device has the kvm pointer already. So, I think it
could be forwarded from VFIO side v.s. via userspace ioctl.

Shammer had two patches before and Jason partially reviewed. I
took those for a side project but haven't sent anywhere. Would
you please check if they for you?

https://github.com/nicolinc/iommufd/commits/wip/viommu_kvm

Nicolin