From 191effb2beb4d309c70d647c4b0347e15fe6a1d1 Mon Sep 17 00:00:00 2001 From: Haozhong Zhang Date: Mon, 24 Aug 2015 14:13:35 +0800 Subject: [PATCH 09/13] x86/time.c: Scale host TSC in pvclock properly This patch makes the pvclock return the scaled host TSC and corresponding scaling parameters to HVM domains if guest TSC is not emulated and TSC scaling is enabled. Signed-off-by: Haozhong Zhang --- xen/arch/x86/time.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 2487b3a..a3e8fe7 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -821,10 +821,18 @@ static void __update_vcpu_system_time(struct vcpu *v, int force) } else { - tsc_stamp = t->local_tsc_stamp; - - _u.tsc_to_system_mul = t->tsc_scale.mul_frac; - _u.tsc_shift = (s8)t->tsc_scale.shift; + if ( is_hvm_domain(d) && hvm_funcs.tsc_scaling_supported ) + { + tsc_stamp = hvm_scale_tsc(v, t->local_tsc_stamp); + _u.tsc_to_system_mul = d->arch.vtsc_to_ns.mul_frac; + _u.tsc_shift = d->arch.vtsc_to_ns.shift; + } + else + { + tsc_stamp = t->local_tsc_stamp; + _u.tsc_to_system_mul = t->tsc_scale.mul_frac; + _u.tsc_shift = (s8)t->tsc_scale.shift; + } } _u.tsc_timestamp = tsc_stamp; -- 2.4.8