aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/pvclock.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-09-01 14:21:03 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2016-09-20 09:26:15 +0200
commit108b249c453dd7132599ab6dc7e435a7036c193f (patch)
treeeb600c0558d7032bc1b0c62066f74ac109bd4fd7 /arch/x86/include/asm/pvclock.h
parentKVM: x86: initialize kvmclock_offset (diff)
downloadlinux-dev-108b249c453dd7132599ab6dc7e435a7036c193f.tar.xz
linux-dev-108b249c453dd7132599ab6dc7e435a7036c193f.zip
KVM: x86: introduce get_kvmclock_ns
Introduce a function that reads the exact nanoseconds value that is provided to the guest in kvmclock. This crystallizes the notion of kvmclock as a thin veneer over a stable TSC, that the guest will (hopefully) convert with NTP. In other words, kvmclock is *not* a paravirtualized host-to-guest NTP. Drop the get_kernel_ns() function, that was used both to get the base value of the master clock and to get the current value of kvmclock. The former use is replaced by ktime_get_boot_ns(), the latter is the purpose of get_kernel_ns(). This also allows KVM to provide a Hyper-V time reference counter that is synchronized with the time that is computed from the TSC page. Reviewed-by: Roman Kagan <rkagan@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/include/asm/pvclock.h')
-rw-r--r--arch/x86/include/asm/pvclock.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index d019f0cc80ec..3ad741b84072 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -87,9 +87,10 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
}
static __always_inline
-cycle_t __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src)
+cycle_t __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
+ u64 tsc)
{
- u64 delta = rdtsc_ordered() - src->tsc_timestamp;
+ u64 delta = tsc - src->tsc_timestamp;
cycle_t offset = pvclock_scale_delta(delta, src->tsc_to_system_mul,
src->tsc_shift);
return src->system_time + offset;