From: Avi Kivity Subject: Re: [PATCH] return default values for apic probe functions. Date: Sun, 19 Apr 2009 11:45:13 +0300 Message-ID: <49EAE499.4010203@redhat.com> References: <1239945321-3903-1-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, aliguori@us.ibm.com, qemu-devel@nongnu.org To: Glauber Costa Return-path: Received: from mx2.redhat.com ([66.187.237.31]:48998 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752326AbZDSIpZ (ORCPT ); Sun, 19 Apr 2009 04:45:25 -0400 In-Reply-To: <1239945321-3903-1-git-send-email-glommer@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Glauber Costa wrote: > As KVM cpus runs on threads, it is possible that > we call kvm_load_registers() from a cpu thread, while the > apic has not yet fully initialized. kvm_load_registers() is called > from ap_main_loop. > > This is not a problem when we're starting the whole machine together, > but is a problem for hotplug, since we don't have the protection > of the locks that protect machine initialization. Currently, some executions > of cpu hotplug on rainy sundays fail with a segfault. > > Moving apic initialization to before kvm_init_vpcu proved fruitful, > as there are some dependencies involved. (kvm irqchip would fail to > initialize). > I presume you mean unfruitful (or perhaps a nasty kind of fruit). > This patch provides default values to be used for tpr and apic_base, > that will be returned when the apic is not yet properly initialized. > It is aimed at kvm, where the problem exists, but it could equally be > used for qemu too, if there is agreement. > Seems like a hack... can you try not to make the vcpu visible until it is completely initialized? (and what is the problem exactly - someone accessing the registers from a different thread? that shouldn't happen) -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.