Skip to content

Commit

Permalink
accel/tcg: Always require can_do_io
Browse files Browse the repository at this point in the history
Require i/o as the last insn of a TranslationBlock always,
not only with icount.  This is required for i/o that alters
the address space, such as a pci config space write.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1866
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Sep 28, 2023
1 parent 200c1f9 commit 18a536f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
20 changes: 7 additions & 13 deletions accel/tcg/translator.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ static void set_can_do_io(DisasContextBase *db, bool val)

bool translator_io_start(DisasContextBase *db)
{
uint32_t cflags = tb_cflags(db->tb);

if (!(cflags & CF_USE_ICOUNT)) {
return false;
}

set_can_do_io(db, true);

/*
Expand Down Expand Up @@ -86,15 +80,15 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags)
tcg_gen_st16_i32(count, cpu_env,
offsetof(ArchCPU, neg.icount_decr.u16.low) -
offsetof(ArchCPU, env));
/*
* cpu->can_do_io is set automatically here at the beginning of
* each translation block. The cost is minimal and only paid for
* -icount, plus it would be very easy to forget doing it in the
* translator.
*/
set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO));
}

/*
* cpu->can_do_io is set automatically here at the beginning of
* each translation block. The cost is minimal, plus it would be
* very easy to forget doing it in the translator.
*/
set_can_do_io(db, db->max_insns == 1 && (cflags & CF_LAST_IO));

return icount_start_insn;
}

Expand Down
1 change: 0 additions & 1 deletion target/mips/tcg/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -11212,7 +11212,6 @@ static void gen_branch(DisasContext *ctx, int insn_bytes)
/* Branches completion */
clear_branch_hflags(ctx);
ctx->base.is_jmp = DISAS_NORETURN;
/* FIXME: Need to clear can_do_io. */
switch (proc_hflags & MIPS_HFLAG_BMASK_BASE) {
case MIPS_HFLAG_FBNSLOT:
gen_goto_tb(ctx, 0, ctx->base.pc_next + insn_bytes);
Expand Down

0 comments on commit 18a536f

Please sign in to comment.