From: Yongbok Kim <yongbok....@imgtec.com> Fix ERET/ERETNC can cause ADEL exception
Signed-off-by: Yongbok Kim <yongbok....@mips.com> --- target/mips/op_helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index 6f5e5a3..09ec20a 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -2434,6 +2434,13 @@ static void set_pc(CPUMIPSState *env, target_ulong error_pc) env->active_tc.PC = error_pc & ~(target_ulong)1; if (env->insn_flags & ISA_NANOMIPS32) { /* Don't clear MIPS_HFLAG_M16 */ + if (error_pc & 1) { + if (!(env->hflags & MIPS_HFLAG_DM)) { + env->CP0_BadVAddr = error_pc; + } + env->active_tc.PC = error_pc; + do_raise_exception(env, EXCP_AdEL, 0); + } return; } if (error_pc & 1) { @@ -2471,10 +2478,12 @@ void helper_eretnc(CPUMIPSState *env) void helper_deret(CPUMIPSState *env) { debug_pre_eret(env); - set_pc(env, env->CP0_DEPC); env->hflags &= ~MIPS_HFLAG_DM; compute_hflags(env); + + set_pc(env, env->CP0_DEPC); + debug_post_eret(env); } #endif /* !CONFIG_USER_ONLY */ -- 1.9.1