From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGlK8-0006Nv-Ha for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:19:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGlJv-0001po-Q3 for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:19:08 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:45583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGlJv-0001pc-Kd for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:18:55 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 21 Feb 2014 03:18:55 -0500 From: Michael Roth Date: Fri, 21 Feb 2014 02:17:16 -0600 Message-Id: <1392970647-21528-41-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1392970647-21528-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1392970647-21528-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 40/51] vfio-pci: Release all MSI-X vectors when disabled List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lersek@redhat.com, qemu-stable@nongnu.org, Petar.Jovanovic@imgtec.com From: Alex Williamson We were relying on msix_unset_vector_notifiers() to release all the vectors when we disable MSI-X, but this only happens when MSI-X is still enabled on the device. Perform further cleanup by releasing any remaining vectors listed as in-use after this call. This caused a leak of IRQ routes on hotplug depending on how the guest OS prepared the device for removal. Signed-off-by: Alex Williamson Cc: qemu-stable@nongnu.org (cherry picked from commit 3e40ba0faf0822fa78336fe6cd9d677ea9b14f1b) Signed-off-by: Michael Roth --- hw/misc/vfio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index f7f8a19..355b018 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -878,8 +878,20 @@ static void vfio_disable_msi_common(VFIODevice *vdev) static void vfio_disable_msix(VFIODevice *vdev) { + int i; + msix_unset_vector_notifiers(&vdev->pdev); + /* + * MSI-X will only release vectors if MSI-X is still enabled on the + * device, check through the rest and release it ourselves if necessary. + */ + for (i = 0; i < vdev->nr_vectors; i++) { + if (vdev->msi_vectors[i].use) { + vfio_msix_vector_release(&vdev->pdev, i); + } + } + if (vdev->nr_vectors) { vfio_disable_irqindex(vdev, VFIO_PCI_MSIX_IRQ_INDEX); } -- 1.7.9.5