xemu/hw/ppc
David Gibson 25c9780d38 spapr: Reset CAS & IRQ subsystem after devices
This fixes a nasty regression in qemu-4.1 for the 'pseries' machine,
caused by the new "dual" interrupt controller model.  Specifically,
qemu can crash when used with KVM if a 'system_reset' is requested
while there's active I/O in the guest.

The problem is that in spapr_machine_reset() we:

1. Reset the CAS vector state
	spapr_ovec_cleanup(spapr->ov5_cas);

2. Reset all devices
	qemu_devices_reset()

3. Reset the irq subsystem
	spapr_irq_reset();

However (1) implicitly changes the interrupt delivery mode, because
whether we're using XICS or XIVE depends on the CAS state.  We don't
properly initialize the new irq mode until (3) though - in particular
setting up the KVM devices.

During (2), we can temporarily drop the BQL allowing some irqs to be
delivered which will go to an irq system that's not properly set up.

Specifically, if the previous guest was in (KVM) XIVE mode, the CAS
reset will put us back in XICS mode.  kvm_kernel_irqchip() still
returns true, because XIVE was using KVM, however XICs doesn't have
its KVM components intialized and kernel_xics_fd == -1.  When the irq
is delivered it goes via ics_kvm_set_irq() which assert()s that
kernel_xics_fd != -1.

This change addresses the problem by delaying the CAS reset until
after the devices reset.  The device reset should quiesce all the
devices so we won't get irqs delivered while we mess around with the
IRQ.  The CAS reset and irq re-initialize should also now be under the
same BQL critical section so nothing else should be able to interrupt
it either.

We also move the spapr_irq_msi_reset() used in one of the legacy irq
modes, since it logically makes sense at the same point as the
spapr_irq_reset() (it's essentially an equivalent operation for older
machine types).  Since we don't need to switch between different
interrupt controllers for those old machine types it shouldn't
actually be broken in those cases though.

Cc: Cédric Le Goater <clg@kaod.org>

Fixes: b2e22477 "spapr: add a 'reset' method to the sPAPR IRQ backend"
Fixes: 13db0cd9 "spapr: introduce a new sPAPR IRQ backend supporting
                 XIVE and XICS"
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-08-13 15:59:21 +10:00
..
e500-ccsr.h ppc: do not use ../ in include files 2013-03-01 13:57:33 +01:00
e500.c hw/ppc: Replace global smp variables with machine smp properties 2019-07-05 17:07:36 -03: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_newworld.c hw/ppc: Replace global smp variables with machine smp properties 2019-07-05 17:07:36 -03:00
mac_oldworld.c hw/ppc: Replace global smp variables with machine smp properties 2019-07-05 17:07:36 -03:00
mac.h macio: move MACIOIDEState type declarations to macio.h 2018-08-30 10:42:18 +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_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
pnv.c hw/ppc: Replace global smp variables with machine smp properties 2019-07-05 17:07:36 -03: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_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
ppc405.h ppc4xx: Export ECB and PLB emulation 2017-09-08 09:30:55 +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
ppc440.h ppc440_uc: Basic emulation of PPC440 DMA controller 2018-07-03 09:56:52 +10:00
ppc_booke.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
ppc.c ppc: Introduce kvmppc_set_reg_tb_offset() helper 2019-07-02 09:43:58 +10: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_systemio.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: Replace global smp variables with machine smp properties 2019-07-05 17:07:36 -03: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_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 spapr/irq: Inform the user when falling back to emulated IC 2019-07-28 11:50:26 +10:00
spapr_ovec.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11: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_pci.c spapr_pci: Unregister listeners before destroying the IOMMU address space 2019-07-02 09:43:58 +10: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_ddw.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
spapr_rtas.c hw/ppc: Replace global smp variables with machine smp properties 2019-07-05 17:07:36 -03:00
spapr_rtc.c qapi: Rename target.json to misc-target.json 2019-07-02 13:37:00 +02:00
spapr_vio.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr.c spapr: Reset CAS & IRQ subsystem after devices 2019-08-13 15:59:21 +10: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