From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] kvm: Fix kvmclock initialization on !CONFIG_KVM_GUEST Date: Fri, 17 Aug 2012 14:54:41 -0300 Message-ID: <20120817175441.GA26255@amt.cnet> References: <87393o1c8q.fsf@devron.myhome.or.jp> <20120816195747.GA10759@amt.cnet> <87vcgijs3h.fsf@devron.myhome.or.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , kvm@vger.kernel.org To: OGAWA Hirofumi Return-path: Received: from mx1.redhat.com ([209.132.183.28]:62999 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753430Ab2HQRyt (ORCPT ); Fri, 17 Aug 2012 13:54:49 -0400 Content-Disposition: inline In-Reply-To: <87vcgijs3h.fsf@devron.myhome.or.jp> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Aug 17, 2012 at 09:10:42AM +0900, OGAWA Hirofumi wrote: > Marcelo Tosatti writes: > > > On Wed, Aug 15, 2012 at 11:05:57PM +0900, OGAWA Hirofumi wrote: > >> > >> If !CONFIG_KVM_GUEST, kvm_smp_prepare_boot_cpu() is not defined. So, > >> kvm_register_clock("primary cpu clock") in kvm_smp_prepare_boot_cpu() > >> is not called. > >> > >> The detail of problem is hv_clock percpu usage. hv_clock is percpu > >> variable, but kvmclock_init() is called _before_ initializing percpu > >> area, and doesn't update address after initialized percpu area. > >> > >> So, host kvm modify the memory area _before_ initializing percpu. This > >> became the cause of strange memory corruption on guest OS. > >> > >> > >> This fixes it by adding kvm_smp_prepare_boot_cpu(). [we might be > >> better to kill the usage before percpu initialization.] > >> > >> Signed-off-by: OGAWA Hirofumi > > > > The distinction between CONFIG_KVM_CLOCK and CONFIG_KVM_GUEST is > > not so clear anymore, as this bug demonstrates. > > > > There is no point in having a separate config option, therefore i > > propose to merge the two (see other reply) instead. > > Yes, it was an another option to fix this. As note, the wrong percpu > usage (use it before initialization) is still true even if merged > KVM_CLOCK. Its fine, i believe, because there is a percpu area for the "boot processor" (see __per_cpu_offset at arch/x86/kernel/setup_percpu.c) before proper initialization. Can you please confirm the proposed config merge fixes the problem for you? > Thanks. > -- > OGAWA Hirofumi