diff mbox series

[v2,26/33] target/mips: Fix ERET/ERETNC behavior related to ADEL exception

Message ID 1531169431-10772-27-git-send-email-aleksandar.markovic@rt-rk.com
State New
Headers show
Series Add nanoMIPS support to QEMU | expand

Commit Message

Aleksandar Markovic July 9, 2018, 8:50 p.m. UTC
From: Yongbok Kim <yongbok.kim@mips.com>

Fix ERET/ERETNC so that ADEL exception can be raised.

Signed-off-by: Yongbok Kim <yongbok.kim@mips.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Stefan Markovic <smarkovic@wavecomp.com>
---
 target/mips/op_helper.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Aleksandar Markovic July 10, 2018, 6:22 p.m. UTC | #1
> Subject: [PATCH v2 26/33] target/mips: Fix ERET/ERETNC behavior related to ADEL exception
>
> From: Yongbok Kim <yongbok.kim@mips.com>
>
> Fix ERET/ERETNC so that ADEL exception can be raised.
>
> Signed-off-by: Yongbok Kim <yongbok.kim@mips.com>
> Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
> Signed-off-by: Stefan Markovic <smarkovic@wavecomp.com>
> ---
>  target/mips/op_helper.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>

Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>

> diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
> index c55a1e6..e6749c5 100644
> --- a/target/mips/op_helper.c
> +++ b/target/mips/op_helper.c
> @@ -2430,6 +2430,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) {
> @@ -2467,10 +2474,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 */
> --
> 2.7.4
>
>
diff mbox series

Patch

diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c
index c55a1e6..e6749c5 100644
--- a/target/mips/op_helper.c
+++ b/target/mips/op_helper.c
@@ -2430,6 +2430,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) {
@@ -2467,10 +2474,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 */