Revision | b655dc7cd91588a77c3df6f618246fd88ad14249 (tree) |
---|---|
Time | 2022-01-21 14:52:57 |
Author | LIU Zhiwei <zhiwei_liu@c-sk...> |
Commiter | Alistair Francis |
target/riscv: Don't save pc when exception return
As pc will be written by the xepc in exception return, just ignore
pc in translation.
Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20220120122050.41546-3-zhiwei_liu@c-sky.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
@@ -100,8 +100,8 @@ DEF_HELPER_2(csrr_i128, tl, env, int) | ||
100 | 100 | DEF_HELPER_4(csrw_i128, void, env, int, tl, tl) |
101 | 101 | DEF_HELPER_6(csrrw_i128, tl, env, int, tl, tl, tl, tl) |
102 | 102 | #ifndef CONFIG_USER_ONLY |
103 | -DEF_HELPER_2(sret, tl, env, tl) | |
104 | -DEF_HELPER_2(mret, tl, env, tl) | |
103 | +DEF_HELPER_1(sret, tl, env) | |
104 | +DEF_HELPER_1(mret, tl, env) | |
105 | 105 | DEF_HELPER_1(wfi, void, env) |
106 | 106 | DEF_HELPER_1(tlb_flush, void, env) |
107 | 107 | #endif |
@@ -74,10 +74,8 @@ static bool trans_uret(DisasContext *ctx, arg_uret *a) | ||
74 | 74 | static bool trans_sret(DisasContext *ctx, arg_sret *a) |
75 | 75 | { |
76 | 76 | #ifndef CONFIG_USER_ONLY |
77 | - tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); | |
78 | - | |
79 | 77 | if (has_ext(ctx, RVS)) { |
80 | - gen_helper_sret(cpu_pc, cpu_env, cpu_pc); | |
78 | + gen_helper_sret(cpu_pc, cpu_env); | |
81 | 79 | tcg_gen_exit_tb(NULL, 0); /* no chaining */ |
82 | 80 | ctx->base.is_jmp = DISAS_NORETURN; |
83 | 81 | } else { |
@@ -92,8 +90,7 @@ static bool trans_sret(DisasContext *ctx, arg_sret *a) | ||
92 | 90 | static bool trans_mret(DisasContext *ctx, arg_mret *a) |
93 | 91 | { |
94 | 92 | #ifndef CONFIG_USER_ONLY |
95 | - tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); | |
96 | - gen_helper_mret(cpu_pc, cpu_env, cpu_pc); | |
93 | + gen_helper_mret(cpu_pc, cpu_env); | |
97 | 94 | tcg_gen_exit_tb(NULL, 0); /* no chaining */ |
98 | 95 | ctx->base.is_jmp = DISAS_NORETURN; |
99 | 96 | return true; |
@@ -115,7 +115,7 @@ target_ulong helper_csrrw_i128(CPURISCVState *env, int csr, | ||
115 | 115 | |
116 | 116 | #ifndef CONFIG_USER_ONLY |
117 | 117 | |
118 | -target_ulong helper_sret(CPURISCVState *env, target_ulong cpu_pc_deb) | |
118 | +target_ulong helper_sret(CPURISCVState *env) | |
119 | 119 | { |
120 | 120 | uint64_t mstatus; |
121 | 121 | target_ulong prev_priv, prev_virt; |
@@ -176,7 +176,7 @@ target_ulong helper_sret(CPURISCVState *env, target_ulong cpu_pc_deb) | ||
176 | 176 | return retpc; |
177 | 177 | } |
178 | 178 | |
179 | -target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb) | |
179 | +target_ulong helper_mret(CPURISCVState *env) | |
180 | 180 | { |
181 | 181 | if (!(env->priv >= PRV_M)) { |
182 | 182 | riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC()); |