Blame SOURCES/kvm-hw-pci-fixed-hotplug-crash-when-using-rombar-0-with-.patch

9ae3a8
From bdd21901f9f1f10de38611d3b2b36e6e3d20fbd4 Mon Sep 17 00:00:00 2001
9ae3a8
From: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
Date: Thu, 20 Nov 2014 10:33:14 +0100
9ae3a8
Subject: [PATCH 2/2] hw/pci: fixed hotplug crash when using rombar=0 with
9ae3a8
 devices having romfile
9ae3a8
9ae3a8
Message-id: <1416479594-22022-3-git-send-email-marcel.a@redhat.com>
9ae3a8
Patchwork-id: 62485
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile
9ae3a8
Bugzilla: 1046007
9ae3a8
RH-Acked-by: Amos Kong <akong@redhat.com>
9ae3a8
RH-Acked-by: Eric Blake <eblake@redhat.com>
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
9ae3a8
Hot-plugging a device that has a romfile (either supplied by user
9ae3a8
or built-in) using rombar=0 option is a user error,
9ae3a8
do not allow the device to be hot-plugged.
9ae3a8
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
(cherry picked from commit db80c7b974f4ccab56bd5e8ff2248c7339b00c73)
9ae3a8
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/pci/pci.c | 9 +++++++++
9ae3a8
 1 file changed, 9 insertions(+)
9ae3a8
9ae3a8
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
9ae3a8
index 0918f4e..18773fe 100644
9ae3a8
--- a/hw/pci/pci.c
9ae3a8
+++ b/hw/pci/pci.c
9ae3a8
@@ -1924,6 +1924,15 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
9ae3a8
          * for 0.11 compatibility.
9ae3a8
          */
9ae3a8
         int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
9ae3a8
+
9ae3a8
+        /*
9ae3a8
+         * Hot-plugged devices can't use the option ROM
9ae3a8
+         * if the rom bar is disabled.
9ae3a8
+         */
9ae3a8
+        if (DEVICE(pdev)->hotplugged) {
9ae3a8
+            return -1;
9ae3a8
+        }
9ae3a8
+
9ae3a8
         if (class == 0x0300) {
9ae3a8
             rom_add_vga(pdev->romfile);
9ae3a8
         } else {
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8