From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: Richard Henderson <rth@twiddle.net>, patches@linaro.org
Subject: [Qemu-devel] [PATCH 7/9] target-arm: Simplify insn_crosses_page()
Date: Mon, 9 Oct 2017 14:48:37 +0100 [thread overview]
Message-ID: <1507556919-24992-8-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1507556919-24992-1-git-send-email-peter.maydell@linaro.org>
Recent changes have left insn_crosses_page() more complicated
than it needed to be:
* it's only called from thumb_tr_translate_insn() so we know
for certain that we're looking at a Thumb insn
* the caller's check for dc->pc >= dc->next_page_start - 3
means that dc->pc can't possibly be 4 aligned, so there's
no need to check that (the check was partly there to ensure
that we didn't treat an ARM insn as Thumb, I think)
* we now have thumb_insn_is_16bit() which lets us do a precise
check of the length of the next insn, rather than opencoding
an inaccurate check
Simplify it down to just loading the first half of the insn
and calling thumb_insn_is_16bit() on it.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/translate.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/target/arm/translate.c b/target/arm/translate.c
index 8d3203e..5838e67 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -11875,29 +11875,14 @@ static bool insn_crosses_page(CPUARMState *env, DisasContext *s)
{
/* Return true if the insn at dc->pc might cross a page boundary.
* (False positives are OK, false negatives are not.)
+ * We know this is a Thumb insn, and our caller ensures we are
+ * only called if dc->pc is less than 4 bytes from the page
+ * boundary, so we cross the page if the first 16 bits indicate
+ * that this is a 32 bit insn.
*/
- uint16_t insn;
+ uint16_t insn = arm_lduw_code(env, s->pc, s->sctlr_b);
- if ((s->pc & 3) == 0) {
- /* At a 4-aligned address we can't be crossing a page */
- return false;
- }
-
- /* This must be a Thumb insn */
- insn = arm_lduw_code(env, s->pc, s->sctlr_b);
-
- if ((insn >> 11) >= 0x1d) {
- /* Top five bits 0b11101 / 0b11110 / 0b11111 : this is the
- * First half of a 32-bit Thumb insn. Thumb-1 cores might
- * end up actually treating this as two 16-bit insns (see the
- * code at the start of disas_thumb2_insn()) but we don't bother
- * to check for that as it is unlikely, and false positives here
- * are harmless.
- */
- return true;
- }
- /* Definitely a 16-bit insn, can't be crossing a page. */
- return false;
+ return !thumb_insn_is_16bit(s, insn);
}
static int arm_tr_init_disas_context(DisasContextBase *dcbase,
--
2.7.4
next prev parent reply other threads:[~2017-10-09 13:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 13:48 [Qemu-devel] [PATCH 0/9] v8M: BLXNS, SG, secure function return Peter Maydell
2017-10-09 13:48 ` [Qemu-devel] [PATCH 1/9] target/arm: Add M profile secure MMU index values to get_a32_user_mem_index() Peter Maydell
2017-10-10 23:36 ` Richard Henderson
2017-10-09 13:48 ` [Qemu-devel] [PATCH 2/9] target/arm: Implement SG instruction Peter Maydell
2017-10-11 0:27 ` Richard Henderson
2017-10-09 13:48 ` [Qemu-devel] [PATCH 3/9] target/arm: Implement BLXNS Peter Maydell
2017-10-09 13:48 ` [Qemu-devel] [PATCH 4/9] target/arm: Implement secure function return Peter Maydell
2017-10-09 13:48 ` [Qemu-devel] [PATCH 5/9] target-arm: Don't check for "Thumb2 or M profile" for not-Thumb1 Peter Maydell
2017-10-11 0:29 ` Richard Henderson
2017-10-09 13:48 ` [Qemu-devel] [PATCH 6/9] target/arm: Pull Thumb insn word loads up to top level Peter Maydell
2017-10-11 2:18 ` Richard Henderson
2017-10-11 9:55 ` Peter Maydell
2017-10-09 13:48 ` Peter Maydell [this message]
2017-10-11 2:26 ` [Qemu-devel] [PATCH 7/9] target-arm: Simplify insn_crosses_page() Richard Henderson
2017-10-09 13:48 ` [Qemu-devel] [PATCH 8/9] target/arm: Support some Thumb insns being always unconditional Peter Maydell
2017-10-11 2:52 ` Richard Henderson
2017-10-11 9:57 ` Peter Maydell
2017-10-11 14:14 ` Richard Henderson
2017-10-09 13:48 ` [Qemu-devel] [PATCH 9/9] target/arm: Implement SG instruction corner cases Peter Maydell
2017-10-11 2:57 ` Richard Henderson
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=1507556919-24992-8-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).