qemu/include/hw
yaozhenguo 963b027645 virtio/vhost-user: fix qemu abort when hotunplug vhost-user-net device
During the hot-unplugging of vhost-user-net type network cards,
the vhost_user_cleanup function may add the same rcu node to
the rcu linked list. The function call in this case is as follows:

vhost_user_cleanup
    ->vhost_user_host_notifier_remove
        ->call_rcu(n, vhost_user_host_notifier_free, rcu);
    ->g_free_rcu(n, rcu);

When this happens, QEMU will abort in try_dequeue:

if (head == &dummy && qatomic_mb_read(&tail) == &dummy.next) {
    abort();
}

backtrace is as follows:
0  __pthread_kill_implementation () at /usr/lib64/libc.so.6
1  raise () at /usr/lib64/libc.so.6
2  abort () at /usr/lib64/libc.so.6
3  try_dequeue () at ../util/rcu.c:235
4  call_rcu_thread (0) at ../util/rcu.c:288
5  qemu_thread_start (0) at ../util/qemu-thread-posix.c:541
6  start_thread () at /usr/lib64/libc.so.6
7  clone3 () at /usr/lib64/libc.so.6

The reason for the abort is that adding two identical nodes to
the rcu linked list will cause the rcu linked list to become a ring,
but when the dummy node is added after the two identical nodes,
the ring is opened. But only one node is added to list with
rcu_call_count added twice. This will cause rcu try_dequeue abort.

This happens when n->addr != 0. In some scenarios, this does happen.
For example, this situation will occur when using a 32-queue DPU
vhost-user-net type network card for hot-unplug testing, because
VhostUserHostNotifier->addr will be cleared during the processing of
VHOST_USER_BACKEND_VRING_HOST_NOTIFIER_MSG. However,it is asynchronous,
so we cannot guarantee that VhostUserHostNotifier->addr is zero in
vhost_user_cleanup. Therefore, it is necessary to merge g_free_rcu
and vhost_user_host_notifier_free into one rcu node.

