From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/2] don't start cpu main loop while there is still init work to do. Date: Mon, 04 May 2009 11:30:58 +0300 Message-ID: <49FEA7C2.7050908@redhat.com> References: <1241037101-24842-1-git-send-email-glommer@redhat.com> <1241037101-24842-2-git-send-email-glommer@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, ehabkost@redhat.com To: Glauber Costa Return-path: Received: from mx2.redhat.com ([66.187.237.31]:50113 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbZEDIbd (ORCPT ); Mon, 4 May 2009 04:31:33 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n448VXNC023331 for ; Mon, 4 May 2009 04:31:33 -0400 In-Reply-To: <1241037101-24842-2-git-send-email-glommer@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Glauber Costa wrote: > As soon as we call kvm_init_vcpu(), we start the vcpu thread. > However, there is still things that has to be done, as soon > as the new CPUState is created. Examples include initializing the > apic, halting the cpu, etc. > > Without this patch, it is possible that the cpu may want to start > using those things, before initializing them, leading to segfaults. > We introduce another state variable, "initialized", meaning that > the cpu is already created, but not totally initialized, > to serialize it. > > Before this patch: > (qemu) cpu_set X online => segfaults ~ 80 % of the time > After this patch: > (qemu) cpu_set X online => works. > > Is it possible to move all those things to the vcpu thread, so it serializes naturally? I'd like to avoid vcpu ioctls from more than one thread, in case we ever move to a syscall implementation. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.