Re: [PATCH 1/3] VFIO: take reference to the KVM module

From: Jason Gunthorpe

Date: Fri Apr 10 2026 - 14:14:48 EST


On Tue, Apr 07, 2026 at 08:01:05PM +0200, Paolo Bonzini wrote:
> VFIO is implicitly taking a reference to the KVM module between
> vfio_device_get_kvm_safe and vfio_device_put_kvm, thanks to
> symbol_get and symbol_put.
>
> In preparation for removing symbol_get and symbol_put themselves
> from VFIO, actually store a pointer to the KVM module and use
> module_get()/module_put() to keep KVM alive.

Why should VFIO have to deal with this? If it has a refcounted struct
kvm then it is kvm's problem to make sure that module doesn't
disappear while the refounct is valid..

I would expect this to happen naturally because the file_operations
are still live and they will hold the module refcount.

Jason