From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [patch 3/3] KVM: x86: zero kvmclock_offset when vcpu0 initializes kvmclock system MSR Date: Thu, 28 May 2015 10:52:05 +0200 Message-ID: <5566D735.9050804@redhat.com> References: <20150528014657.367253422@redhat.com> <20150528014929.546279051@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: Luiz Capitulino , kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:53049 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753395AbbE1IwJ (ORCPT ); Thu, 28 May 2015 04:52:09 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 43EBB18AEA0 for ; Thu, 28 May 2015 08:52:09 +0000 (UTC) In-Reply-To: <20150528014929.546279051@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 28/05/2015 03:47, Marcelo Tosatti wrote: > Initialize kvmclock base, on kvmclock system MSR write time, > so that the guest sees kvmclock counting from zero. > > This matches baremetal behaviour when kvmclock in guest > sets sched clock stable. > > Signed-off-by: Marcelo Tosatti > > --- > arch/x86/kvm/x86.c | 5 +++++ > 1 file changed, 5 insertions(+) > > Index: kvm/arch/x86/kvm/x86.c > =================================================================== > --- kvm.orig/arch/x86/kvm/x86.c 2015-05-27 17:40:46.948189811 -0300 > +++ kvm/arch/x86/kvm/x86.c 2015-05-27 22:43:47.340413347 -0300 > @@ -1703,6 +1703,8 @@ > /* If the host uses TSC clocksource, then it is stable */ > if (use_master_clock) > pvclock_flags |= PVCLOCK_TSC_STABLE_BIT; > + if (ka->kvmclk_counts_from_zero) Not defined anywhere. > + pvclock_flags |= PVCLOCK_COUNTS_FROM_ZERO; Why can't this be unconditional? Paolo > vcpu->hv_clock.flags = pvclock_flags; > > @@ -2282,6 +2284,9 @@ > &vcpu->requests); > > ka->boot_vcpu_runs_old_kvmclock = tmp; > + > + ka->kvmclock_offset = -get_kernel_ns(); > + ka->kvmclk_counts_from_zero = true; > } > > vcpu->arch.time = data; > >