On 19/08/2026 15:56, Philippe Mathieu-Daudé wrote:
Hi Phil,
No objections to the idea of the patch, however I do have a couple of
questions:
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().
Can you explain exactly what you mean by async events here in the
context of TCG? Looking at the thread indicated below suggests this is
terminology borrowed from KVM with which I am less familiar.
* transition_halt_to_exec(): Perform target-specific state updates
when transitioning from halt to execution.
That's quite a name :) Would something like cpu_exec_resume() be more
descriptive here (as well as keeping the cpu_exec_ prefix used by other
callbacks)?
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://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_qemu-2Ddevel_CABgObfaDAhrpnVqQaKgG6uxPQe1YDu77YOsUEx9nqrN-3D3M2cGw-40mail.gmail.com_&d=DwIDaQ&c=s883GpUCOChKOHiocYtGcg&r=c23RpsaH4D2MKyD3EPJTDa0BAxz6tV8aUJqVSoytEiY&m=sBca7couYmrH5p0nURqPPrh51jIPm0xJ4Tk5aHPSTzVFUbwS1-pc6webrznl259Y&s=eDmByvd3KnM-OoPHj78lDNqJAdxt6w0rKnaJOuyWJbM&e=
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(-)
ATB,
Mark.