From 4d90497d1421109e54842ae16aacc8c159fa6ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Fri, 2 Mar 2018 09:26:31 -0500 Subject: [PATCH] tcg: rename tcg_current_cpu to tcg_current_rr_cpu ..and make the definition local to cpus. In preparation for MTTCG the concept of a global tcg_current_cpu will no longer make sense. However we still need to keep track of it in the single-threaded case to be able to exit quickly when required. qemu_cpu_kick_no_halt() moves and becomes qemu_cpu_kick_rr_cpu() to emphasise its use-case. qemu_cpu_kick now kicks the relevant cpu as well as qemu_kick_rr_cpu() which will become a no-op in MTTCG. For the time being the setting of the global exit_request remains. Backports commit 791158d93b27f22a17c2ada06621831d54f09a2c from qemu Also atomically sets the unicorn equivalents --- include/uc_priv.h | 2 +- qemu/cpu-exec.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/uc_priv.h b/include/uc_priv.h index e3a98ec2..a3036ada 100644 --- a/include/uc_priv.h +++ b/include/uc_priv.h @@ -194,7 +194,7 @@ struct uc_struct { // qemu/cpu-exec.c BounceBuffer bounce; volatile sig_atomic_t exit_request; - CPUState *tcg_current_cpu; + CPUState *tcg_current_rr_cpu; // qemu/memory.c bool global_dirty_log; diff --git a/qemu/cpu-exec.c b/qemu/cpu-exec.c index f5387062..9419e48e 100644 --- a/qemu/cpu-exec.c +++ b/qemu/cpu-exec.c @@ -491,8 +491,8 @@ int cpu_exec(struct uc_struct *uc, CPUState *cpu) return EXCP_HALTED; } - uc->current_cpu = cpu; - atomic_mb_set(&uc->tcg_current_cpu, cpu); + atomic_mb_set(&uc->current_cpu, cpu); + atomic_mb_set(&uc->tcg_current_rr_cpu, cpu); if (unlikely(atomic_mb_read(&uc->exit_request))) { cpu->exit_request = 1; @@ -546,8 +546,8 @@ int cpu_exec(struct uc_struct *uc, CPUState *cpu) tb_flush(cpu); /* fail safe : never use current_cpu outside cpu_exec() */ - uc->current_cpu = NULL; + atomic_set(&uc->current_cpu, NULL); /* Does not need atomic_mb_set because a spurious wakeup is okay. */ - atomic_set(&uc->tcg_current_cpu, NULL); + atomic_set(&uc->tcg_current_rr_cpu, NULL); return ret; }