Patchwork [2/3] target-arm: implement Thumb-2 exception return

login
register
mail settings
Submitter Rabin Vincent
Date Feb. 14, 2010, 6:32 p.m.
Message ID <1266172357-9252-3-git-send-email-rabin@rab.in>
Download mbox | patch
Permalink /patch/45332/
State New
Headers show

Comments

Rabin Vincent - Feb. 14, 2010, 6:32 p.m.
Support the "subs pc, lr" Thumb-2 exception return instruction.

Signed-off-by: Rabin Vincent <rabin@rab.in>
---
 target-arm/translate.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

Patch

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 10a516b..f0667e5 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -8001,8 +8001,17 @@  static int disas_thumb2_insn(CPUState *env, DisasContext *s, uint16_t insn_hw1)
                         gen_bx(s, tmp);
                         break;
                     case 5: /* Exception return.  */
-                        /* Unpredictable in user mode.  */
-                        goto illegal_op;
+                        if (IS_USER(s)) {
+                            goto illegal_op;
+                        }
+
+                        tmp = load_reg(s, rn);
+                        tmp2 = new_tmp();
+                        tcg_gen_movi_i32(tmp2, insn & 0xff);
+                        gen_helper_sub_cc(tmp, tmp, tmp2);
+                        gen_exception_return(s, tmp);
+                        dead_tmp(tmp2);
+                        break;
                     case 6: /* mrs cpsr.  */
                         tmp = new_tmp();
                         if (IS_M(env)) {