OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 v2 0/2] vfio, KVM: kvm reference leak and debugfs clash on live update
@ 2026-11-05 12:17 Andrey Drobyshev
  2026-11-05 12:17 ` [Devel] [PATCH hci-8.1 1/2] vfio: take the kvm reference only for drivers that read device->kvm Andrey Drobyshev
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Andrey Drobyshev @ 2026-11-05 12: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, and
the new VM, on the same pid and fd number, finds its debugfs directory
taken.

Patch 1 takes that reference only for the drivers that read
device->kvm.  Patch 2 removes the debugfs directory when the VM's fd
is released.

Tested with 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", no
mismatches.

v1 -> v2:

- Patch 1: the reference is no longer moved to the new kvm, which
  changed device->kvm under KVMGT; it's taken only for drivers that
  opt in with needs_kvm_ref.  Fixes tag, tested driver named

- Patch 2: only the directory is removed at fd release, the stat data
  stays until kvm_destroy_vm() (use-after-free in v1); the message
  notes the uevent and vcpu-fd changes

- Both: Feature: lines, single spaces

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


Andrey Drobyshev (2):
  vfio: take the kvm reference only for drivers that read device->kvm
  KVM: remove the VM's debugfs directory when its fd is released

 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              |  6 ++++++
 virt/kvm/kvm_main.c               | 18 ++++++++++++++----
 6 files changed, 27 insertions(+), 6 deletions(-)

-- 
2.47.1

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

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [Devel] [PATCH hci-8.1 0/2] vfio: prevent kvm reference leak on qemu-update
@ 2026-10-30 14:49 Andrey Drobyshev
  2026-10-30 14:49 ` [Devel] [PATCH hci-8.1 2/2] KVM: remove the VM's debugfs directory when its fd is released Andrey Drobyshev
  0 siblings, 1 reply; 10+ messages in thread
From: Andrey Drobyshev @ 2026-10-30 14:49 UTC (permalink / raw)
  To: devel

Andrey Drobyshev (2):
  vfio: move an open device's kvm reference when its group gets a new
    kvm
  KVM: remove the VM's debugfs directory when its fd is released

 drivers/vfio/group.c | 21 +++++++++++++++++++++
 virt/kvm/kvm_main.c  |  5 +++++
 2 files changed, 26 insertions(+)

-- 
2.47.1

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

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

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

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 12:17 [Devel] [PATCH hci-8.1 v2 0/2] vfio, KVM: kvm reference leak and debugfs clash on live update Andrey Drobyshev
2026-11-05 12:17 ` [Devel] [PATCH hci-8.1 1/2] vfio: take the kvm reference only for drivers that read device->kvm Andrey Drobyshev
2026-11-05 12:23   ` no-reply
2026-11-05 12:54   ` Konstantin Khorenko
2026-11-05 12:17 ` [Devel] [PATCH hci-8.1 2/2] KVM: remove the VM's debugfs directory when its fd is released Andrey Drobyshev
2026-11-05 12:24   ` no-reply
2026-11-05 12:54   ` Konstantin Khorenko
2026-11-05 12:54 ` [Devel] [PATCH hci-8.1 v2 0/2] vfio, KVM: kvm reference leak and debugfs clash on live update Konstantin Khorenko
  -- strict thread matches above, loose matches on Subject: below --
2026-10-30 14:49 [Devel] [PATCH hci-8.1 0/2] vfio: prevent kvm reference leak on qemu-update Andrey Drobyshev
2026-10-30 14:49 ` [Devel] [PATCH hci-8.1 2/2] KVM: remove the VM's debugfs directory when its fd is released Andrey Drobyshev
2026-11-04 20:08   ` Konstantin Khorenko

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