qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [PATCH v1 2/4] target/arm: handle A-profile T32 semihosting at translate time
Date: Wed,  3 Jul 2019 16:52:42 +0100	[thread overview]
Message-ID: <20190703155244.28166-3-alex.bennee@linaro.org> (raw)
In-Reply-To: <20190703155244.28166-1-alex.bennee@linaro.org>

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 | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/target/arm/translate.c b/target/arm/translate.c
index aaab043636..8e2e955cbe 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -10995,6 +10995,24 @@ static inline void gen_thumb_bkpt(DisasContext *s, int imm8)
     gen_exception_bkpt_insn(s, 2, syn_aa32_bkpt(imm8, true));
 }
 
+/*
+ * Thumb SWI. On A-profile CPUs this may be a semihosting call.
+ */
+static inline void gen_thumb_swi(DisasContext *s, int imm8)
+{
+    if (semihosting_enabled() &&
+#ifndef CONFIG_USER_ONLY
+        s->current_el != 0 &&
+#endif
+        (imm8 == 0xab)) {
+        gen_exception_internal_insn(s, 0, EXCP_SEMIHOST);
+        return;
+    }
+    gen_set_pc_im(s, s->pc);
+    s->svc_imm = imm8;
+    s->base.is_jmp = DISAS_SWI;
+}
+
 static void disas_thumb_insn(DisasContext *s, uint32_t insn)
 {
     uint32_t val, op, rm, rn, rd, shift, cond;
@@ -11752,10 +11770,8 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
             goto undef;
 
         if (cond == 0xf) {
-            /* swi */
-            gen_set_pc_im(s, s->pc);
-            s->svc_imm = extract32(insn, 0, 8);
-            s->base.is_jmp = DISAS_SWI;
+            /* swi/svc  */
+            gen_thumb_swi(s, extract32(insn, 0, 8));
             break;
         }
         /* generate a conditional jump to next instruction */
-- 
2.20.1



  parent reply	other threads:[~2019-07-03 16:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 15:52 [Qemu-devel] [PATCH v1 0/4] arm semihosting cleanups Alex Bennée
2019-07-03 15:52 ` [Qemu-devel] [PATCH v1 1/4] target/arm: handle M-profile semihosting at translate time Alex Bennée
2019-07-03 16:26   ` Richard Henderson
2019-07-04 10:21     ` Alex Bennée
2019-07-04 10:25       ` Philippe Mathieu-Daudé
2019-07-05 15:09         ` Richard Henderson
2019-07-03 15:52 ` Alex Bennée [this message]
2019-07-03 16:28   ` [Qemu-devel] [PATCH v1 2/4] target/arm: handle A-profile T32 " Richard Henderson
2019-07-03 15:52 ` [Qemu-devel] [PATCH v1 3/4] target/arm: handle A-profile A32 " Alex Bennée
2019-07-03 16:35   ` Richard Henderson
2019-07-03 15:52 ` [Qemu-devel] [PATCH v1 4/4] target/arm: remove run time semihosting checks Alex Bennée
2019-07-03 16:30   ` Philippe Mathieu-Daudé
2019-07-03 16:44     ` Alex Bennée
2019-07-03 16:53       ` Philippe Mathieu-Daudé
2019-07-03 16:38   ` Richard Henderson
2019-07-03 21:26 ` [Qemu-devel] [PATCH v1 0/4] arm semihosting cleanups no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190703155244.28166-3-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).