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: Thu, 16 Aug 2012 16:57:47 -0300 Message-ID: <20120816195747.GA10759@amt.cnet> References: <87393o1c8q.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]:1440 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933207Ab2HPUAe (ORCPT ); Thu, 16 Aug 2012 16:00:34 -0400 Content-Disposition: inline In-Reply-To: <87393o1c8q.fsf@devron.myhome.or.jp> Sender: kvm-owner@vger.kernel.org List-ID: 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.