From 461fbaa9ebe8a45f417985ab2155c4906ecd8d89 Mon Sep 17 00:00:00 2001 From: Pavel Dovgalyuk Date: Thu, 4 Oct 2018 04:32:18 -0400 Subject: [PATCH] target/i386: fix translation for icount mode This patch fixes the checking of boundary crossing instructions. In icount mode only first instruction of the block may cross the page boundary to keep the translation deterministic. These conditions already existed, but compared the wrong variable. Backports commit 41d54dc09f1f327dedc79d5ba0b1b437ab7b0e94 from qemu --- qemu/target/i386/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu/target/i386/translate.c b/qemu/target/i386/translate.c index 75a034e8..39a01a63 100644 --- a/qemu/target/i386/translate.c +++ b/qemu/target/i386/translate.c @@ -9173,10 +9173,10 @@ static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) chance to happen */ dc->base.is_jmp = DISAS_TOO_MANY; } else if ((dc->base.tb->cflags & CF_USE_ICOUNT) - && ((dc->base.pc_next & TARGET_PAGE_MASK) - != ((dc->base.pc_next + TARGET_MAX_INSN_SIZE - 1) + && ((pc_next & TARGET_PAGE_MASK) + != ((pc_next + TARGET_MAX_INSN_SIZE - 1) & TARGET_PAGE_MASK) - || (dc->base.pc_next & ~TARGET_PAGE_MASK) == 0)) { + || (pc_next & ~TARGET_PAGE_MASK) == 0)) { /* Do not cross the boundary of the pages in icount mode, it can cause an exception. Do it only when boundary is crossed by the first instruction in the block.