[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y78Wk2/P5+gLMdpk@nvidia.com>
Date: Wed, 11 Jan 2023 16:05:39 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Matthew Rosato <mjrosato@...ux.ibm.com>,
alex.williamson@...hat.com, pbonzini@...hat.com, cohuck@...hat.com,
farman@...ux.ibm.com, pmorel@...ux.ibm.com,
borntraeger@...ux.ibm.com, frankja@...ux.ibm.com,
imbrenda@...ux.ibm.com, david@...hat.com, akrowiak@...ux.ibm.com,
jjherne@...ux.ibm.com, pasic@...ux.ibm.com,
zhenyuw@...ux.intel.com, zhi.a.wang@...el.com,
linux-s390@...r.kernel.org, kvm@...r.kernel.org,
intel-gvt-dev@...ts.freedesktop.org,
intel-gfx@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] KVM: async kvm_destroy_vm for vfio devices
On Wed, Jan 11, 2023 at 07:54:51PM +0000, Sean Christopherson wrote:
> Something feels off. If KVM's refcount is 0, then accessing device->group->kvm
> in vfio_device_open() can't happen unless there's a refcounting bug somewhere.
The problem is in close, not open.
Specifically it would be very hard to avoid holding the group_lock
during close which is when the put is done.
> Rather than force devices to get KVM references, why not handle that in common
> VFIO code and drop KVM refcountin from devices? Worst case scenario KVM is pinned
> by a device that doesn't need KVM but is in a group associated with KVM. If that's
> a concern, it seems easy enough to add a flag to vfio_device_ops to enumerate
> whether or not the device depends on KVM.
We can't make cross-dependencies between kvm and core VFIO - it is why
so much of this is soo ugly.
The few device drivers that unavoidably have KVM involvment already
have a KVM module dependency, so they can safely do the get/put
Jason
Powered by blists - more mailing lists