aboutsummaryrefslogtreecommitdiff
path: root/target-arm/translate.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-10-27 16:17:55 +0000
committerPeter Maydell <peter.maydell@linaro.org>2015-10-27 16:17:55 +0000
commitc012e1b7ad066f462ba1c3322fcb43cd8295eaff (patch)
tree0ba1b8617611f9c4ac60dfc946cf5e24a3fab2ed /target-arm/translate.c
parent7e038b94e74e1c2d1b3598e2e4b0b5c8b79a7278 (diff)
parent9b539263faa5c1b7fce2551092b5c7b6eea92081 (diff)
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20151027-1' into staging
target-arm queue: * more EL2 preparation: handling for stage 2 translations * standardize debug macros in i.MX devices * improve error message in a corner case for virt board * disable live migration of KVM GIC if the kernel can't handle it * add SPSR_(ABT|UND|IRQ|FIQ) registers * handle non-executable page-straddling Thumb instructions * fix a "no 64-bit EL2" assumption in arm_excp_unmasked() # gpg: Signature made Tue 27 Oct 2015 16:03:31 GMT using RSA key ID 14360CDE # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" # gpg: aka "Peter Maydell <pmaydell@gmail.com>" # gpg: aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" * remotes/pmaydell/tags/pull-target-arm-20151027-1: (27 commits) target-arm: Add support for S1 + S2 MMU translations target-arm: Route S2 MMU faults to EL2 target-arm: Add S2 translation to 32bit S1 PTWs target-arm: Add S2 translation to 64bit S1 PTWs target-arm: Add ARMMMUFaultInfo target-arm: Avoid inline for get_phys_addr target-arm: Add support for S2 page-table protection bits target-arm: Add computation of starting level for S2 PTW target-arm: lpae: Rename granule_sz to stride target-arm: lpae: Replace tsz with computed inputsize target-arm: Add support for AArch32 S2 negative t0sz target-arm: lpae: Move declaration of t0sz and t1sz target-arm: lpae: Make t0sz and t1sz signed integers target-arm: Add HPFAR_EL2 i.MX: Standardize i.MX GPT debug i.MX: Standardize i.MX EPIT debug i.MX: Standardize i.MX FEC debug i.MX: Standardize i.MX CCM debug i.MX: Standardize i.MX AVIC debug i.MX: Standardize i.MX I2C debug ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target-arm/translate.c')
-rw-r--r--target-arm/translate.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/target-arm/translate.c b/target-arm/translate.c
index 9f1d740b4e..6be2c728f0 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -11179,6 +11179,35 @@ undef:
default_exception_el(s));
}
+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.)
+ */
+ uint16_t insn;
+
+ 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->bswap_code);
+
+ 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;
+}
+
/* generate intermediate code in gen_opc_buf and gen_opparam_buf for
basic block 'tb'. */
void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
@@ -11190,6 +11219,7 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
target_ulong next_page_start;
int num_insns;
int max_insns;
+ bool end_of_page;
/* generate intermediate code */
@@ -11411,11 +11441,24 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
* Otherwise the subsequent code could get translated several times.
* Also stop translation when a page boundary is reached. This
* ensures prefetch aborts occur at the right place. */
+
+ /* We want to stop the TB if the next insn starts in a new page,
+ * or if it spans between this page and the next. This means that
+ * if we're looking at the last halfword in the page we need to
+ * see if it's a 16-bit Thumb insn (which will fit in this TB)
+ * or a 32-bit Thumb insn (which won't).
+ * This is to avoid generating a silly TB with a single 16-bit insn
+ * in it at the end of this page (which would execute correctly
+ * but isn't very efficient).
+ */
+ end_of_page = (dc->pc >= next_page_start) ||
+ ((dc->pc >= next_page_start - 3) && insn_crosses_page(env, dc));
+
} while (!dc->is_jmp && !tcg_op_buf_full() &&
!cs->singlestep_enabled &&
!singlestep &&
!dc->ss_active &&
- dc->pc < next_page_start &&
+ !end_of_page &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {