From: Marcelo Tosatti Subject: Re: [PATCH 1/2] Complete cpu initialization before signaling main thread. Date: Tue, 13 Oct 2009 15:23:48 -0300 Message-ID: <20091013182348.GB14313@amt.cnet> References: <1255436240-994-1-git-send-email-gleb@redhat.com> <20091013181908.GA14313@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1261 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760897AbZJMSYf (ORCPT ); Tue, 13 Oct 2009 14:24:35 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9DIO9BV009456 for ; Tue, 13 Oct 2009 14:24:10 -0400 Content-Disposition: inline In-Reply-To: <20091013181908.GA14313@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Oct 13, 2009 at 03:19:08PM -0300, Marcelo Tosatti wrote: > > @@ -2003,15 +1991,25 @@ 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); > > You don't set cpu_single_env after reacquiring > qemu_mutex here (via qemu_cond_wait). > Also i'm curious about the failure. Why say, bsp should care about other cpu's register state while doing MP init? MP state is set via apic_reset, which happens before qemu_system_ready is set.