From c0fc9b280e04078749612b09af6fb796cca0a83d Mon Sep 17 00:00:00 2001 From: Leon Alrae Date: Sun, 11 Feb 2018 17:12:29 -0500 Subject: [PATCH] target-mips: fix detection of the end of the page during translation The test is supposed to terminate TB if the end of the page is reached. However, with current implementation it may never succeed for microMIPS or mips16. Backports commit fe2372910a09034591fd2cfc2d70cca43fccaa95 from qemu --- qemu/target-mips/translate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qemu/target-mips/translate.c b/qemu/target-mips/translate.c index 3a959f6a..4cae8ea9 100644 --- a/qemu/target-mips/translate.c +++ b/qemu/target-mips/translate.c @@ -19261,6 +19261,7 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb, CPUMIPSState *env = &cpu->env; DisasContext ctx; target_ulong pc_start; + target_ulong next_page_start; CPUBreakpoint *bp; int j, lj = -1; int num_insns; @@ -19275,6 +19276,7 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb, qemu_log("search pc %d\n", search_pc); pc_start = tb->pc; + next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; ctx.uc = env->uc; ctx.pc = pc_start; ctx.saved_pc = -1; @@ -19427,8 +19429,9 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb, break; } - if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) + if (ctx.pc >= next_page_start) { break; + } if (tcg_op_buf_full(tcg_ctx)) { break;