From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X302L-0007Or-0R for qemu-devel@nongnu.org; Fri, 04 Jul 2014 05:44:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X302C-0006Sh-0E for qemu-devel@nongnu.org; Fri, 04 Jul 2014 05:44:08 -0400 Received: from mail-qc0-x22f.google.com ([2607:f8b0:400d:c01::22f]:45476) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X302B-0006Sd-Rn for qemu-devel@nongnu.org; Fri, 04 Jul 2014 05:43:59 -0400 Received: by mail-qc0-f175.google.com with SMTP id i8so1287306qcq.20 for ; Fri, 04 Jul 2014 02:43:59 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 4 Jul 2014 11:43:49 +0200 Message-Id: <1404467029-16028-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] virtio-pci: fix MSI memory region use after tree List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, mst@redhat.com After memory region QOMification QEMU is stricter in detecting wrong usage of the memory region API. Here it detected a memory_region_destroy done before the corresponding memory_region_del_subregion; the memory_region_destroy is done by msix_uninit_exclusive_bar, the memory_region_del_subregion is done by the PCI core's pci_unregister_io_regions before pc->exit is called. The misuse caused an assertion when hot-unplugging virtio devices. Using the API correctly fixes the assertion. Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 3c42cda..ecb2097 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1003,11 +1003,9 @@ static void virtio_pci_device_plugged(DeviceState *d) static void virtio_pci_device_unplugged(DeviceState *d) { - PCIDevice *pci_dev = PCI_DEVICE(d); VirtIOPCIProxy *proxy = VIRTIO_PCI(d); virtio_pci_stop_ioeventfd(proxy); - msix_uninit_exclusive_bar(pci_dev); } static int virtio_pci_init(PCIDevice *pci_dev) @@ -1024,6 +1022,8 @@ static int virtio_pci_init(PCIDevice *pci_dev) static void virtio_pci_exit(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev); + + msix_uninit_exclusive_bar(pci_dev); memory_region_destroy(&proxy->bar); } -- 1.9.3