All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 1/2] Complete cpu initialization before signaling main thread.
@ 2009-10-14 13:52 Gleb Natapov
  2009-10-14 13:52 ` [PATCH 2/2] Don't sync mpstate to/from kernel when unneeded Gleb Natapov
  2009-10-14 18:35 ` [PATCHv2 1/2] Complete cpu initialization before signaling main thread Marcelo Tosatti
  0 siblings, 2 replies; 5+ messages in thread
From: Gleb Natapov @ 2009-10-14 13:52 UTC (permalink / raw)
  To: mtosatti; +Cc: kvm

Otherwise some cpus may start executing code before others
are fully initialized.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
v1->v2:
 - reinit cpu_single_env after qemu_cond_wait()

 qemu-kvm.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 62ca050..a104ab8 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1954,18 +1954,6 @@ static void process_irqchip_events(CPUState *env)
 
 static int kvm_main_loop_cpu(CPUState *env)
 {
-    setup_kernel_sigmask(env);
-
-    pthread_mutex_lock(&qemu_mutex);
-
-    kvm_arch_init_vcpu(env);
-#ifdef TARGET_I386
-    kvm_tpr_vcpu_start(env);
-#endif
-
-    cpu_single_env = env;
-    kvm_arch_load_regs(env);
-
     while (1) {
         int run_cpu = !is_cpu_stopped(env);
         if (run_cpu && !kvm_irqchip_in_kernel(kvm_context)) {
@@ -2003,15 +1991,28 @@ static void *ap_main_loop(void *_env)
         on_vcpu(env, kvm_arch_do_ioperm, data);
 #endif
 
-    /* signal VCPU creation */
+    setup_kernel_sigmask(env);
+
     pthread_mutex_lock(&qemu_mutex);
+    cpu_single_env = env;
+
+    kvm_arch_init_vcpu(env);
+#ifdef TARGET_I386
+    kvm_tpr_vcpu_start(env);
+#endif
+
+    kvm_arch_load_regs(env);
+
+    /* signal VCPU creation */
     current_env->created = 1;
     pthread_cond_signal(&qemu_vcpu_cond);
 
     /* and wait for machine initialization */
     while (!qemu_system_ready)
         qemu_cond_wait(&qemu_system_cond);
-    pthread_mutex_unlock(&qemu_mutex);
+
+    /* re-initialize cpu_single_env after re-acquiring qemu_mutex */
+    cpu_single_env = env;
 
     kvm_main_loop_cpu(env);
     return NULL;
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-13  0:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-14 13:52 [PATCHv2 1/2] Complete cpu initialization before signaling main thread Gleb Natapov
2009-10-14 13:52 ` [PATCH 2/2] Don't sync mpstate to/from kernel when unneeded Gleb Natapov
2009-11-11 23:33   ` Jan Kiszka
2009-11-13  0:33     ` Glauber Costa
2009-10-14 18:35 ` [PATCHv2 1/2] Complete cpu initialization before signaling main thread Marcelo Tosatti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.