thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-vfio-pci-do-not-set-the-PCIDevice-has_rom-attribute.patch

ae23c9
From 85d3fdbf408b0d96ff27c38d09770685c6bac4ec Mon Sep 17 00:00:00 2001
ae23c9
From: "plai@redhat.com" <plai@redhat.com>
ae23c9
Date: Mon, 7 Jan 2019 17:02:15 +0000
ae23c9
Subject: [PATCH 14/22] vfio/pci: do not set the PCIDevice 'has_rom' attribute
ae23c9
MIME-Version: 1.0
ae23c9
Content-Type: text/plain; charset=UTF-8
ae23c9
Content-Transfer-Encoding: 8bit
ae23c9
ae23c9
RH-Author: plai@redhat.com
ae23c9
Message-id: <1546880543-24860-3-git-send-email-plai@redhat.com>
ae23c9
Patchwork-id: 83888
ae23c9
O-Subject: [RHEL8.0 qemu-kvm PATCH v7 02/10] vfio/pci: do not set the PCIDevice 'has_rom' attribute
ae23c9
Bugzilla: 1539285
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ae23c9
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
ae23c9
ae23c9
From: Cédric Le Goater <clg@kaod.org>
ae23c9
ae23c9
PCI devices needing a ROM allocate an optional MemoryRegion with
ae23c9
pci_add_option_rom(). pci_del_option_rom() does the cleanup when the
ae23c9
device is destroyed. The only action taken by this routine is to call
ae23c9
vmstate_unregister_ram() which clears the id string of the optional
ae23c9
ROM RAMBlock and now, also flags the RAMBlock as non-migratable. This
ae23c9
was recently added by commit b895de502717 ("migration: discard
ae23c9
non-migratable RAMBlocks"), .
ae23c9
ae23c9
VFIO devices do their own loading of the PCI option ROM in
ae23c9
vfio_pci_size_rom(). The memory region is switched to an I/O region
ae23c9
and the PCI attribute 'has_rom' is set but the RAMBlock of the ROM
ae23c9
region is not allocated. When the associated PCI device is deleted,
ae23c9
pci_del_option_rom() calls vmstate_unregister_ram() which tries to
ae23c9
flag a NULL RAMBlock, leading to a SEGV.
ae23c9
ae23c9
It seems that 'has_rom' was set to have memory_region_destroy()
ae23c9
called, but since commit 469b046ead06 ("memory: remove
ae23c9
memory_region_destroy") this is not necessary anymore as the
ae23c9
MemoryRegion is freed automagically.
ae23c9
ae23c9
Remove the PCIDevice 'has_rom' attribute setting in vfio.
ae23c9
ae23c9
Fixes: b895de502717 ("migration: discard non-migratable RAMBlocks")
ae23c9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
ae23c9
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
ae23c9
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
ae23c9
(cherry picked from commit 26c0ae56386edacc8b0da40264748f59afedb1bb)
ae23c9
Signed-off-by: Paul Lai <plai@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 hw/vfio/pci.c | 1 -
ae23c9
 1 file changed, 1 deletion(-)
ae23c9
ae23c9
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
ae23c9
index b463661..ba3a393 100644
ae23c9
--- a/hw/vfio/pci.c
ae23c9
+++ b/hw/vfio/pci.c
ae23c9
@@ -990,7 +990,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
ae23c9
     pci_register_bar(&vdev->pdev, PCI_ROM_SLOT,
ae23c9
                      PCI_BASE_ADDRESS_SPACE_MEMORY, &vdev->pdev.rom);
ae23c9
 
ae23c9
-    vdev->pdev.has_rom = true;
ae23c9
     vdev->rom_read_failed = false;
ae23c9
 }
ae23c9
 
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9