qemu/hw/ppc
Greg Kurz a2166410ad spapr_pci: Unregister listeners before destroying the IOMMU address space
Hot-unplugging a PHB with a VFIO device connected to it crashes QEMU:

-device spapr-pci-host-bridge,index=1,id=phb1 \
-device vfio-pci,host=0034:01:00.3,id=vfio0

(qemu) device_del phb1
[  357.207183] iommu: Removing device 0001:00:00.0 from group 1
[  360.375523] rpadlpar_io: slot PHB 1 removed
qemu-system-ppc64: memory.c:2742:
 do_address_space_destroy: Assertion `QTAILQ_EMPTY(&as->listeners)' failed.

'as' is the IOMMU address space, which indeed has a listener registered
to by vfio_connect_container() when the VFIO device is realized. This
listener is supposed to be unregistered by vfio_disconnect_container()
when the VFIO device is finalized. Unfortunately, the VFIO device hasn't
reached finalize yet at the time the PHB unrealize function is called,
and address_space_destroy() gets called with the VFIO listener still
being registered.

All regions have just been unmapped from the address space. Listeners
aren't needed anymore at this point. Remove them before destroying the
address space.

The VFIO code will try to remove them _again_ at device finalize,
but it is okay since memory_listener_unregister() is idempotent.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <156110925375.92514.11649846071216864570.stgit@bahia.lan>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[dwg: Correct spelling error pointed out by aik]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-02 09:43:58 +10:00
..
e500-ccsr.h ppc: do not use ../ in include files 2013-03-01 13:57:33 +01:00
e500.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
e500.h platform-bus-device: use device plug callback instead of machine_done notifier 2018-05-10 18:10:56 +01:00
e500plat.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
fdt.c target/ppc: Split page size information into a separate allocation 2018-04-27 18:05:22 +10:00
fw_cfg.c hw/ppc: Implement fw_cfg_arch_key_name() 2019-05-23 14:10:31 +02:00
Kconfig spapr/xive: add KVM support 2019-05-29 11:39:45 +10:00
mac.h macio: move MACIOIDEState type declarations to macio.h 2018-08-30 10:42:18 +10:00
mac_newworld.c hw/ppc/mac_newworld: Drop useless CONFIG_KVM ifdefery 2019-07-02 09:43:58 +10:00
mac_oldworld.c hw/ppc/mac_oldworld: Drop useless CONFIG_KVM ifdefery 2019-07-02 09:43:58 +10:00
Makefile.objs hw/ppc: Implement fw_cfg_arch_key_name() 2019-05-23 14:10:31 +02:00
mpc8544_guts.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
mpc8544ds.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
pnv.c ppc/pnv: remove xscom_base field from PnvChip 2019-07-02 09:43:58 +10:00
pnv_bmc.c Include qapi/error.h exactly where needed 2018-02-09 13:50:17 +01:00
pnv_core.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
pnv_lpc.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
pnv_occ.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
pnv_psi.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
pnv_xscom.c ppc/pnv: fix XSCOM MMIO base address for P9 machines with multiple chips 2019-07-02 09:43:58 +10:00
ppc.c ppc: Introduce kvmppc_set_reg_tb_offset() helper 2019-07-02 09:43:58 +10:00
ppc4xx_devs.c ppc4xx: Pass array index to function instead of pointer into the array 2019-02-04 18:44:17 +11:00
ppc4xx_pci.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
ppc405.h ppc4xx: Export ECB and PLB emulation 2017-09-08 09:30:55 +10:00
ppc405_boards.c pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
ppc405_uc.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
ppc440.h ppc440_uc: Basic emulation of PPC440 DMA controller 2018-07-03 09:56:52 +10:00
ppc440_bamboo.c elf: Add optional function ptr to load_elf() to parse ELF notes 2019-02-05 16:50:16 +01:00
ppc440_pcix.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
ppc440_uc.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
ppc_booke.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
ppce500_spin.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
prep.c hw/ppc/prep: Drop useless CONFIG_KVM ifdefery 2019-07-02 09:43:58 +10:00
prep_systemio.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
rs6000_mc.c hw/ppc: Use the IEC binary prefix definitions 2018-07-02 15:41:16 +02:00
sam460ex.c pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
spapr.c ppc patch queue 2019-06-12 2019-06-12 14:43:47 +01:00
spapr_caps.c qemu-common: Move tcg_enabled() etc. to sysemu/tcg.h 2019-06-11 20:22:09 +02:00
spapr_cpu_core.c target/ppc: Set PSSCR_EC on cpu halt to prevent spurious wakeup 2019-05-29 11:39:45 +10:00
spapr_drc.c spapr: Clean up spapr_drc_populate_dt() 2019-06-12 10:41:49 +10:00
spapr_events.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_hcall.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
spapr_iommu.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
spapr_irq.c xics/spapr: Rename xics_kvm_init() 2019-07-02 09:43:58 +10:00
spapr_ovec.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_pci.c spapr_pci: Unregister listeners before destroying the IOMMU address space 2019-07-02 09:43:58 +10:00
spapr_pci_nvlink2.c spapr: Support NVIDIA V100 GPU with NVLink2 2019-04-26 10:41:23 +10:00
spapr_pci_vfio.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
spapr_rng.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
spapr_rtas.c target/ppc: Set PSSCR_EC on cpu halt to prevent spurious wakeup 2019-05-29 11:39:45 +10:00
spapr_rtas_ddw.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
spapr_rtc.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
spapr_vio.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
trace-events trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
virtex_ml507.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00