mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
target/riscv: Make translator stop before the end of a page
Right now the translator stops right *after* the end of a page, which breaks reporting of fault locations when the last instruction of a multi-insn translation block crosses a page boundary. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1155 Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
ef6e987b64
commit
00c07344fa
3 changed files with 93 additions and 4 deletions
|
@ -1154,12 +1154,21 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
|
|||
}
|
||||
ctx->nftemp = 0;
|
||||
|
||||
/* Only the first insn within a TB is allowed to cross a page boundary. */
|
||||
if (ctx->base.is_jmp == DISAS_NEXT) {
|
||||
target_ulong page_start;
|
||||
|
||||
page_start = ctx->base.pc_first & TARGET_PAGE_MASK;
|
||||
if (ctx->base.pc_next - page_start >= TARGET_PAGE_SIZE) {
|
||||
if (!is_same_page(&ctx->base, ctx->base.pc_next)) {
|
||||
ctx->base.is_jmp = DISAS_TOO_MANY;
|
||||
} else {
|
||||
unsigned page_ofs = ctx->base.pc_next & ~TARGET_PAGE_MASK;
|
||||
|
||||
if (page_ofs > TARGET_PAGE_SIZE - MAX_INSN_LEN) {
|
||||
uint16_t next_insn = cpu_lduw_code(env, ctx->base.pc_next);
|
||||
int len = insn_len(next_insn);
|
||||
|
||||
if (!is_same_page(&ctx->base, ctx->base.pc_next + len)) {
|
||||
ctx->base.is_jmp = DISAS_TOO_MANY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue