From: OGAWA Hirofumi Subject: Re: [PATCH] kvm: Fix kvmclock initialization on !CONFIG_KVM_GUEST Date: Fri, 17 Aug 2012 09:10:42 +0900 Message-ID: <87vcgijs3h.fsf@devron.myhome.or.jp> References: <87393o1c8q.fsf@devron.myhome.or.jp> <20120816195747.GA10759@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain Cc: Avi Kivity , kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mail.parknet.co.jp ([210.171.160.6]:57419 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369Ab2HQAKp (ORCPT ); Thu, 16 Aug 2012 20:10:45 -0400 In-Reply-To: <20120816195747.GA10759@amt.cnet> (Marcelo Tosatti's message of "Thu, 16 Aug 2012 16:57:47 -0300") Sender: kvm-owner@vger.kernel.org List-ID: 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. Thanks. -- OGAWA Hirofumi