OSDN Git Service

cpus: check cpu->running in cpu_get_icount_raw()
authorAlex Bennée <alex.bennee@linaro.org>
Thu, 30 Mar 2017 17:49:22 +0000 (18:49 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Mon, 10 Apr 2017 09:22:28 +0000 (10:22 +0100)
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>
cpus.c

diff --git a/cpus.c b/cpus.c
index fc0ddc8..7ec6473 100644 (file)
--- 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);