Changeset
hw/vfio/pci.c | 1 -
1 file changed, 1 deletion(-)
Git apply log
Switched to a new branch '153133890557.31530.586346402906852972.stgit@w520.home'
Applying: vfio/pci: do not set the PCIDevice 'has_rom' attribute
To https://github.com/patchew-project/qemu
 * [new tag]         patchew/153133890557.31530.586346402906852972.stgit@w520.home -> patchew/153133890557.31530.586346402906852972.stgit@w520.home
Test passed: checkpatch

loading

Test passed: docker-mingw@fedora

loading

Test passed: docker-quick@centos7

loading

[Qemu-devel] [PULL 0/1] VFIO fixes for qemu-3.0-rc1
Posted by Alex Williamson, 1 week ago
The following changes since commit c447afd5783b9237fa51b7a85777007d8d568bfc:

  Update version for v3.0.0-rc0 release (2018-07-10 18:19:50 +0100)

are available in the Git repository at:

  git://github.com/awilliam/qemu-vfio.git tags/vfio-fixes-20180711.1

for you to fetch changes up to 26c0ae56386edacc8b0da40264748f59afedb1bb:

  vfio/pci: do not set the PCIDevice 'has_rom' attribute (2018-07-11 13:43:57 -0600)

----------------------------------------------------------------
VFIO fixes 2018-07-11

 - Avoid RAMBlock segfault in option ROM teardown for vfio-pci devices
   (Cédric Le Goater)

----------------------------------------------------------------
Cédric Le Goater (1):
      vfio/pci: do not set the PCIDevice 'has_rom' attribute

 hw/vfio/pci.c | 1 -
 1 file changed, 1 deletion(-)

Re: [Qemu-devel] [PULL 0/1] VFIO fixes for qemu-3.0-rc1
Posted by Peter Maydell, 1 week ago
On 11 July 2018 at 20:55, Alex Williamson <alex.williamson@redhat.com> wrote:
> The following changes since commit c447afd5783b9237fa51b7a85777007d8d568bfc:
>
>   Update version for v3.0.0-rc0 release (2018-07-10 18:19:50 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/awilliam/qemu-vfio.git tags/vfio-fixes-20180711.1
>
> for you to fetch changes up to 26c0ae56386edacc8b0da40264748f59afedb1bb:
>
>   vfio/pci: do not set the PCIDevice 'has_rom' attribute (2018-07-11 13:43:57 -0600)
>
> ----------------------------------------------------------------
> VFIO fixes 2018-07-11
>
>  - Avoid RAMBlock segfault in option ROM teardown for vfio-pci devices
>    (Cédric Le Goater)
>
> ----------------------------------------------------------------
> Cédric Le Goater (1):
>       vfio/pci: do not set the PCIDevice 'has_rom' attribute
>
>  hw/vfio/pci.c | 1 -
>  1 file changed, 1 deletion(-)
>


Applied, thanks.

-- PMM

[Qemu-devel] [PULL 1/1] vfio/pci: do not set the PCIDevice 'has_rom' attribute
Posted by Alex Williamson, 1 week ago
From: Cédric Le Goater <clg@kaod.org>

PCI devices needing a ROM allocate an optional MemoryRegion with
pci_add_option_rom(). pci_del_option_rom() does the cleanup when the
device is destroyed. The only action taken by this routine is to call
vmstate_unregister_ram() which clears the id string of the optional
ROM RAMBlock and now, also flags the RAMBlock as non-migratable. This
was recently added by commit b895de502717 ("migration: discard
non-migratable RAMBlocks"), .

VFIO devices do their own loading of the PCI option ROM in
vfio_pci_size_rom(). The memory region is switched to an I/O region
and the PCI attribute 'has_rom' is set but the RAMBlock of the ROM
region is not allocated. When the associated PCI device is deleted,
pci_del_option_rom() calls vmstate_unregister_ram() which tries to
flag a NULL RAMBlock, leading to a SEGV.

It seems that 'has_rom' was set to have memory_region_destroy()
called, but since commit 469b046ead06 ("memory: remove
memory_region_destroy") this is not necessary anymore as the
MemoryRegion is freed automagically.

Remove the PCIDevice 'has_rom' attribute setting in vfio.

Fixes: b895de502717 ("migration: discard non-migratable RAMBlocks")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 hw/vfio/pci.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index a1577dea7fdb..6cbb8fa0549d 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -990,7 +990,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
     pci_register_bar(&vdev->pdev, PCI_ROM_SLOT,
                      PCI_BASE_ADDRESS_SPACE_MEMORY, &vdev->pdev.rom);
 
-    vdev->pdev.has_rom = true;
     vdev->rom_read_failed = false;
 }