From: KONRAD Frederic <fred.kon...@greensocs.com> This removes exit_request global and adds a variable in CPUState for this. Only the flag for the first cpu is used for the moment as we are still with one TCG thread.
Signed-off-by: KONRAD Frederic <fred.kon...@greensocs.com> --- cpu-exec.c | 4 +--- cpus.c | 12 +++++++++--- include/qom/cpu.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 68654e3..3ba2a7a 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -327,8 +327,6 @@ static void cpu_handle_debug_exception(CPUArchState *env) /* main execution loop */ -volatile sig_atomic_t exit_request; - int cpu_exec(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); @@ -365,7 +363,7 @@ int cpu_exec(CPUArchState *env) * an instruction scheduling constraint on modern architectures. */ smp_mb(); - if (unlikely(exit_request)) { + if (unlikely(cpu->exit_loop_request)) { cpu->exit_request = 1; } diff --git a/cpus.c b/cpus.c index f10c94d..8ae70c2 100644 --- a/cpus.c +++ b/cpus.c @@ -646,10 +646,14 @@ static void cpu_handle_guest_debug(CPUState *cpu) static void cpu_signal(int sig) { + CPUState *cpu; if (current_cpu) { cpu_exit(current_cpu); } - exit_request = 1; + + CPU_FOREACH(cpu) { + cpu->exit_loop_request = 1; + } } #ifdef CONFIG_LINUX @@ -1376,7 +1380,8 @@ static void tcg_exec_all(void) if (next_cpu == NULL) { next_cpu = first_cpu; } - for (; next_cpu != NULL && !exit_request; next_cpu = CPU_NEXT(next_cpu)) { + for (; next_cpu != NULL && !first_cpu->exit_loop_request; + next_cpu = CPU_NEXT(next_cpu)) { CPUState *cpu = next_cpu; CPUArchState *env = cpu->env_ptr; @@ -1393,7 +1398,8 @@ static void tcg_exec_all(void) break; } } - exit_request = 0; + + first_cpu->exit_loop_request = 0; } void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 2098f1c..a2e3208 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -249,6 +249,7 @@ struct CPUState { bool created; bool stop; bool stopped; + volatile sig_atomic_t exit_loop_request; volatile sig_atomic_t exit_request; uint32_t interrupt_request; int singlestep_enabled; -- 1.9.0