This series was inspired by a previous thread on the list [*].
Refactor the CPU halt-to-execution transition logic in TCG as
something more explicit and composable.
Core problem: TCGCPUOps::cpu_exec_halt callback mixed concerns,
it checked for work, processed async events, and handled state
transitions all in one place.
Solution: introduces two dedicated callbacks:
* process_async_events(): Process target-specific async events
before checking for work. Called early in cpu_exec().
* transition_halt_to_exec(): Perform target-specific state updates
when transitioning from halt to execution.
This separation allows the generic cpu_exec() code to orchestrate
the flow cleanly (process events, check for work, transition state).
Only 2 targets need to be migrated (x86 and ARM) then we can remove
the redundant cpu_exec_halt() hook.
The changes are expected to be purely refactoring with no functional
impact.
Series structure:
Patches 1-2: Preparatory refactoring and guard additions
Patch 3: Introduce the new hooks and orchestration logic
Patch 4: Refactor cpu_exec() flow to use new infrastructure
Patches 5-7: x86 extraction and conversion
Patches 8-9: ARM extraction and conversion
Patch 10: Remove the now-redundant cpu_exec_halt hook
Testing: CI test suite
[*]
https://lore.kernel.org/qemu-devel/CABgObfaDAhrpnVqQaKgG6uxPQe1YDu77YOsUEx9nqrN=3m2...@mail.gmail.com/
Philippe Mathieu-Daudé (11):
accel/tcg: Rename for exception codes named @ret as @excp
accel/tcg: Restrict EXCP_HALTED handling to system emulation
accel/tcg: Check %halted field in cpu_handle_halt() caller
accel/tcg: Refactor halt-to-execution flow in cpu_exec()
accel/tcg: Introduce .process_async_events and
.transition_halt_to_exec
target/arm: Extract halt-to-exec transition out of arm_cpu_exec_halt()
target/arm: Convert cpu_exec_halt() to transition_halt_to_exec()
target/i386: Extract async event processing out of x86_cpu_exec_halt()
target/i386: Extract halt-to-exec transition out of
x86_cpu_exec_halt()
target/i386: Convert cpu_exec_halt() to transition_halt_to_exec()
accel/tcg: Remove the now redundant cpu_exec_halt() hook
include/accel/tcg/cpu-ops.h | 30 +++++++-------
target/arm/internals.h | 3 --
target/i386/tcg/helper-tcg.h | 3 +-
accel/tcg/cpu-exec.c | 63 ++++++++++++++++-------------
accel/tcg/tcg-accel-ops-mttcg.c | 7 ++--
accel/tcg/tcg-accel-ops-rr.c | 8 ++--
accel/tcg/tcg-accel-ops.c | 7 ++--
target/alpha/cpu.c | 1 -
target/arm/cpu.c | 22 +++++-----
target/arm/tcg/cpu-v7m.c | 1 -
target/avr/cpu.c | 1 -
target/hexagon/cpu.c | 1 -
target/hppa/cpu.c | 1 -
target/i386/tcg/system/seg_helper.c | 14 ++++---
target/i386/tcg/tcg-cpu.c | 3 +-
target/loongarch/tcg/tcg_cpu.c | 1 -
target/m68k/cpu.c | 1 -
target/microblaze/cpu.c | 1 -
target/mips/cpu.c | 1 -
target/or1k/cpu.c | 1 -
target/ppc/cpu_init.c | 1 -
target/riscv/tcg/tcg-cpu.c | 1 -
target/rx/cpu.c | 1 -
target/s390x/cpu.c | 1 -
target/sh4/cpu.c | 1 -
target/sparc/cpu.c | 1 -
target/tricore/cpu.c | 1 -
target/xtensa/cpu.c | 1 -
28 files changed, 84 insertions(+), 94 deletions(-)
--
2.53.0