diff mbox series

[v1,3/4] target/arm: handle A-profile A32 semihosting at translate time

Message ID 20190703155244.28166-4-alex.bennee@linaro.org
State Superseded
Headers show
Series arm semihosting cleanups | expand

Commit Message

Alex Bennée July 3, 2019, 3:52 p.m. UTC
As for the other semihosting calls we can resolve this at translate
time.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 target/arm/translate.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

-- 
2.20.1

Comments

Richard Henderson July 3, 2019, 4:35 p.m. UTC | #1
On 7/3/19 5:52 PM, Alex Bennée wrote:
> As for the other semihosting calls we can resolve this at translate

> time.

> 

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> ---

>  target/arm/translate.c | 20 +++++++++++++++++---

>  1 file changed, 17 insertions(+), 3 deletions(-)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>



r~
diff mbox series

Patch

diff --git a/target/arm/translate.c b/target/arm/translate.c
index 8e2e955cbe..139b2f6765 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -7699,6 +7699,22 @@  static void arm_skip_unless(DisasContext *s, uint32_t cond)
     arm_gen_test_cc(cond ^ 1, s->condlabel);
 }
 
+static inline void gen_arm_swi(DisasContext *s, int imm24)
+{
+    if (semihosting_enabled() &&
+#ifndef CONFIG_USER_ONLY
+        s->current_el != 0 &&
+#endif
+        (imm24 == 0x123456)) {
+        gen_exception_internal_insn(s, 0, EXCP_SEMIHOST);
+        return;
+    }
+
+    gen_set_pc_im(s, s->pc);
+    s->svc_imm = imm24;
+    s->base.is_jmp = DISAS_SWI;
+}
+
 static void disas_arm_insn(DisasContext *s, unsigned int insn)
 {
     unsigned int cond, val, op1, i, shift, rm, rs, rn, rd, sh;
@@ -9249,9 +9265,7 @@  static void disas_arm_insn(DisasContext *s, unsigned int insn)
             break;
         case 0xf:
             /* swi */
-            gen_set_pc_im(s, s->pc);
-            s->svc_imm = extract32(insn, 0, 24);
-            s->base.is_jmp = DISAS_SWI;
+            gen_arm_swi(s, extract32(insn, 0, 24));
             break;
         default:
         illegal_op: