mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 11:05:40 +00:00
target/mips: avoid integer overflow in next_page PC check
If the PC is in the last page of the address space, next_page_start overflows to 0. Fix it. Backports commit 6cd79443d33e6ba6b4c5b787eb713ca1cec56328 from qemu
This commit is contained in:
parent
8162e6f1c6
commit
28cfe5dab0
|
@ -20373,7 +20373,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
|
||||||
CPUMIPSState *env = cs->env_ptr;
|
CPUMIPSState *env = cs->env_ptr;
|
||||||
DisasContext ctx;
|
DisasContext ctx;
|
||||||
target_ulong pc_start;
|
target_ulong pc_start;
|
||||||
target_ulong next_page_start;
|
target_ulong page_start;
|
||||||
int num_insns;
|
int num_insns;
|
||||||
int max_insns;
|
int max_insns;
|
||||||
int insn_bytes;
|
int insn_bytes;
|
||||||
|
@ -20384,7 +20384,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
|
||||||
bool block_full = false;
|
bool block_full = false;
|
||||||
|
|
||||||
pc_start = tb->pc;
|
pc_start = tb->pc;
|
||||||
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
|
page_start = pc_start & TARGET_PAGE_MASK;
|
||||||
ctx.uc = env->uc;
|
ctx.uc = env->uc;
|
||||||
ctx.pc = pc_start;
|
ctx.pc = pc_start;
|
||||||
ctx.saved_pc = -1;
|
ctx.saved_pc = -1;
|
||||||
|
@ -20553,7 +20553,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.pc >= next_page_start) {
|
if (ctx.pc - page_start >= TARGET_PAGE_SIZE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue