OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 v3 0/1] vfio: kvm reference leak on live update
@ 2026-11-05 14:17 Andrey Drobyshev
  2026-11-05 14:17 ` [Devel] [PATCH hci-8.1 v3 1/1] vfio: take the kvm reference only for drivers that read device->kvm Andrey Drobyshev
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andrey Drobyshev @ 2026-11-05 14:17 UTC (permalink / raw)
  To: devel

A live update keeps the passthrough device open while the VM is
re-created. The device holds a reference to the kvm it was opened
with, so the first VM is never destroyed until the device closes. Take
that reference only for the drivers that read device->kvm.

Tested with this patch alone: 30 live updates of a vGPU VM (RTX 6000
Ada SR-IOV VF) under guest DMA load, then 4 live migrations between
two such nodes: one KVM instance after every update, no "duplicate
directory", and no DMA'd buffer differing from the pattern written
into it.

v2 -> v3:

- Patch 2 (debugfs directory) dropped: with patch 1 nothing holds the
  old VM past exec. Traced: the VM fd release and kvm_destroy_vm() run
  at exec, 180 ms before the new QEMU creates its VM, so the directory
  is gone before the name can clash; the test above ran without it

- Patch 1: "in open_device()" and "device->kvm stays NULL without the
  flag" in the comment and the message, how nvidia-vgpu-vfio was
  checked, Assisted-by moved here, blank line before Feature:

v2: http://lore.virtuozzo.com/20261105121733.643754-1-andrey.drobyshev@virtuozzo.com
v1: http://lore.virtuozzo.com/20261030144933.944360-1-andrey.drobyshev@virtuozzo.com

Assisted-by: LLM


Andrey Drobyshev (1):
  vfio: take the kvm reference only for drivers that read device->kvm

 drivers/gpu/drm/i915/gvt/kvmgt.c  | 1 +
 drivers/s390/crypto/vfio_ap_ops.c | 1 +
 drivers/vfio/pci/vfio_pci_core.c  | 1 +
 drivers/vfio/vfio_main.c          | 6 ++++--
 include/linux/vfio.h              | 7 +++++++
 5 files changed, 14 insertions(+), 2 deletions(-)

-- 
2.47.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-05 17:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 14:17 [Devel] [PATCH hci-8.1 v3 0/1] vfio: kvm reference leak on live update Andrey Drobyshev
2026-11-05 14:17 ` [Devel] [PATCH hci-8.1 v3 1/1] vfio: take the kvm reference only for drivers that read device->kvm Andrey Drobyshev
2026-11-05 14:22   ` no-reply
2026-11-05 17:51   ` Konstantin Khorenko
2026-11-05 17:51 ` [Devel] [PATCH hci-8.1 v3 0/1] vfio: kvm reference leak on live update Konstantin Khorenko
2026-11-05 17:51 ` Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox