Use the shared raise_excp helper for exception_internal and adapt zero-PC C exception exits to cpu_raise_excp(). Preserve ARM-specific exception helpers that carry additional state.
Signed-off-by: Yonggang Luo <[email protected]> --- target/arm/tcg/helper-defs.h | 1 - target/arm/tcg/m_helper.c | 3 ++- target/arm/tcg/op_helper.c | 33 ++++++--------------------------- target/arm/tcg/translate.c | 2 +- 4 files changed, 9 insertions(+), 30 deletions(-) diff --git a/target/arm/tcg/helper-defs.h b/target/arm/tcg/helper-defs.h index 269ac515065..14ef3120373 100644 --- a/target/arm/tcg/helper-defs.h +++ b/target/arm/tcg/helper-defs.h @@ -45,7 +45,6 @@ DEF_HELPER_FLAGS_2(usad8, TCG_CALL_NO_RWG_SE, i32, i32, i32) DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) -DEF_HELPER_2(exception_internal, noreturn, env, i32) DEF_HELPER_3(exception_with_syndrome, noreturn, env, i32, i32) DEF_HELPER_4(exception_with_syndrome_el, noreturn, env, i32, i32, i32) DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32) diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index 65dcf97adef..9c21df772ab 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -18,6 +18,7 @@ #include "exec/page-protection.h" #ifdef CONFIG_TCG #include "accel/tcg/cpu-ldst-common.h" +#include "accel/tcg/cpu-loop.h" #include "semihosting/common-semi.h" #endif #if !defined(CONFIG_USER_ONLY) @@ -575,7 +576,7 @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) */ env->regs[15] = dest & ~1; env->thumb = dest & 1; - HELPER(exception_internal)(env, EXCP_EXCEPTION_EXIT); + cpu_raise_excp(env_cpu(env), EXCP_EXCEPTION_EXIT); /* notreached */ } diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c index af56eff9f18..522c309fa39 100644 --- a/target/arm/tcg/op_helper.c +++ b/target/arm/tcg/op_helper.c @@ -64,10 +64,9 @@ void raise_exception(CPUARMState *env, uint32_t excp, } assert(!excp_is_internal(excp)); - cs->exception_index = excp; env->exception.syndrome = syndrome; env->exception.target_el = target_el; - cpu_loop_exit(cs); + cpu_raise_excp(cs, excp); } void raise_exception_ra(CPUARMState *env, uint32_t excp, uint64_t syndrome, @@ -399,9 +398,8 @@ void HELPER(wfi)(CPUARMState *env, uint32_t insn_len) } qatomic_set(&env->halt_reason, HALT_WFI); - cs->exception_index = EXCP_HLT; cs->halted = 1; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); #endif } @@ -462,9 +460,8 @@ void HELPER(wfit)(CPUARMState *env, uint32_t rd) timer_mod(cpu->wfxt_timer, nexttick); } qatomic_set(&env->halt_reason, HALT_WFI); - cs->exception_index = EXCP_HLT; cs->halted = 1; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); #endif } @@ -631,9 +628,8 @@ void HELPER(wfe)(CPUARMState *env, uint32_t insn_len) } qatomic_set(&env->halt_reason, HALT_WFE); - cs->exception_index = EXCP_HLT; cs->halted = 1; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); #endif } @@ -726,9 +722,8 @@ void HELPER(wfet)(CPUARMState *env, uint32_t rd) } qatomic_set(&env->halt_reason, HALT_WFE); - cs->exception_index = EXCP_HLT; cs->halted = 1; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_HLT); #endif } @@ -740,23 +735,7 @@ void HELPER(yield)(CPUARMState *env) * that the guest is currently busy-looping. Yield control back to the * top level loop so that a more deserving VCPU has a chance to run. */ - cs->exception_index = EXCP_YIELD; - cpu_loop_exit(cs); -} - -/* Raise an internal-to-QEMU exception. This is limited to only - * those EXCP values which are special cases for QEMU to interrupt - * execution and not to be used for exceptions which are passed to - * the guest (those must all have syndrome information and thus should - * use exception_with_syndrome*). - */ -void HELPER(exception_internal)(CPUARMState *env, uint32_t excp) -{ - CPUState *cs = env_cpu(env); - - assert(excp_is_internal(excp)); - cs->exception_index = excp; - cpu_loop_exit(cs); + cpu_raise_excp(cs, EXCP_YIELD); } /* Raise an exception with the specified syndrome register value */ diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 6983153ffc6..ad73813fe53 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -379,7 +379,7 @@ static void gen_rebuild_hflags(DisasContext *s, bool new_el) void gen_exception_internal(int excp) { assert(excp_is_internal(excp)); - gen_helper_exception_internal(tcg_env, tcg_constant_i32(excp)); + gen_helper_raise_excp(tcg_env, tcg_constant_i32(excp)); } static void gen_singlestep_exception(DisasContext *s) -- 2.52.0.windows.1
