icount: clean up cpu_can_io at the entry to the block
Most of IO instructions can be executed only at the end of the block in icount mode. Therefore translator can set cpu_can_io flag when translating the last instruction. But when the blocks are chained, then this flag is not reset and may remain set at the beginning of the next block. This patch resets the flag at the entry of any translation block, making I/O operations impossible by default. Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> -- v2 changes: - reset can_do_io at the start of every TB (suggested by Paolo Bonzini) Message-Id: <156404428943.18669.15747009371169578935.stgit@pasha-Precision-3630-Tower> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
13f267133f
commit
ba3e792669
|
@ -169,7 +169,6 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb)
|
||||||
}
|
}
|
||||||
#endif /* DEBUG_DISAS */
|
#endif /* DEBUG_DISAS */
|
||||||
|
|
||||||
cpu->can_do_io = !use_icount;
|
|
||||||
ret = tcg_qemu_tb_exec(env, tb_ptr);
|
ret = tcg_qemu_tb_exec(env, tb_ptr);
|
||||||
cpu->can_do_io = 1;
|
cpu->can_do_io = 1;
|
||||||
last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);
|
last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);
|
||||||
|
|
|
@ -7,6 +7,24 @@
|
||||||
|
|
||||||
static TCGOp *icount_start_insn;
|
static TCGOp *icount_start_insn;
|
||||||
|
|
||||||
|
static inline void gen_io_start(void)
|
||||||
|
{
|
||||||
|
TCGv_i32 tmp = tcg_const_i32(1);
|
||||||
|
tcg_gen_st_i32(tmp, cpu_env,
|
||||||
|
offsetof(ArchCPU, parent_obj.can_do_io) -
|
||||||
|
offsetof(ArchCPU, env));
|
||||||
|
tcg_temp_free_i32(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void gen_io_end(void)
|
||||||
|
{
|
||||||
|
TCGv_i32 tmp = tcg_const_i32(0);
|
||||||
|
tcg_gen_st_i32(tmp, cpu_env,
|
||||||
|
offsetof(ArchCPU, parent_obj.can_do_io) -
|
||||||
|
offsetof(ArchCPU, env));
|
||||||
|
tcg_temp_free_i32(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void gen_tb_start(TranslationBlock *tb)
|
static inline void gen_tb_start(TranslationBlock *tb)
|
||||||
{
|
{
|
||||||
TCGv_i32 count, imm;
|
TCGv_i32 count, imm;
|
||||||
|
@ -40,6 +58,8 @@ static inline void gen_tb_start(TranslationBlock *tb)
|
||||||
tcg_gen_st16_i32(count, cpu_env,
|
tcg_gen_st16_i32(count, cpu_env,
|
||||||
offsetof(ArchCPU, neg.icount_decr.u16.low) -
|
offsetof(ArchCPU, neg.icount_decr.u16.low) -
|
||||||
offsetof(ArchCPU, env));
|
offsetof(ArchCPU, env));
|
||||||
|
/* Disable I/O by default */
|
||||||
|
gen_io_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
tcg_temp_free_i32(count);
|
tcg_temp_free_i32(count);
|
||||||
|
@ -57,22 +77,4 @@ static inline void gen_tb_end(TranslationBlock *tb, int num_insns)
|
||||||
tcg_gen_exit_tb(tb, TB_EXIT_REQUESTED);
|
tcg_gen_exit_tb(tb, TB_EXIT_REQUESTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gen_io_start(void)
|
|
||||||
{
|
|
||||||
TCGv_i32 tmp = tcg_const_i32(1);
|
|
||||||
tcg_gen_st_i32(tmp, cpu_env,
|
|
||||||
offsetof(ArchCPU, parent_obj.can_do_io) -
|
|
||||||
offsetof(ArchCPU, env));
|
|
||||||
tcg_temp_free_i32(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void gen_io_end(void)
|
|
||||||
{
|
|
||||||
TCGv_i32 tmp = tcg_const_i32(0);
|
|
||||||
tcg_gen_st_i32(tmp, cpu_env,
|
|
||||||
offsetof(ArchCPU, parent_obj.can_do_io) -
|
|
||||||
offsetof(ArchCPU, env));
|
|
||||||
tcg_temp_free_i32(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue