From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: pavel.dovgaluk@ispras.ru,
peter.maydell@linaro.orgPavel Dovgalyuk <dovgaluk@ispras.ru>
Subject: [Qemu-devel] [PATCH 2/3] replay: check icount in cpu exec loop
Date: Tue, 21 Feb 2017 13:46:37 +0100 [thread overview]
Message-ID: <20170221124638.19573-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20170221124638.19573-1-pbonzini@redhat.com>
From: Pavel Dovgalyuk <dovgaluk@ispras.ru>
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 does not longjmp anymore after exhausting the
icount decrementer, it can use the align_clocks call in cpu_exec. Remove
the one in cpu_loop_exec_tb, as well as the SyncClocks *sc argument.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Message-Id: <002801d2810f$18809c20$4981d460$@ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
cpu-exec.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 18e1973..bf126dd 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -517,7 +517,10 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
*last_tb = NULL;
}
}
- 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;
@@ -527,8 +530,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;
@@ -578,10 +580,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);
}
}
@@ -641,7 +640,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
next prev parent reply other threads:[~2017-02-21 12:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-21 12:46 [Qemu-devel] [PATCH 0/3] cpu-exec: icount and exit request cleanups Paolo Bonzini
2017-02-21 12:46 ` [Qemu-devel] [PATCH 1/3] cpu-exec: unify icount_decr and tcg_exit_req Paolo Bonzini
2017-02-21 12:46 ` Paolo Bonzini [this message]
2017-02-21 12:46 ` [Qemu-devel] [PATCH 3/3] cpu-exec: remove unnecessary check of cpu->exit_request Paolo Bonzini
2017-02-21 14:25 ` [Qemu-devel] [PATCH 0/3] cpu-exec: icount and exit request cleanups no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170221124638.19573-3-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=peter.maydell@linaro.orgPavel \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).