From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: KVM: x86: update masterclock when kvmclock_offset is calculated Date: Tue, 20 Aug 2013 15:20:12 -0300 Message-ID: <20130820182012.GA814@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Paolo Bonzini , Gleb Natapov To: kvm-devel Return-path: Received: from mx1.redhat.com ([209.132.183.28]:25309 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750933Ab3HTSUa (ORCPT ); Tue, 20 Aug 2013 14:20:30 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7KIKT90013019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Aug 2013 14:20:30 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: The offset to add to the hosts monotonic time, kvmclock_offset, is calculated against the monotonic time at KVM_SET_CLOCK ioctl time. Request a master clock update at this time, to reduce a potentially unbounded difference between the values of the masterclock and the clock value used to calculate kvmclock_offset. Signed-off-by: Marcelo Tosatti Index: linux-2.6-kvmclock-fixes/arch/x86/kvm/x86.c =================================================================== --- linux-2.6-kvmclock-fixes.orig/arch/x86/kvm/x86.c +++ linux-2.6-kvmclock-fixes/arch/x86/kvm/x86.c @@ -3806,6 +3806,7 @@ long kvm_arch_vm_ioctl(struct file *filp delta = user_ns.clock - now_ns; local_irq_enable(); kvm->arch.kvmclock_offset = delta; + kvm_gen_update_masterclock(kvm); break; } case KVM_GET_CLOCK: {