From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XinN8-0002Ac-DM for qemu-devel@nongnu.org; Mon, 27 Oct 2014 12:42:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XinN2-0000cm-9C for qemu-devel@nongnu.org; Mon, 27 Oct 2014 12:42:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XinN2-0000c9-30 for qemu-devel@nongnu.org; Mon, 27 Oct 2014 12:42:16 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9RGgFJM010097 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Oct 2014 12:42:15 -0400 From: Marcel Apfelbaum Date: Mon, 27 Oct 2014 18:41:22 +0200 Message-Id: <1414428082-7341-3-git-send-email-marcel.a@redhat.com> In-Reply-To: <1414428082-7341-1-git-send-email-marcel.a@redhat.com> References: <1414428082-7341-1-git-send-email-marcel.a@redhat.com> Subject: [Qemu-devel] [PATCH v3 2/2] 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: marcel@redhat.com, pbonzini@redhat.com, alex.williamson@redhat.com, armbru@redhat.com, mst@redhat.com Hot-plugging a device that has a romfile (either supplied by user or built-in) using rombar=0 option is an user error, do not allow the device to be hot-plugged. Signed-off-by: Marcel Apfelbaum --- 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 { -- 1.8.3.1