[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/68] target/nios2: Split out helper for eret instruction
From: |
Richard Henderson |
Subject: |
[PULL 17/68] target/nios2: Split out helper for eret instruction |
Date: |
Tue, 26 Apr 2022 11:18:16 -0700 |
From: Amir Gonnen <amir.gonnen@neuroblade.ai>
The implementation of eret will become much more complex
with the introduction of shadow registers.
[rth: Split out of a larger patch for shadow register sets.
Directly exit to the cpu loop from the helper.]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Amir Gonnen <amir.gonnen@neuroblade.ai>
Message-Id: <20220303153906.2024748-3-amir.gonnen@neuroblade.ai>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220421151735.31996-18-richard.henderson@linaro.org>
---
target/nios2/helper.h | 1 +
target/nios2/op_helper.c | 9 +++++++++
target/nios2/translate.c | 10 ++++++----
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/target/nios2/helper.h b/target/nios2/helper.h
index a44ecfdf7a..525b6b685b 100644
--- a/target/nios2/helper.h
+++ b/target/nios2/helper.h
@@ -21,6 +21,7 @@
DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32)
#if !defined(CONFIG_USER_ONLY)
+DEF_HELPER_3(eret, noreturn, env, i32, i32)
DEF_HELPER_2(mmu_write_tlbacc, void, env, i32)
DEF_HELPER_2(mmu_write_tlbmisc, void, env, i32)
DEF_HELPER_2(mmu_write_pteaddr, void, env, i32)
diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c
index caa885f7b4..ee5ad8b23f 100644
--- a/target/nios2/op_helper.c
+++ b/target/nios2/op_helper.c
@@ -30,3 +30,12 @@ void helper_raise_exception(CPUNios2State *env, uint32_t
index)
cs->exception_index = index;
cpu_loop_exit(cs);
}
+
+#ifndef CONFIG_USER_ONLY
+void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc)
+{
+ env->regs[CR_STATUS] = new_status;
+ env->pc = new_pc;
+ cpu_loop_exit(env_cpu(env));
+}
+#endif /* !CONFIG_USER_ONLY */
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index 226bd9e30b..53699ee088 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -391,10 +391,12 @@ static void eret(DisasContext *dc, uint32_t code,
uint32_t flags)
return;
}
- tcg_gen_mov_tl(cpu_R[CR_STATUS], cpu_R[CR_ESTATUS]);
- tcg_gen_mov_tl(cpu_pc, cpu_R[R_EA]);
-
- dc->base.is_jmp = DISAS_JUMP;
+#ifdef CONFIG_USER_ONLY
+ g_assert_not_reached();
+#else
+ gen_helper_eret(cpu_env, cpu_R[CR_ESTATUS], cpu_R[R_EA]);
+ dc->base.is_jmp = DISAS_NORETURN;
+#endif
}
/* PC <- ra */
--
2.34.1
- [PULL 01/68] linux-user/nios2: Hoist pc advance to the top of EXCP_TRAP, (continued)
- [PULL 01/68] linux-user/nios2: Hoist pc advance to the top of EXCP_TRAP, Richard Henderson, 2022/04/26
- [PULL 05/68] linux-user/nios2: Handle special qemu syscall return values, Richard Henderson, 2022/04/26
- [PULL 16/68] target/nios2: Split PC out of env->regs[], Richard Henderson, 2022/04/26
- [PULL 07/68] linux-user/nios2: Use QEMU_ESIGRETURN from do_rt_sigreturn, Richard Henderson, 2022/04/26
- [PULL 12/68] linux-user/nios2: Use force_sig_fault for EXCP_DEBUG, Richard Henderson, 2022/04/26
- [PULL 26/68] target/nios2: Use hw/registerfields.h for CR_TLBADDR fields, Richard Henderson, 2022/04/26
- [PULL 22/68] target/nios2: Split control registers away from general registers, Richard Henderson, 2022/04/26
- [PULL 04/68] linux-user/nios2: Adjust error return, Richard Henderson, 2022/04/26
- [PULL 08/68] tests/tcg/nios2: Re-enable linux-user tests, Richard Henderson, 2022/04/26
- [PULL 11/68] target/nios2: Build helper.c for system only, Richard Henderson, 2022/04/26
- [PULL 17/68] target/nios2: Split out helper for eret instruction,
Richard Henderson <=
- [PULL 03/68] linux-user/nios2: Drop syscall 0 "workaround", Richard Henderson, 2022/04/26
- [PULL 02/68] linux-user/nios2: Fix clone child return, Richard Henderson, 2022/04/26
- [PULL 06/68] linux-user/nios2: Remove do_sigreturn, Richard Henderson, 2022/04/26
- [PULL 10/68] target/nios2: Remove nios2_cpu_record_sigsegv, Richard Henderson, 2022/04/26
- [PULL 13/68] target/nios2: Check supervisor on eret, Richard Henderson, 2022/04/26
- [PULL 14/68] target/nios2: Stop generating code if gen_check_supervisor fails, Richard Henderson, 2022/04/26
- [PULL 18/68] target/nios2: Fix BRET instruction, Richard Henderson, 2022/04/26
- [PULL 20/68] linux-user/nios2: Only initialize SP and PC in target_cpu_copy_regs, Richard Henderson, 2022/04/26
- [PULL 21/68] target/nios2: Remove cpu_interrupts_enabled, Richard Henderson, 2022/04/26
- [PULL 23/68] target/nios2: Clean up nios2_cpu_dump_state, Richard Henderson, 2022/04/26