yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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