Blame SOURCES/kvm-vfio-pci-Don-t-remove-irqchip-notifier-if-not-regist.patch

ddf19c
From e4631c00d8e9ee3608ef3196cbe8bec4841ee988 Mon Sep 17 00:00:00 2001
ddf19c
From: Peter Xu <peterx@redhat.com>
ddf19c
Date: Wed, 8 Jan 2020 15:04:57 +0000
ddf19c
Subject: [PATCH 2/5] vfio/pci: Don't remove irqchip notifier if not registered
ddf19c
ddf19c
RH-Author: Peter Xu <peterx@redhat.com>
ddf19c
Message-id: <20200108150457.12324-2-peterx@redhat.com>
ddf19c
Patchwork-id: 93291
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/1] vfio/pci: Don't remove irqchip notifier if not registered
ddf19c
Bugzilla: 1782678
ddf19c
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
ddf19c
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
ddf19c
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
ddf19c
ddf19c
The kvm irqchip notifier is only registered if the device supports
ddf19c
INTx, however it's unconditionally removed.  If the assigned device
ddf19c
does not support INTx, this will cause QEMU to crash when unplugging
ddf19c
the device from the system.  Change it to conditionally remove the
ddf19c
notifier only if the notify hook is setup.
ddf19c
ddf19c
CC: Eduardo Habkost <ehabkost@redhat.com>
ddf19c
CC: David Gibson <david@gibson.dropbear.id.au>
ddf19c
CC: Alex Williamson <alex.williamson@redhat.com>
ddf19c
Cc: qemu-stable@nongnu.org # v4.2
ddf19c
Reported-by: yanghliu@redhat.com
ddf19c
Debugged-by: Eduardo Habkost <ehabkost@redhat.com>
ddf19c
Fixes: c5478fea27ac ("vfio/pci: Respond to KVM irqchip change notifier")
ddf19c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1782678
ddf19c
Signed-off-by: Peter Xu <peterx@redhat.com>
ddf19c
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
ddf19c
Reviewed-by: Greg Kurz <groug@kaod.org>
ddf19c
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
ddf19c
(cherry picked from commit 0446f8121723b134ca1d1ed0b73e96d4a0a8689d)
ddf19c
Signed-off-by: Peter Xu <peterx@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 hw/vfio/pci.c | 4 +++-
ddf19c
 1 file changed, 3 insertions(+), 1 deletion(-)
ddf19c
ddf19c
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
ddf19c
index 309535f..d717520 100644
ddf19c
--- a/hw/vfio/pci.c
ddf19c
+++ b/hw/vfio/pci.c
ddf19c
@@ -3100,7 +3100,9 @@ static void vfio_exitfn(PCIDevice *pdev)
ddf19c
     vfio_unregister_req_notifier(vdev);
ddf19c
     vfio_unregister_err_notifier(vdev);
ddf19c
     pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
ddf19c
-    kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
ddf19c
+    if (vdev->irqchip_change_notifier.notify) {
ddf19c
+        kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
ddf19c
+    }
ddf19c
     vfio_disable_interrupts(vdev);
ddf19c
     if (vdev->intx.mmap_timer) {
ddf19c
         timer_free(vdev->intx.mmap_timer);
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c