From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Mackerras Date: Fri, 22 Feb 2019 09:39:38 +0000 Subject: Re: [PATCH kernel] KVM: PPC: Release all hardware TCE tables attached to a group Message-Id: <20190222093938.GC6006@blackberry> List-Id: References: <20190212043745.18290-1-aik@ozlabs.ru> In-Reply-To: <20190212043745.18290-1-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Alexey Kardashevskiy Cc: "Paul E . McKenney" , linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, David Gibson On Tue, Feb 12, 2019 at 03:37:45PM +1100, Alexey Kardashevskiy wrote: > The SPAPR TCE KVM device references all hardware IOMMU tables assigned to > some IOMMU group to ensure that in-kernel KVM acceleration of H_PUT_TCE > can work. The tables are references when an IOMMU group gets registered > with the VFIO KVM device by the KVM_DEV_VFIO_GROUP_ADD ioctl; > KVM_DEV_VFIO_GROUP_DEL calls into the dereferencing code > in kvm_spapr_tce_release_iommu_group() which walks through the list of > LIOBNs, finds a matching IOMMU table and calls kref_put() when found. > > However that code stops after the very first successful derefencing > leaving other tables referenced till the SPAPR TCE KVM device is destroyed > which normally happens on guest reboot or termination so if we do hotplug > and unplug in a loop, we are leaking IOMMU tables here. > > This removes a premature return to let kvm_spapr_tce_release_iommu_group() > find and dereference all attached tables. > > Fixes: 121f80ba68f "KVM: PPC: VFIO: Add in-kernel acceleration for VFIO" > Signed-off-by: Alexey Kardashevskiy Thanks, applied to my kvm-ppc-next tree. Paul.