diff mbox series

[PULL,05/11] cpus: check cpu->running in cpu_get_icount_raw()

Message ID 20170410125524.21008-6-alex.bennee@linaro.org
State Accepted
Commit 243c5f77f6734776a45d50612b0f3ca2f2f6448e
Headers show
Series Final icount and misc MTTCG fixes for 2.9 | expand

Commit Message

Alex Bennée April 10, 2017, 12:55 p.m. UTC
The lifetime of current_cpu is now the lifetime of the vCPU thread.
However get_icount_raw() can apply a fudge factor if called while code
is running to take into account the current executed instruction
count.

To ensure this is always the case we also check cpu->running.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Richard Henderson <rth@twiddle.net>


-- 
2.11.0
diff mbox series

Patch

diff --git a/cpus.c b/cpus.c
index fc0ddc8793..7ec6473c02 100644
--- a/cpus.c
+++ b/cpus.c
@@ -229,7 +229,7 @@  int64_t cpu_get_icount_raw(void)
     CPUState *cpu = current_cpu;
 
     icount = timers_state.qemu_icount;
-    if (cpu) {
+    if (cpu && cpu->running) {
         if (!cpu->can_do_io) {
             fprintf(stderr, "Bad icount read\n");
             exit(1);