]> Git Repo - qemu.git/commitdiff
target/xtensa: check zero overhead loop alignment
authorMax Filippov <[email protected]>
Fri, 27 Apr 2018 20:07:53 +0000 (13:07 -0700)
committerMax Filippov <[email protected]>
Sat, 30 Jun 2018 18:58:02 +0000 (11:58 -0700)
ISA book documents that the first instruction of zero overhead loop
must fit completely into naturally aligned region of an instruction
fetch unit size. Check that condition and log a message if it's
violated.

Signed-off-by: Max Filippov <[email protected]>
target/xtensa/cpu.h
target/xtensa/overlay_tool.h
target/xtensa/translate.c

index e9d2e109f7905bd1b597e248e257b87b04f2b815..51b4551464945b1477618ddd753c5a98cf9df0f3 100644 (file)
@@ -369,6 +369,7 @@ struct XtensaConfig {
     unsigned nareg;
     int excm_level;
     int ndepc;
+    unsigned inst_fetch_width;
     uint32_t vecbase;
     uint32_t exception_vector[EXC_MAX];
     unsigned ninterrupt;
index b24ad11fec1c1e7c523bf0de271103806d5a7190..ee37a04a176cdeffd90269fccc0115720603be10 100644 (file)
     .options = XTENSA_OPTIONS, \
     .nareg = XCHAL_NUM_AREGS, \
     .ndepc = (XCHAL_XEA_VERSION >= 2), \
+    .inst_fetch_width = XCHAL_INST_FETCH_WIDTH, \
     EXCEPTIONS_SECTION, \
     INTERRUPTS_SECTION, \
     TLB_SECTION, \
index a11162eebe068732b013eb3a418e5c70fe7be9cf..7dd8b55d4a5d7e0d6a7929cad28c7bb5f3a7ae4b 100644 (file)
@@ -970,6 +970,13 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
     }
 
     dc->next_pc = dc->pc + len;
+    if (xtensa_option_enabled(dc->config, XTENSA_OPTION_LOOP) &&
+        dc->lbeg == dc->pc &&
+        ((dc->pc ^ (dc->next_pc - 1)) & -dc->config->inst_fetch_width)) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "unaligned first instruction of a loop (pc = %08x)\n",
+                      dc->pc);
+    }
     for (i = 1; i < len; ++i) {
         b[i] = cpu_ldub_code(env, dc->pc + i);
     }
This page took 0.036867 seconds and 4 git commands to generate.