[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 59/68] target/nios2: Update helper_eret for shadow registers
From: |
Richard Henderson |
Subject: |
[PULL 59/68] target/nios2: Update helper_eret for shadow registers |
Date: |
Tue, 26 Apr 2022 11:18:58 -0700 |
When CRS = 0, we restore from estatus; otherwise from sstatus.
Update for the new CRS.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220421151735.31996-56-richard.henderson@linaro.org>
---
target/nios2/cpu.h | 1 +
target/nios2/op_helper.c | 10 +++++++---
target/nios2/translate.c | 13 ++++++++-----
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index cca821cf80..eb171a33e6 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -82,6 +82,7 @@ enum {
R_FP = 28,
R_EA = 29,
R_BA = 30,
+ R_SSTATUS = 30,
R_RA = 31,
};
diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c
index a3164f5356..94040102f4 100644
--- a/target/nios2/op_helper.c
+++ b/target/nios2/op_helper.c
@@ -73,14 +73,18 @@ void helper_eret(CPUNios2State *env, uint32_t new_status,
uint32_t new_pc)
}
/*
- * Both estatus and bstatus have no constraints on write;
+ * None of estatus, bstatus, or sstatus have constraints on write;
* do not allow reserved fields in status to be set.
- * TODO: more than this is required for shadow registers.
+ * When shadow registers are enabled, eret *does* restore CRS.
+ * Rather than testing eic_present to decide, mask CRS out of
+ * the set of readonly fields.
*/
- new_status &= cpu->cr_state[CR_STATUS].writable;
+ new_status &= cpu->cr_state[CR_STATUS].writable |
+ (cpu->cr_state[CR_STATUS].readonly & R_CR_STATUS_CRS_MASK);
env->ctrl[CR_STATUS] = new_status;
env->pc = new_pc;
+ nios2_update_crs(env);
cpu_loop_exit(cs);
}
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index e566175db5..b52f98180d 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -496,11 +496,14 @@ static void eret(DisasContext *dc, uint32_t code,
uint32_t flags)
#ifdef CONFIG_USER_ONLY
g_assert_not_reached();
#else
- TCGv tmp = tcg_temp_new();
- tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, ctrl[CR_ESTATUS]));
- gen_helper_eret(cpu_env, tmp, load_gpr(dc, R_EA));
- tcg_temp_free(tmp);
-
+ if (FIELD_EX32(dc->tb_flags, TBFLAGS, CRS0)) {
+ TCGv tmp = tcg_temp_new();
+ tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPUNios2State, ctrl[CR_ESTATUS]));
+ gen_helper_eret(cpu_env, tmp, load_gpr(dc, R_EA));
+ tcg_temp_free(tmp);
+ } else {
+ gen_helper_eret(cpu_env, load_gpr(dc, R_SSTATUS), load_gpr(dc, R_EA));
+ }
dc->base.is_jmp = DISAS_NORETURN;
#endif
}
--
2.34.1
- [PULL 53/68] target/nios2: Hoist set of is_jmp into gen_goto_tb, (continued)
- [PULL 53/68] target/nios2: Hoist set of is_jmp into gen_goto_tb, Richard Henderson, 2022/04/26
- [PULL 41/68] target/nios2: Support division error exception, Richard Henderson, 2022/04/26
- [PULL 42/68] target/nios2: Use tcg_constant_tl, Richard Henderson, 2022/04/26
- [PULL 54/68] target/nios2: Use gen_goto_tb for DISAS_TOO_MANY, Richard Henderson, 2022/04/26
- [PULL 64/68] hw/nios2: Introduce Nios2MachineState, Richard Henderson, 2022/04/26
- [PULL 45/68] target/nios2: Split out helpers for gen_i_math_logic, Richard Henderson, 2022/04/26
- [PULL 50/68] target/nios2: Drop CR_STATUS_EH from tb->flags, Richard Henderson, 2022/04/26
- [PULL 52/68] target/nios2: Create gen_jumpr, Richard Henderson, 2022/04/26
- [PULL 57/68] target/nios2: Introduce shadow register sets, Richard Henderson, 2022/04/26
- [PULL 55/68] target/nios2: Use tcg_gen_lookup_and_goto_ptr, Richard Henderson, 2022/04/26
- [PULL 59/68] target/nios2: Update helper_eret for shadow registers,
Richard Henderson <=
- [PULL 60/68] target/nios2: Implement EIC interrupt processing, Richard Henderson, 2022/04/26
- [PULL 61/68] target/nios2: Advance pc when raising exceptions, Richard Henderson, 2022/04/26
- [PULL 62/68] linux-user/nios2: Handle various SIGILL exceptions, Richard Henderson, 2022/04/26
- [PULL 65/68] hw/nios2: Move memory regions into Nios2Machine, Richard Henderson, 2022/04/26
- [PULL 68/68] tests/tcg/nios2: Add test-shadow-1, Richard Henderson, 2022/04/26
- [PULL 48/68] target/nios2: Split out helpers for gen_rr_shift, Richard Henderson, 2022/04/26
- [PULL 67/68] tests/tcg/nios2: Add semihosting multiarch tests, Richard Henderson, 2022/04/26
- [PULL 47/68] target/nios2: Split out helpers for gen_rr_mul_high, Richard Henderson, 2022/04/26
- [PULL 58/68] target/nios2: Implement rdprs, wrprs, Richard Henderson, 2022/04/26
- [PULL 63/68] hw/intc: Vectored Interrupt Controller (VIC), Richard Henderson, 2022/04/26