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