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
This commit is contained in:
Leon Alrae 2018-02-11 17:12:29 -05:00 committed by Lioncash
parent 6d1bc2c3c7
commit c0fc9b280e
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -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;