> A device takes a reference to its group's kvm at the first open and
> drops it at the last close, so that device->kvm stays valid for the
> driver in between. QEMU's cpr-exec and cpr-transfer keep the device
> open while the VM is re-created, so the first VM stays referenced for
> as long as the device is: its vcpus, mm and in-kernel PIT thread with
> it. Seen as a second KVM instance in debugfs after a live update of a
> vGPU VM.
>
> Only three drivers read device->kvm: KVMGT, vfio_ap and vfio-pci's
> zdev support, all in open_device(), the first and the last at close
> too. Let them say so with needs_kvm_ref. Without it device->kvm stays
> NULL and no reference is taken, so the device can't keep a VM alive.
> Tested with nvidia-vgpu-vfio 595.71.03 on RTX 6000 Ada SR-IOV VFs, a
> vfio-pci variant driver that doesn't read the pointer: a grep for kvm
> over its sources (nvidia-595.71.03/nvidia-vgpu-vfio) finds only the
> kvm_host.h include and a comment.
>
> Fixes: 2b48f52f2bff ("vfio: fix deadlock between group lock and kvm lock")
> https://virtuozzo.atlassian.net/browse/VSTOR-150597
>
> Feature: fix ms/vfio
> Signed-off-by: Andrey Drobyshev <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review ยท
https://sashiko.vzint.dev/#/patchset/[email protected]?part=1
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel