From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"open list:ARM TCG CPUs" <qemu-arm@nongnu.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PATCH v1 1/9] target/arm: handle M-profile semihosting at translate time
Date: Wed, 28 Aug 2019 17:52:59 +0100 [thread overview]
Message-ID: <20190828165307.18321-2-alex.bennee@linaro.org> (raw)
In-Reply-To: <20190828165307.18321-1-alex.bennee@linaro.org>
We do this for other semihosting calls so we might as well do it for
M-profile as well.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/m_helper.c | 18 ++++++------------
target/arm/translate.c | 20 +++++++++++++++++++-
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
index 884d35d2b02..27cd2f3f964 100644
--- a/target/arm/m_helper.c
+++ b/target/arm/m_helper.c
@@ -2114,19 +2114,13 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
break;
}
break;
+ case EXCP_SEMIHOST:
+ qemu_log_mask(CPU_LOG_INT,
+ "...handling as semihosting call 0x%x\n",
+ env->regs[0]);
+ env->regs[0] = do_arm_semihosting(env);
+ return;
case EXCP_BKPT:
- if (semihosting_enabled()) {
- int nr;
- nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff;
- if (nr == 0xab) {
- env->regs[15] += 2;
- qemu_log_mask(CPU_LOG_INT,
- "...handling as semihosting call 0x%x\n",
- env->regs[0]);
- env->regs[0] = do_arm_semihosting(env);
- return;
- }
- }
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false);
break;
case EXCP_IRQ:
diff --git a/target/arm/translate.c b/target/arm/translate.c
index cbe19b7a625..259c4669b4c 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -10889,6 +10889,24 @@ illegal_op:
unallocated_encoding(s);
}
+/*
+ * Thumb BKPT. On M-profile CPUs this may be a semihosting call which
+ * we can process much the same way as gen_hlt() above.
+ */
+static inline void gen_thumb_bkpt(DisasContext *s, int imm8)
+{
+ if (arm_dc_feature(s, ARM_FEATURE_M) &&
+ semihosting_enabled() &&
+#ifndef CONFIG_USER_ONLY
+ s->current_el != 0 &&
+#endif
+ (imm8 == 0xab)) {
+ gen_exception_internal_insn(s, 0, EXCP_SEMIHOST);
+ return;
+ }
+ gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm8, true));
+}
+
static void disas_thumb_insn(DisasContext *s, uint32_t insn)
{
uint32_t val, op, rm, rn, rd, shift, cond;
@@ -11511,7 +11529,7 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
{
int imm8 = extract32(insn, 0, 8);
ARCH(5);
- gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm8, true));
+ gen_thumb_bkpt(s, imm8);
break;
}
--
2.20.1
next prev parent reply other threads:[~2019-08-28 17:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-28 16:52 [Qemu-devel] [PATCH v1 0/9] arm semih-hosting cleanups and other misc cleanups Alex Bennée
2019-08-28 16:52 ` Alex Bennée [this message]
2019-08-28 16:53 ` [Qemu-devel] [PATCH v1 2/9] target/arm: handle A-profile T32 semihosting at translate time Alex Bennée
2019-08-28 16:53 ` [Qemu-devel] [PATCH v1 3/9] target/arm: handle A-profile A32 " Alex Bennée
2019-08-28 16:53 ` [Qemu-devel] [PATCH v1 4/9] target/arm: remove run time semihosting checks Alex Bennée
2019-08-28 21:12 ` Richard Henderson
2019-08-28 16:53 ` [Qemu-devel] [PATCH v1 5/9] includes: remove stale [smp|max]_cpus externs Alex Bennée
2019-08-28 21:12 ` Richard Henderson
2019-08-28 16:53 ` [Qemu-devel] [PATCH v1 6/9] tcg/README: fix typo s/afterwise/afterwards/ Alex Bennée
2019-08-28 16:53 ` [Qemu-devel] [PATCH v1 7/9] atomic_template: fix indentation in GEN_ATOMIC_HELPER Alex Bennée
2019-08-28 16:53 ` [Qemu-devel] [PATCH v1 8/9] accel/stubs: reduce headers from tcg-stub Alex Bennée
2019-08-29 9:31 ` Alex Bennée
2019-08-28 16:53 ` [Qemu-devel] [PATCH v1 9/9] include/exec/cpu-defs.h: fix typo Alex Bennée
2019-08-29 16:57 ` [Qemu-devel] [PATCH v1 0/9] arm semih-hosting cleanups and other misc cleanups Philippe Mathieu-Daudé
2019-09-03 10:22 ` Peter Maydell
2019-09-03 10:37 ` Peter Maydell
2019-09-03 10:45 ` Alex Bennée
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=20190828165307.18321-2-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).