Re: [PATCH v5 01/31] vfio: Use file-based reference counting for KVM
Steffen Eiden <[email protected]> Fri, 31 Jul 2026 16:54:35 +0200
| Newsgroups | dev.linux.lists.kvmarm,org.infradead.lists.linux-arm-kernel,org.kernel.vger.kvm,org.kernel.vger.linux-kernel,org.kernel.vger.linux-s390 |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jul 31, 2026 at 03:08:29PM +0200, Steffen Eiden wrote: > Replace manual module reference counting with file-based reference > counting for KVM integration. Previously, VFIO used symbol_get() to > obtain function pointers for kvm_get_kvm_safe() and kvm_put_kvm(), > then manually tracked module references through these symbols. This > approach required storing the put_kvm function pointer in each device > and carefully managing symbol references. > > Pass struct file pointers instead of struct kvm pointers throughout the > VFIO-KVM interface. This leverages the kernel's existing file reference > counting mechanism via get_file_active() and fput(), eliminating the > need for manual module reference tracking. The file->private_data field > provides access to the underlying struct kvm when needed. > > This simplifies the code and removes all remaining externally exported > symbols for KVM, paving the path for a second concurrent KVM module. > > Suggested-by: Jason Gunthorpe <[email protected]> > Suggested-by: Sean Christopherson <[email protected]> > Signed-off-by: Steffen Eiden <[email protected]> > --- > arch/x86/include/asm/kvm_page_track.h | 8 ++--- > arch/x86/kvm/Makefile | 3 -- > arch/x86/kvm/mmu/page_track.c | 16 +++++---- > drivers/s390/crypto/vfio_ap_ops.c | 24 ++++++++++--- > drivers/vfio/group.c | 2 +- > drivers/vfio/pci/vfio_pci_zdev.c | 7 +++- > drivers/vfio/vfio.h | 10 +++--- > drivers/vfio/vfio_main.c | 49 ++++++--------------------- > include/linux/kvm_host.h | 2 ++ > include/linux/vfio.h | 4 +-- > virt/kvm/kvm_main.c | 23 ++++++++++--- > virt/kvm/vfio.c | 8 ++--- > 12 files changed, 81 insertions(+), 75 deletions(-) @sean: This is based on your draft in https://lore.kernel.org/all/[email protected]/ do you want another/more attribution? If yes which? Steffen