diff mbox

[RFC,03/38] cpu-exec: set current_cpu at cpu_exec()

Message ID 1440375847-17603-4-git-send-email-cota@braap.org
State New
Headers show

Commit Message

Emilio Cota Aug. 24, 2015, 12:23 a.m. UTC
So that it applies to usermode as well.

Signed-off-by: Emilio G. Cota <cota@braap.org>
---
 cpu-exec.c | 2 ++
 cpus.c     | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini Aug. 24, 2015, 1:03 a.m. UTC | #1
On 23/08/2015 17:23, Emilio G. Cota wrote:
> So that it applies to usermode as well.
> 
> Signed-off-by: Emilio G. Cota <cota@braap.org>
> ---
>  cpu-exec.c | 2 ++
>  cpus.c     | 1 -
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/cpu-exec.c b/cpu-exec.c
> index b8a11e1..2b9a447 100644
> --- a/cpu-exec.c
> +++ b/cpu-exec.c
> @@ -386,6 +386,8 @@ int cpu_exec(CPUState *cpu)
>      uintptr_t next_tb;
>      SyncClocks sc;
>  
> +    current_cpu = cpu;
> +
>  #ifndef CONFIG_USER_ONLY
>      /* FIXME: user-mode emulation probably needs a similar mechanism as well,
>       * for example for tb_flush.
> diff --git a/cpus.c b/cpus.c
> index 5484ce6..0fe6576 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1079,7 +1079,6 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
>      cpu->thread_id = qemu_get_thread_id();
>      cpu->created = true;
>      cpu->can_do_io = 1;
> -    current_cpu = cpu;
>  
>      qemu_cond_signal(&qemu_cpu_cond);

Please set it somewhere in linux-user/ and bsd-user/ instead, I would
like to keep the TCG code more similar to KVM/Xen/qtest.  Probably the whole

    qemu_thread_get_self(cpu->thread);

    cpu->thread_id = qemu_get_thread_id();
    cpu->created = true;
    cpu->can_do_io = 1;
    current_cpu = cpu;

should be moved into a new function (rcu_register_thread too?).

Paolo
diff mbox

Patch

diff --git a/cpu-exec.c b/cpu-exec.c
index b8a11e1..2b9a447 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -386,6 +386,8 @@  int cpu_exec(CPUState *cpu)
     uintptr_t next_tb;
     SyncClocks sc;
 
+    current_cpu = cpu;
+
 #ifndef CONFIG_USER_ONLY
     /* FIXME: user-mode emulation probably needs a similar mechanism as well,
      * for example for tb_flush.
diff --git a/cpus.c b/cpus.c
index 5484ce6..0fe6576 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1079,7 +1079,6 @@  static void *qemu_tcg_cpu_thread_fn(void *arg)
     cpu->thread_id = qemu_get_thread_id();
     cpu->created = true;
     cpu->can_do_io = 1;
-    current_cpu = cpu;
 
     qemu_cond_signal(&qemu_cpu_cond);