[Intel-gfx] [PATCH 1/2] KVM: async kvm_destroy_vm for vfio devices
Jason Gunthorpe
jgg at nvidia.com
Thu Jan 12 17:27:41 UTC 2023
On Thu, Jan 12, 2023 at 12:21:17PM -0500, Matthew Rosato wrote:
> So should I work up a v2 that does symbol gets for kvm_get_kvm_safe
> and kvm_put_kvm from vfio_main and drop kvm_put_kvm_async? Or is
> the patch Yi is working on changing things such that will also
> address the deadlock issue?
I don't think Yi's part will help
> +361,22 @@ static int vfio_device_first_open(struct vfio_device
> *device, if (ret) goto err_module_put;
>
> + if (kvm && !vfio_kvm_get(kvm)) {
Do call it kvm_get_safe though
> + ret = -ENOENT;
> + goto err_unuse_iommu;
> + }
> device->kvm = kvm;
> if (device->ops->open_device) {
> ret = device->ops->open_device(device);
> if (ret)
> - goto err_unuse_iommu;
> + goto err_put_kvm;
> }
> return 0;
>
> -err_unuse_iommu:
> +err_put_kvm:
> + vfio_put_kvm(kvm);
> device->kvm = NULL;
> +err_unuse_iommu:
> if (iommufd)
> vfio_iommufd_unbind(device);
> else
> @@ -465,6 +471,9 @@ static int vfio_device_fops_release(struct inode *inode, struct file *filep)
>
> vfio_device_group_close(device);
>
> + if (device->open_count == 0 && device->group->kvm)
> + vfio_kvm_put(device->group->kvm);
> +
No, you can't touch group->kvm without holding the group lock,
that is the whole point of the problem..
This has to be device->kvm
Jason
More information about the Intel-gfx
mailing list