Add two TCG helpers next to cpu_loop_exit_excp. raise_excp exits with host_pc 0. raise_excp_restore exits with GETPC(). Declare both with DEF_HELPER in cpu-exec-common.h.
Signed-off-by: Yonggang Luo <[email protected]> --- accel/tcg/cpu-exec-common.c | 12 ++++++++++++ accel/tcg/cpu-exec-common.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index 31fed8e497f..d6277b7d917 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -124,6 +124,18 @@ void cpu_loop_exit_excp(CPUState *cpu, int exception_index, uintptr_t pc) cpu_loop_exit_restore(cpu, pc); } +/* Raise exception and exit the TB without restoring guest state. */ +void HELPER(raise_excp)(CPUArchState *env, uint32_t exception) +{ + cpu_loop_exit_excp(env_cpu(env), exception, 0); +} + +/* Raise exception and exit the TB, restoring state from GETPC(). */ +void HELPER(raise_excp_restore)(CPUArchState *env, uint32_t exception) +{ + cpu_loop_exit_excp(env_cpu(env), exception, GETPC()); +} + void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc) { /* Prevent looping if already executing in a serial context. */ diff --git a/accel/tcg/cpu-exec-common.h b/accel/tcg/cpu-exec-common.h index 19359a97bae..1e82f3b14d3 100644 --- a/accel/tcg/cpu-exec-common.h +++ b/accel/tcg/cpu-exec-common.h @@ -1,2 +1,4 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) +DEF_HELPER_FLAGS_2(raise_excp, TCG_CALL_NO_WG, noreturn, env, i32) +DEF_HELPER_FLAGS_2(raise_excp_restore, TCG_CALL_NO_WG, noreturn, env, i32) -- 2.52.0.windows.1
