qemu/hw
David Woodhouse 981780cdda hw/i386/pc: Fix level interrupt sharing for Xen event channel GSI
The system GSIs are not designed for sharing. One device might assert a
shared interrupt with qemu_set_irq() and another might deassert it, and
the level from the first device is lost.

This could be solved by refactoring the x86 GSI code to use an OrIrq
device, but that still wouldn't be ideal.

The best answer would be to have a 'resample' callback which is invoked
when the interrupt is acked at the interrupt controller, and causes the
devices to re-trigger the interrupt if it should still be pending. This
is the model that VFIO in Linux uses, with a 'resampler' eventfd that
actually unmasks the interrupt on the hardware device and thus triggers
a new interrupt from it if needed.

As things stand, QEMU currently doesn't use that VFIO interface
correctly, and just bashes on the resampler for every MMIO access to the
device "just in case". Which requires unmapping and trapping the MMIO
while an interrupt is pending!

For the Xen callback GSI, QEMU does something similar — a flag is set
which triggers a poll on *every* vmexst to see if the GSI should be
deasserted.

Proper resampler support would solve all of that, but is a task for
later which has already been on the TODO list for a while.

Since the Xen event channel GSI support *already* has hooks into the PC
gsi_handler() code for routing GSIs to PIRQs, we can use that for a
simpler bug fix.

So... remember the externally-driven state of the line (from e.g. PCI
INTx) and set the logical OR of that with the GSI. As a bonus, we now
only need to enable the polling of vcpu_info on vmexit if the Xen
callback GSI is the *only* reason the corresponding line is asserted.

Closes: https://gitlab.com/qemu-project/qemu/-/issues/2731
Fixes: ddf0fd9ae1 ("hw/xen: Support HVM_PARAM_CALLBACK_TYPE_GSI callback")
Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
2025-01-09 10:40:11 +00:00
..
9pfs Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
acpi Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
adc include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
alpha alpha: switch boards to "default y" 2024-05-03 15:47:47 +02:00
arm hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
audio Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
avr Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
block hw/block/virtio-blk: Replaces request free function with g_free 2024-12-31 21:21:34 +01:00
char Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
core Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
cpu Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
cxl Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
display hw/display/qxl: Do not use C99 // comments 2024-12-31 21:21:34 +01:00
dma Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
fsi hw: Use device_class_set_legacy_reset() instead of opencoding 2024-09-13 15:31:44 +01:00
gpio Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
hppa include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
hyperv Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
i2c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
i386 hw/i386/pc: Fix level interrupt sharing for Xen event channel GSI 2025-01-09 10:40:11 +00:00
ide Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
input Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
intc hw/s390x: Remove the "adapter_routes_max_batch" property from the flic 2025-01-07 14:51:39 +01:00
ipack include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
ipmi Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
isa Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
loongarch hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
m68k next-cube: add my copyright to the top of the file 2024-12-29 07:13:47 +01:00
mem Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
microblaze hw/microblaze: Propagate CPU endianness to microblaze_load_kernel() 2024-12-31 21:21:34 +01:00
mips hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
misc hw/misc/vmcoreinfo: Rename opaque pointer as 'opaque' 2024-12-31 21:21:34 +01:00
net hw/net/xilinx_ethlite: Rename rxbuf -> port_index 2024-12-31 21:21:34 +01:00
nubus include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
nvme Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
nvram fw_cfg: Don't set callback_opaque NULL in fw_cfg_modify_bytes_read() 2024-12-31 21:21:34 +01:00
openrisc hw/openrisc: Mark devices as big-endian 2024-12-31 21:21:34 +01:00
pci Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
pci-bridge Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
pci-host hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
ppc Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
remote Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
riscv hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
rtc Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
rx Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
s390x hw/s390x: Remove the "adapter_routes_max_batch" property from the flic 2025-01-07 14:51:39 +01:00
scsi Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
sd Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
sensor hw/sensor: Replace type_register() with type_register_static() 2024-12-10 18:49:25 +01:00
sh4 include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
smbios include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
sparc hw/sparc: Mark devices as big-endian 2024-12-31 21:21:34 +01:00
sparc64 hw/sparc: Mark devices as big-endian 2024-12-31 21:21:34 +01:00
ssi Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
timer hw/timer/hpet: Fix comment about capabilities register 2024-12-28 14:42:52 +03:00
tpm Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
tricore hw/tricore: Mark devices as little-endian 2024-12-31 21:21:34 +01:00
ufs Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
usb hw/usb/hcd-xhci: Unimplemented/guest error logging for port MMIO 2024-12-31 21:21:34 +01:00
vfio vfio/migration: Rename vfio_devices_all_dirty_tracking() 2024-12-26 07:23:38 +01:00
virtio qmp: update vhost-user protocol feature maps 2024-12-28 14:42:53 +03:00
watchdog Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
xen hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
xenpv include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
xtensa hw/pci-host/gpex: Allow more than 4 legacy IRQs 2024-12-30 20:04:50 +01:00
Kconfig hw: Remove PCMCIA subsystem 2024-10-15 15:16:17 +01:00
meson.build hw: Remove PCMCIA subsystem 2024-10-15 15:16:17 +01:00