From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlH1J-000059-OB for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:46:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlH1D-000059-Iq for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:46:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlH1D-00004x-9m for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:45:59 -0500 Date: Mon, 3 Nov 2014 14:45:51 +0200 From: "Michael S. Tsirkin" Message-ID: <1415018633-16041-22-git-send-email-mst@redhat.com> References: <1415018633-16041-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1415018633-16041-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 21/29] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Anthony Liguori , Marcel Apfelbaum From: Marcel Apfelbaum 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 --- hw/pci/pci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 36226eb..371699c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1942,6 +1942,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 { -- MST