Fixes: 503e355465 ("virtio/vhost-user: dynamically assign VhostUserHostNotifiers")
Signed-off-by: yaozhenguo <yaozhenguo@jd.com>
Message-Id: <20241011102913.45582-1-yaozhenguo@jd.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2024-11-04 16:03:24 -05:00
..
acpi hw/acpi: Make storage of node id uint32_t to reduce fragility 2024-11-04 16:03:24 -05:00
adc hw/adc: Remove MAX111X device 2024-10-15 15:16:17 +01:00
arm hw/intc/omap_intc: Remove now-unnecessary abstract base class 2024-10-15 15:16:17 +01:00
audio virtio-snd: rewrite invalid tx/rx message handling 2024-04-09 02:31:16 -04:00
block hw/block: Remove ecc 2024-10-15 15:16:17 +01:00
char hw/char: sifive_uart: Print uart characters async 2024-10-30 11:22:08 +10:00
core include: Move QemuLockCnt APIs to their own header 2024-10-15 15:16:17 +01:00
cpu
cxl hw/mem/cxl-type3: Add properties to control link speed and width 2024-11-04 16:03:24 -05:00
display hw/display: Remove Blizzard display device 2024-10-01 14:40:29 +01:00
dma
firmware hw/smbios: Remove 'uuid_encoded' argument from smbios_set_defaults() 2024-06-19 12:40:49 +02:00
fsi
gpio hw/gpio/aspeed: Support different memory region ops 2024-10-24 07:57:47 +02:00
hyperv vmbus: Print a warning when enabled without the recommended set of features 2024-03-08 14:18:56 +01:00
i2c hw/i2c/aspeed: Add support for Tx/Rx buffer 64 bit addresses 2024-09-16 17:44:08 +02:00
i386 hw: add compat machines for 9.2 2024-09-05 13:12:36 +01:00
ide ide, vl: turn -win2k-hack into a property on IDE devices 2024-02-28 00:23:39 +01:00
input hw/input: Remove lm832x device 2024-10-01 14:41:10 +01:00
intc hw/intc/loongarch_ipi: Add loongarch IPI support 2024-08-06 10:22:52 +02:00
ipack
ipmi
isa
loongarch hw/loongarch/virt: Remove unnecessary 'cpu.h' inclusion 2024-10-16 16:03:13 +08:00
m68k
mem hw/mem/memory-device: Remove legacy_align from memory_device_pre_plug() 2024-06-19 12:40:49 +02:00
mips hw/mips/cps: Set the vCPU 'cpu-big-endian' property 2024-10-15 12:21:06 -03:00
misc hw/misc/aspeed_hace: Fix SG Accumulative hashing 2024-10-24 07:57:47 +02:00
net hw/net:ftgmac100: introduce TX and RX ring base address high registers to support 64 bits 2024-07-09 08:05:44 +02:00
nubus
nvram hw: Remove unused fw_cfg_init_io 2024-10-03 17:26:06 +03:00
openrisc
pci virtio-pci: fix memory_region_find for VirtIOPCIRegion's MR 2024-11-04 16:03:24 -05:00
pci-bridge hw/pci-bridge/cxl-upstream: Add properties to control link speed and width 2024-11-04 16:03:24 -05:00
pci-host q35: Remove unused mch_mcfg_base 2024-10-03 17:26:05 +03:00
ppc mac_dbdma: Remove leftover dma_memory_unmap calls 2024-09-18 09:31:56 +01:00
remote remote: Remove unused remote_iohub_finalize 2024-10-03 17:26:06 +03:00
riscv hw/riscv: add RISC-V IOMMU base emulation 2024-10-31 13:51:24 +10:00
rtc hw/i386: move rtc-reset-reinjection command out of hw/rtc 2024-05-10 15:45:15 +02:00
rx
s390x s390x: Rebuild IPLB for SCSI device directly from DIAG308 2024-10-23 06:53:44 +02:00
scsi
sd hw/sd/omap_mmc: Don't use sd_cmd_type_t 2024-10-29 15:04:46 +00:00
sensor
sh4 hw/sh4: Remove sh7750_register_io_device() helper 2024-09-13 20:10:49 +02:00
southbridge hw/acpi/ich9: Add periodic and swsmi timer 2024-09-11 09:46:14 -04:00
sparc
ssi aspeed/smc: Fix write incorrect data into flash in user mode 2024-10-24 07:57:47 +02:00
timer
tricore
usb hw/usb: Remove MUSB USB host controller 2024-10-01 14:43:02 +01:00
vfio vfio/common: Allow disabling device dirty page tracking 2024-07-23 17:14:53 +02:00
virtio virtio/vhost-user: fix qemu abort when hotunplug vhost-user-net device 2024-11-04 16:03:24 -05:00
watchdog aspeed/wdt: Add AST2700 support 2024-06-16 21:08:54 +02:00
xen hw/xen: xenpvh: Disable buffered IOREQs for ARM 2024-10-03 19:37:35 +02:00
xtensa
boards.h reset: Use ResetType for qemu_devices_reset() and MachineClass::reset() 2024-09-24 11:33:34 +02:00
clock.h hw/clock: Let clock_set_mul_div() return a boolean value 2024-03-26 14:24:06 +01:00
elf_ops.h.inc hw/elf_ops: Rename elf_ops.h -> elf_ops.h.inc 2024-04-25 12:48:12 +02:00
fw-path-provider.h
hotplug.h
hw.h
irq.h hw: Move declaration of IRQState to header and add init function 2024-09-11 07:20:30 -04:00
loader-fit.h
loader.h loader: remove load_image_gzipped function as its not used anywhere 2024-07-16 20:04:08 +02:00
nmi.h
or-irq.h
platform-bus.h
ptimer.h
qdev-clock.h
qdev-core.h qapi: introduce device-sync-config 2024-11-04 16:03:24 -05:00
qdev-dma.h
qdev-properties-system.h qapi/machine: Rename CpuS390* to S390Cpu*, and drop 'prefix' 2024-09-10 13:22:47 +02:00
qdev-properties.h
register.h
registerfields.h
resettable.h reset: Add RESET_TYPE_WAKEUP 2024-09-24 11:33:35 +02:00
stream.h
sysbus.h hw/sysbus: Remove unused sysbus_mmio_unmap 2024-09-20 10:01:40 +03:00
usb.h
vmstate-if.h