@@ -1,5 +1,5 @@
/* Exceptions */
-DEF_HELPER_2(raise_exception, noreturn, env, i32)
+DEF_HELPER_2(riscv_raise_exception, noreturn, env, i32)
/* Floating Point - rounding mode */
DEF_HELPER_FLAGS_2(set_rounding_mode, TCG_CALL_NO_WG, void, env, i32)
@@ -55,8 +55,7 @@ static bool trans_lpad(DisasContext *ctx, arg_lpad *a)
*/
tcg_gen_st8_i32(tcg_constant_i32(RISCV_EXCP_SW_CHECK_FCFI_TVAL),
tcg_env, offsetof(CPURISCVState, sw_check_code));
- gen_helper_raise_exception(tcg_env,
- tcg_constant_i32(RISCV_EXCP_SW_CHECK));
+ gen_raise_exception(RISCV_EXCP_SW_CHECK);
return true;
}
@@ -68,8 +67,7 @@ static bool trans_lpad(DisasContext *ctx, arg_lpad *a)
tcg_gen_brcondi_tl(TCG_COND_EQ, tmp, a->label, skip);
tcg_gen_st8_i32(tcg_constant_i32(RISCV_EXCP_SW_CHECK_FCFI_TVAL),
tcg_env, offsetof(CPURISCVState, sw_check_code));
- gen_helper_raise_exception(tcg_env,
- tcg_constant_i32(RISCV_EXCP_SW_CHECK));
+ gen_raise_exception(RISCV_EXCP_SW_CHECK);
gen_set_label(skip);
}
@@ -43,8 +43,7 @@ static bool trans_sspopchk(DisasContext *ctx, arg_sspopchk *a)
tcg_gen_brcond_tl(TCG_COND_EQ, data, rs1, skip);
tcg_gen_st8_i32(tcg_constant_i32(RISCV_EXCP_SW_CHECK_BCFI_TVAL),
tcg_env, offsetof(CPURISCVState, sw_check_code));
- gen_helper_raise_exception(tcg_env,
- tcg_constant_i32(RISCV_EXCP_SW_CHECK));
+ gen_raise_exception(RISCV_EXCP_SW_CHECK);
gen_set_label(skip);
tcg_gen_addi_tl(addr, addr, tmp);
tcg_gen_ext_tl_i64(wide_addr, addr);
@@ -47,11 +47,10 @@ G_NORETURN void riscv_raise_exception(CPURISCVState *env,
riscv_cpu_get_trap_name(exception, false),
env->pc);
- cs->exception_index = exception;
- cpu_loop_exit_restore(cs, pc);
+ cpu_loop_exit_excp(cs, exception, pc);
}
-void helper_raise_exception(CPURISCVState *env, uint32_t exception)
+void HELPER(riscv_raise_exception)(CPURISCVState *env, uint32_t exception)
{
#ifndef CONFIG_USER_ONLY
riscv_pmu_decr_instret(env);
@@ -257,10 +257,15 @@ static void gen_update_pc(DisasContext *ctx, target_long diff)
ctx->pc_save = ctx->base.pc_next + diff;
}
+static void gen_raise_exception(uint32_t excp)
+{
+ gen_helper_riscv_raise_exception(tcg_env, tcg_constant_i32(excp));
+}
+
static void generate_exception(DisasContext *ctx, RISCVException excp)
{
gen_update_pc(ctx, 0);
- gen_helper_raise_exception(tcg_env, tcg_constant_i32(excp));
+ gen_raise_exception(excp);
ctx->base.is_jmp = DISAS_NORETURN;
}
@@ -1424,8 +1429,7 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
tcg_ctx->emit_before_op = QTAILQ_NEXT(ctx->base.insn_start, link);
tcg_gen_st8_i32(tcg_constant_i32(RISCV_EXCP_SW_CHECK_FCFI_TVAL),
tcg_env, offsetof(CPURISCVState, sw_check_code));
- gen_helper_raise_exception(tcg_env,
- tcg_constant_i32(RISCV_EXCP_SW_CHECK));
+ gen_raise_exception(RISCV_EXCP_SW_CHECK);
tcg_ctx->emit_before_op = NULL;
ctx->base.is_jmp = DISAS_NORETURN;
}
Prefix leftover TCG raise_exception to riscv_raise_exception so translate still decrements instret then exits with restore 0. Keep C riscv_raise_exception via cpu_loop_exit_excp. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> --- target/riscv/helper.h | 2 +- target/riscv/tcg/insn_trans/trans_rvi.c.inc | 6 ++---- target/riscv/tcg/insn_trans/trans_rvzicfiss.c.inc | 3 +-- target/riscv/tcg/op_helper.c | 5 ++--- target/riscv/tcg/translate.c | 10 +++++++--- 5 files changed, 13 insertions(+), 13 deletions(-)