[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 27/36] icount: clean up cpu_can_io at the entry to th
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 27/36] icount: clean up cpu_can_io at the entry to the block |
Date: |
Tue, 20 Aug 2019 08:59:46 +0200 |
From: Pavel Dovgalyuk <address@hidden>
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 <address@hidden>
--
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 <address@hidden>
---
accel/tcg/cpu-exec.c | 1 -
include/exec/gen-icount.h | 38 ++++++++++++++++++++------------------
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 6c85c3e..48272c7 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -169,7 +169,6 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu,
TranslationBlock *itb)
}
#endif /* DEBUG_DISAS */
- cpu->can_do_io = !use_icount;
ret = tcg_qemu_tb_exec(env, tb_ptr);
cpu->can_do_io = 1;
last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);
diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h
index f7669b6..4004e6c 100644
--- a/include/exec/gen-icount.h
+++ b/include/exec/gen-icount.h
@@ -7,6 +7,24 @@
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)
{
TCGv_i32 count, imm;
@@ -40,6 +58,8 @@ static inline void gen_tb_start(TranslationBlock *tb)
tcg_gen_st16_i32(count, cpu_env,
offsetof(ArchCPU, neg.icount_decr.u16.low) -
offsetof(ArchCPU, env));
+ /* Disable I/O by default */
+ gen_io_end();
}
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);
}
-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
--
1.8.3.1
- [Qemu-devel] [PULL 16/36] mc146818rtc: Remove reset notifiers, (continued)
- [Qemu-devel] [PULL 16/36] mc146818rtc: Remove reset notifiers, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 15/36] memory: fix race between TCG and accesses to dirty bitmap, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 17/36] timer: Remove reset notifiers, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 12/36] tests: Fix uninitialized byte in test_visitor_in_fuzz, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 14/36] target/i386: Return 'indefinite integer value' for invalid SSE fp->int conversions, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 19/36] timer: last, remove last bits of last, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 20/36] kconfig: do not select VMMOUSE, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 18/36] replay: Remove host_clock_last, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 25/36] replay: refine replay-time module, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 29/36] cpus-common: nuke finish_safe_work, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 27/36] icount: clean up cpu_can_io at the entry to the block,
Paolo Bonzini <=
- [Qemu-devel] [PULL 36/36] x86: Intel AVX512_BF16 feature enabling, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 28/36] icount: remove unnecessary gen_io_end calls, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 26/36] replay: rename step-related variables and functions, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 32/36] HACKING: Document 'struct' keyword usage, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 23/36] util/qemu-timer: refactor deadline calculation for external timers, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 33/36] migration: do not rom_reset() during incoming migration, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 34/36] test-bitmap: test set 1 bit case for bitmap_set, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 35/36] scsi: lsi: exit infinite loop while executing script (CVE-2019-12068), Paolo Bonzini, 2019/08/20
- Re: [Qemu-devel] [PULL 00/36] QEMU patches for 2018-08-20, no-reply, 2019/08/20
- Re: [Qemu-devel] [PULL 00/36] QEMU patches for 2018-08-20, Peter Maydell, 2019/08/20