From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [v3 4/5] vfio: implement APIs to set/put kvm to/from vfio group Date: Mon, 7 Nov 2016 21:45:45 +0100 Message-ID: <9e83a26f-e5dc-ed91-a1b5-c6f165eed7ed@redhat.com> References: <1477895706-22824-1-git-send-email-jike.song@intel.com> <1477895706-22824-5-git-send-email-jike.song@intel.com> <20161107110412.5db26fd4@t450s.home> <20161107112834.2aa971df@t450s.home> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: Jike Song , guangrong.xiao@linux.intel.com, kwankhede@nvidia.com, cjia@nvidia.com, kevin.tian@intel.com, kvm@vger.kernel.org To: Alex Williamson Return-path: Received: from mail-wm0-f67.google.com ([74.125.82.67]:35400 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752104AbcKGUpt (ORCPT ); Mon, 7 Nov 2016 15:45:49 -0500 Received: by mail-wm0-f67.google.com with SMTP id a20so7762714wme.2 for ; Mon, 07 Nov 2016 12:45:49 -0800 (PST) In-Reply-To: <20161107112834.2aa971df@t450s.home> Sender: kvm-owner@vger.kernel.org List-ID: On 07/11/2016 19:28, Alex Williamson wrote: > > > Can the reference become invalid? > > > > No, this is guaranteed by virt/kvm/vfio.c + the udata.lock mutex (which > > probably should be renamed...). > > The caller gets a reference to kvm, but there's no guarantee that the > association of that kvm reference to the group stays valid. Once we're > outside of that mutex, we might as well consider that kvm:group > association stale. > > > > The caller may still hold > > > a kvm references, but couldn't the group be detached from one kvm > > > instance and re-attached to another? > > > > Can this be handled by the vendor driver? Does it get a callback when > > it's detached from a KVM instance? > > The only release callback through vfio is when the user closes the > device, the code in this series is the full extent of vfio awareness of > kvm. Thanks, Maybe there should be an mdev callback at the point of association and deassociation between VFIO and KVM. Then the vendor driver can just use the same mutex for association, deassociation and usage. I'm not even sure that these patches are necessary once you have that callback. Paolo