> +static int viommu_get_kvm(struct iommufd_viommu *viommu, int kvm_vm_fd) > +{ > + int rc = -EBADF; > + struct kvm *kvm; > + struct fd f = fdget(kvm_vm_fd); > + > + if (!fd_file(f) || !file_is_kvm(fd_file(f))) > + goto err_out; > + > + kvm = fd_file(f)->private_data; > + if (!kvm) > + goto err_out; Is this actually possible? Doesn't it suggest that the file refcount is not sufficient? If not possible then remove it. > + > + /* hold the kvm reference via file descriptor */ > + viommu->kvm_fd = f; You can't store a 'struct fd', fdget is a special "fast" function that only works within system calls. You must use the normal fget flow here. > diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h > index f29b6c44655e..b3b962d857c7 100644 > --- a/include/uapi/linux/iommufd.h > +++ b/include/uapi/linux/iommufd.h > @@ -957,6 +957,7 @@ enum iommu_viommu_type { > IOMMU_VIOMMU_TYPE_ARM_SMMUV3 = 1, > }; > > +#define IOMMU_VIOMMU_KVM_FD BIT(0) Needs a kdoc Jason