[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/17] replay: check icount in cpu exec loop
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 02/17] replay: check icount in cpu exec loop |
Date: |
Mon, 27 Feb 2017 13:45:36 +0100 |
From: Pavel Dovgalyuk <address@hidden>
This patch adds check to break cpu loop when icount expires without
setting the TB_EXIT_ICOUNT_EXPIRED flag. It happens when there is no
available translated blocks and all instructions were executed.
In icount replay mode unnecessary tb_find will be called (which may
cause an exception) and execution will be non-deterministic.
Because cpu_loop_exec_tb cannot longjmp anymore, we can remove
the anticipated call to align_clocks in cpu_loop_exec_tb, as
well as the SyncClocks *sc argument.
Signed-off-by: Pavel Dovgalyuk <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
cpu-exec.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 6fd3f47..2a0dfb0 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -554,8 +554,9 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
qemu_mutex_unlock_iothread();
}
-
- if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt())) {
+ /* Finally, check if we need to exit to the main loop. */
+ if (unlikely(atomic_read(&cpu->exit_request)
+ || (use_icount && cpu->icount_decr.u16.low + cpu->icount_extra == 0)))
{
atomic_set(&cpu->exit_request, 0);
cpu->exception_index = EXCP_INTERRUPT;
return true;
@@ -565,8 +566,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
}
static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
- TranslationBlock **last_tb, int *tb_exit,
- SyncClocks *sc)
+ TranslationBlock **last_tb, int *tb_exit)
{
uintptr_t ret;
int32_t insns_left;
@@ -615,10 +615,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu,
TranslationBlock *tb,
*/
if (insns_left > 0) {
cpu_exec_nocache(cpu, insns_left, tb, false);
- align_clocks(sc, cpu);
}
- cpu->exception_index = EXCP_INTERRUPT;
- cpu_loop_exit(cpu);
}
#endif
}
@@ -593,7 +592,7 @@ int cpu_exec(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
int ret;
- SyncClocks sc;
+ SyncClocks sc = { 0 };
/* replay_interrupt may need current_cpu */
current_cpu = cpu;
@@ -677,7 +674,7 @@ int cpu_exec(CPUState *cpu)
while (!cpu_handle_interrupt(cpu, &last_tb)) {
TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit);
- cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc);
+ cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit);
/* Try to align the host and virtual clocks
if the guest is in advance */
align_clocks(&sc, cpu);
--
2.9.3
- [Qemu-devel] [PULL v2 00/17] KVM and cpu-exec patches for 2.9 soft freeze, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 02/17] replay: check icount in cpu exec loop,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 03/17] cpu-exec: remove unnecessary check of cpu->exit_request, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 01/17] cpu-exec: unify icount_decr and tcg_exit_req, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 04/17] update-linux-headers: update for 4.11, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 06/17] cpus: remove ugly cast on sigbus_handler, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 07/17] KVM: x86: cleanup SIGBUS handlers, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 08/17] cpus: reorganize signal handling code, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 09/17] KVM: remove kvm_arch_on_sigbus, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 10/17] KVM: do not use sigtimedwait to catch SIGBUS, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 12/17] kvm: use atomic_read/atomic_set to access cpu->exit_request, Paolo Bonzini, 2017/02/27
- [Qemu-devel] [PATCH 11/17] KVM: move SIG_IPI handling to kvm-all.c, Paolo Bonzini, 2017/02/27