qemu/hw
Igor Mammedov 8aa35bebee cpuhp: make sure that remove events are handled within the same SCI
CPU_SCAN_METHOD was processing insert events first and only if insert event was
not present then it would check remove event.

Normally it's not an issue as it doesn't make much sense tho hotplug and
immediately unplug it. In this corner case, which can be reproduced with:

   qemu -smp 1,maxcpus=2 -cpu host -monitor stdio \
        -drive if=pflash,format=raw,readonly,file=edk2-x86_64-code.fd

   * boot till GRUB prompt and pause guest (either via monitor or stop GRUB
     from automatic boot)
   * at monitor prompt add CPU:
         device_add host-x86_64-cpu,socket-id=0,core-id=1,thread-id=0,id=foo
   * let guest OS boot completely, and unplug CPU from monitor prompt:
         device_del foo
     which triggers GPE event that leads to CPU_SCAN_METHOD on guest side

as result of above cpu 'foo' will not be hotunplugged, since QEMU sees
insert event and ignores remove event (leaving it in pending state) for
the GPE event.

Any follow up CPU hotplug/unplug action from QEMU side will handle
previously ignored event, so as workaround user can repeat device_del.

Fix this corner-case by queuing remove events independently from insert
events, aka the same way as we do with insert events. And then go over remove
queue to send eject notify events to OSPM within the same GPE event.

PS:
Process remove queue after the cpu add queue has been processed 1st
to ensure that OSPM gets hotadd evets after hotremove ones.

PS2:
Case where it's still borken happens when guest OS is Linux and
device_del happens before guest OS initializes ACPI subsystem.
Culprit in this case though is the guest kernel, which mangles GPE.sts
(by clearing them up) and thus pending SCI turns to NOP leaving
insert/remove events in pending state.
That is the guest bug and should be fixed there.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reported-by: Eric Mackay <eric.mackay@oracle.com>
Message-Id: <20241210163945.3422623-3-imammedo@redhat.com>
Tested-by: Eric Mackay <eric.mackay@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2025-01-15 13:05:41 -05:00
..
9pfs Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
acpi cpuhp: make sure that remove events are handled within the same SCI 2025-01-15 13:05:41 -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: Replace DEVICE(object_new) -> qdev_new() 2025-01-13 17:06:35 +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 hw/char/imx_serial: Turn some DPRINTF() statements into trace events 2025-01-13 17:16:04 +01:00
core hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_common 2025-01-13 17:16:03 +01: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 virtio-gpu: Add definition for resource_uuid feature 2025-01-15 13:05:26 -05: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 hw/gpio/imx_gpio: Turn DPRINTF() into trace events 2025-01-13 17:16:04 +01:00
hppa hw/hppa: Reset vCPUs calling resettable_reset() 2025-01-13 17:16:04 +01:00
hyperv Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
i2c hw/i2c/imx_i2c: Convert DPRINTF() to trace events 2025-01-13 17:16:04 +01:00
i386 QOM & QDev patches 2025-01-10 10:30:51 -05: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/microblaze: Restrict MemoryRegionOps are implemented as 32-bit 2025-01-13 17:16:03 +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/loongarch/virt: Checkpatch cleanup 2025-01-13 17:16:04 +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/imx6_src: Convert DPRINTF() to trace events 2025-01-13 17:16:04 +01:00
net hw/net/xilinx_ethlite: Map RESERVED I/O as unimplemented 2025-01-13 17:16:04 +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 pci: ensure valid link status bits for downstream ports 2025-01-15 13:05:33 -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 s390x: Fix CSS migration 2025-01-09 17:40:03 -03:00
scsi Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
sd hw/sd/sdhci: Factor sdhci_sdma_transfer() out 2025-01-13 17:16:04 +01: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: Replace DEVICE(object_new) -> qdev_new() 2025-01-13 17:06:35 +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/imx_gpt: Remove unused define 2025-01-13 17:16:04 +01:00
tpm Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
tricore hw/tricore/triboard: Remove unnecessary use of &first_cpu 2025-01-13 17:21:46 +01:00
ufs hw/ufs: Adjust value to match CPU's endian format 2025-01-13 17:16:04 +01:00
usb hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported 2025-01-13 17:21:46 +01:00
vfio hw/pci: Use -1 as the default value for rombar 2025-01-09 18:16:18 +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