target/nios2: Update helper_eret for shadow registers

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>
This commit is contained in:
Richard Henderson 2022-04-21 08:17:26 -07:00
parent 3a03087019
commit 6bcc59cafa
3 changed files with 16 additions and 8 deletions

View file

@ -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);
}