qemu-cr16/system
Paolo Bonzini 9a191d3782 cpus: clear exit_request in qemu_process_cpu_events
Make the code common to all accelerators: after seeing cpu->exit_request
set to true, accelerator code needs to reach qemu_process_cpu_events_common().

So for the common cases where they use qemu_process_cpu_events(), go ahead and
clear it in there.  Note that the cheap qatomic_set() is enough because
at this point the thread has taken the BQL; qatomic_set_mb() is not needed.
In particular, this is the ordering of the communication between
I/O and vCPU threads is always the same.

In the I/O thread:

(a) store other memory locations that will be checked if cpu->exit_request
    or cpu->interrupt_request is 1 (for example cpu->stop or cpu->work_list
    for cpu->exit_request)

(b) cpu_exit(): store-release cpu->exit_request, or
(b) cpu_interrupt(): store-release cpu->interrupt_request

>>> at this point, cpu->halt_cond is broadcast and the BQL released

(c) do the accelerator-specific kick (e.g. write icount_decr for TCG,
    pthread_kill for KVM, etc.)

In the vCPU thread instead the opposite order is respected:

(c) the accelerator's execution loop exits thanks to the kick

(b) then the inner execution loop checks cpu->interrupt_request
    and cpu->exit_request.  If needed cpu->interrupt_request is
    converted into cpu->exit_request when work is needed outside
    the execution loop.

(a) then the other memory locations are checked.  Some may need to
    be read under the BQL, but the vCPU thread may also take other
    locks (e.g. for queued work items) or none at all.

qatomic_set_mb() would only be needed if the halt sleep was done
outside the BQL (though in that case, cpu->exit_request probably
would be replaced by a QemuEvent or something like that).

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-09-17 19:00:56 +02:00
..
arch_init.c system: Replace arch_type global by qemu_arch_available() helper 2025-03-11 20:03:26 +01:00
async-teardown.c qemu/osdep: Add excluded fd parameter to qemu_close_all_open_fd() 2024-08-05 08:21:59 +10:00
balloon.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
bootdevice.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpu-timers.c cpus: properly kick CPUs out of inner execution loop 2025-09-17 19:00:55 +02:00
cpus.c cpus: clear exit_request in qemu_process_cpu_events 2025-09-17 19:00:56 +02:00
datadir.c pc-bios: Move device tree files in their own subdir 2025-04-25 17:09:58 +02:00
device_tree-stub.c hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error 2025-02-25 15:32:57 +00:00
device_tree.c hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error 2025-02-25 15:32:57 +00:00
dirtylimit.c Miscellaneous patches for 2025-04-24 2025-04-24 13:44:57 -04:00
dma-helpers.c include/exec: Split out icount.h 2025-04-23 14:08:44 -07:00
globals-target.c system: Extract target-specific globals to their own compilation unit 2025-03-11 20:03:26 +01:00
globals.c accel/tcg: Restrict 'icount_align_option' global to TCG 2025-03-06 15:46:17 +01:00
ioport.c include/system: Move exec/ioport.h to system/ioport.h 2025-04-23 14:08:21 -07:00
main.c system/main: comment lock rationale 2025-05-28 08:07:59 +01:00
memory-internal.h system/memory: Remove DEVICE_HOST_ENDIAN definition 2025-04-25 17:09:58 +02:00
memory.c memory: Fix leaks due to owner-shared MRs circular references 2025-09-15 12:00:12 -04:00
memory_ldst.c.inc memory: pass MemTxAttrs to memory_access_is_direct() 2025-02-12 11:33:05 -05:00
memory_mapping.c include/system: Move exec/address-spaces.h to system/address-spaces.h 2025-04-23 14:08:21 -07:00
meson.build ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd 2025-06-23 16:03:59 -04:00
physmem.c memory: Fix addr/len for flatview_access_allowed() 2025-09-15 12:00:12 -04:00
qdev-monitor.c system/qdev: Remove pointless NULL check in qdev_device_add_from_qdict 2025-07-10 16:18:43 +01:00
qemu-seccomp.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
qtest.c qemu: Convert target_words_bigendian() to TargetInfo API 2025-07-15 02:56:39 -04:00
ram-block-attributes.c ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd 2025-06-23 16:03:59 -04:00
rtc.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
runstate-action.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
runstate-hmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
runstate.c Accelerators patches 2025-07-16 07:13:40 -04:00
tpm-hmp-cmds.c
tpm.c tpm: "qemu -tpmdev help" should return success 2025-07-15 10:22:33 +04:00
trace-events ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd 2025-06-23 16:03:59 -04:00
trace.h
vl.c hw/nvram/fw_cfg: Remove legacy FW_CFG_ORDER_OVERRIDE 2025-05-30 09:52:08 +02:00
watchpoint.c include/exec: Split out watchpoint.h 2025-04-23 14:08:36 -07:00