This reverts commit 78ff82bb1b67c0d79113688e4b3427fc99cab9d4. This produces transient errors in the 2018 advent calendar day 11 image for sparc when using -icount auto.
It is not clear what the problem is with the narrower CF_COUNT_MASK value, since we bound the insns_left value in cpu_loop_exec_tb and we bound the insns translated in tb_gen_code. But it is late in the release cycle and reverting the change does fix the problem. In the meantime, CF_NO_GOTO_TB, CF_NO_GOTO_PTR and CF_SINGLE_STEP were added and so need to be moved to different bits. Reported-by: Peter Maydell <peter.mayd...@linaro.org> Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- include/exec/exec-all.h | 9 ++++----- accel/tcg/translate-all.c | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 5d1b6d80fb..bccd7724dc 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -493,16 +493,15 @@ struct TranslationBlock { uint32_t flags; /* flags defining in which context the code was generated */ uint32_t cflags; /* compile flags */ -/* Note that TCG_MAX_INSNS is 512; we validate this match elsewhere. */ -#define CF_COUNT_MASK 0x000001ff -#define CF_NO_GOTO_TB 0x00000200 /* Do not chain with goto_tb */ -#define CF_NO_GOTO_PTR 0x00000400 /* Do not chain with goto_ptr */ -#define CF_SINGLE_STEP 0x00000800 /* gdbstub single-step in effect */ +#define CF_COUNT_MASK 0x00007fff #define CF_LAST_IO 0x00008000 /* Last insn may be an IO access. */ #define CF_MEMI_ONLY 0x00010000 /* Only instrument memory ops */ #define CF_USE_ICOUNT 0x00020000 #define CF_INVALID 0x00040000 /* TB is stale. Set with @jmp_lock held */ #define CF_PARALLEL 0x00080000 /* Generate code for a parallel context */ +#define CF_NO_GOTO_TB 0x00100000 /* Do not chain with goto_tb */ +#define CF_NO_GOTO_PTR 0x00200000 /* Do not chain with goto_ptr */ +#define CF_SINGLE_STEP 0x00400000 /* gdbstub single-step in effect */ #define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */ #define CF_CLUSTER_SHIFT 24 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index bbfcfb698c..0226123981 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1428,9 +1428,11 @@ TranslationBlock *tb_gen_code(CPUState *cpu, max_insns = cflags & CF_COUNT_MASK; if (max_insns == 0) { + max_insns = CF_COUNT_MASK; + } + if (max_insns > TCG_MAX_INSNS) { max_insns = TCG_MAX_INSNS; } - QEMU_BUILD_BUG_ON(CF_COUNT_MASK + 1 != TCG_MAX_INSNS); buffer_overflow: tb = tcg_tb_alloc(tcg_ctx); -- 2.25.1