From: KONRAD Frederic <fred.kon...@greensocs.com> This flag indicates if the VCPU is currently executing TCG code.
Signed-off-by: KONRAD Frederic <fred.kon...@greensocs.com> Changes V1 -> V2: * do both tcg_executing = 0 or 1 in cpu_exec(). --- cpu-exec.c | 2 ++ include/qom/cpu.h | 3 +++ qom/cpu.c | 1 + 3 files changed, 6 insertions(+) diff --git a/cpu-exec.c b/cpu-exec.c index 75694f3..2fdf89d 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -371,6 +371,7 @@ int cpu_exec(CPUState *cpu) cpu->halted = 0; } + cpu->tcg_executing = 1; current_cpu = cpu; /* As long as current_cpu is null, up to the assignment just above, @@ -583,5 +584,6 @@ int cpu_exec(CPUState *cpu) /* fail safe : never use current_cpu outside cpu_exec() */ current_cpu = NULL; + cpu->tcg_executing = 0; return ret; } diff --git a/include/qom/cpu.h b/include/qom/cpu.h index efa9624..a2de536 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -226,6 +226,7 @@ struct kvm_run; * @stopped: Indicates the CPU has been artificially stopped. * @tcg_exit_req: Set to force TCG to stop executing linked TBs for this * CPU and return to its top level loop. + * @tcg_executing: This TCG thread is in cpu_exec(). * @singlestep_enabled: Flags for single-stepping. * @icount_extra: Instructions until next timer event. * @icount_decr: Number of cycles left, with interrupt flag in high bit. @@ -322,6 +323,8 @@ struct CPUState { (absolute value) offset as small as possible. This reduces code size, especially for hosts without large memory offsets. */ volatile sig_atomic_t tcg_exit_req; + + volatile int tcg_executing; }; QTAILQ_HEAD(CPUTailQ, CPUState); diff --git a/qom/cpu.c b/qom/cpu.c index 4e12598..62663e5 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -249,6 +249,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->icount_decr.u32 = 0; cpu->can_do_io = 0; cpu->exception_index = -1; + cpu->tcg_executing = 0; memset(cpu->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *)); } -- 1.9.0