[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 18/68] target/nios2: Fix BRET instruction
From: |
Richard Henderson |
Subject: |
[PATCH v8 18/68] target/nios2: Fix BRET instruction |
Date: |
Fri, 22 Apr 2022 09:51:48 -0700 |
We had failed to copy BSTATUS back to STATUS, and diagnose
supervisor-only. The spec is light on the specifics of the
implementation of bret, but it is an easy assumption that
the restore into STATUS should work the same as eret.
Therefore, reuse the existing helper_eret.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220421151735.31996-19-richard.henderson@linaro.org>
---
target/nios2/translate.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index 53699ee088..3694f2503b 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -407,12 +407,22 @@ static void ret(DisasContext *dc, uint32_t code, uint32_t
flags)
dc->base.is_jmp = DISAS_JUMP;
}
-/* PC <- ba */
+/*
+ * status <- bstatus
+ * PC <- ba
+ */
static void bret(DisasContext *dc, uint32_t code, uint32_t flags)
{
- tcg_gen_mov_tl(cpu_pc, cpu_R[R_BA]);
+ if (!gen_check_supervisor(dc)) {
+ return;
+ }
- dc->base.is_jmp = DISAS_JUMP;
+#ifdef CONFIG_USER_ONLY
+ g_assert_not_reached();
+#else
+ gen_helper_eret(cpu_env, cpu_R[CR_BSTATUS], cpu_R[R_BA]);
+ dc->base.is_jmp = DISAS_NORETURN;
+#endif
}
/* PC <- rA */
--
2.34.1
- [PATCH v8 06/68] linux-user/nios2: Remove do_sigreturn, (continued)
- [PATCH v8 06/68] linux-user/nios2: Remove do_sigreturn, Richard Henderson, 2022/04/22
- [PATCH v8 07/68] linux-user/nios2: Use QEMU_ESIGRETURN from do_rt_sigreturn, Richard Henderson, 2022/04/22
- [PATCH v8 08/68] tests/tcg/nios2: Re-enable linux-user tests, Richard Henderson, 2022/04/22
- [PATCH v8 09/68] target/nios2: Remove user-only nios2_cpu_do_interrupt, Richard Henderson, 2022/04/22
- [PATCH v8 10/68] target/nios2: Remove nios2_cpu_record_sigsegv, Richard Henderson, 2022/04/22
- [PATCH v8 11/68] target/nios2: Build helper.c for system only, Richard Henderson, 2022/04/22
- [PATCH v8 12/68] linux-user/nios2: Use force_sig_fault for EXCP_DEBUG, Richard Henderson, 2022/04/22
- [PATCH v8 14/68] target/nios2: Stop generating code if gen_check_supervisor fails, Richard Henderson, 2022/04/22
- [PATCH v8 13/68] target/nios2: Check supervisor on eret, Richard Henderson, 2022/04/22
- [PATCH v8 16/68] target/nios2: Split PC out of env->regs[], Richard Henderson, 2022/04/22
- [PATCH v8 18/68] target/nios2: Fix BRET instruction,
Richard Henderson <=
- [PATCH v8 19/68] target/nios2: Do not create TCGv for control registers, Richard Henderson, 2022/04/22
- [PATCH v8 20/68] linux-user/nios2: Only initialize SP and PC in target_cpu_copy_regs, Richard Henderson, 2022/04/22
- [PATCH v8 21/68] target/nios2: Remove cpu_interrupts_enabled, Richard Henderson, 2022/04/22
- [PATCH v8 24/68] target/nios2: Use hw/registerfields.h for CR_STATUS fields, Richard Henderson, 2022/04/22
- [PATCH v8 15/68] target/nios2: Add NUM_GP_REGS and NUM_CP_REGS, Richard Henderson, 2022/04/22
- [PATCH v8 17/68] target/nios2: Split out helper for eret instruction, Richard Henderson, 2022/04/22
- [PATCH v8 23/68] target/nios2: Clean up nios2_cpu_dump_state, Richard Henderson, 2022/04/22
- [PATCH v8 22/68] target/nios2: Split control registers away from general registers, Richard Henderson, 2022/04/22
- [PATCH v8 25/68] target/nios2: Use hw/registerfields.h for CR_EXCEPTION fields, Richard Henderson, 2022/04/22
- [PATCH v8 26/68] target/nios2: Use hw/registerfields.h for CR_TLBADDR fields, Richard Henderson, 2022/04/22