aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/time.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-05-21 16:21:39 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-05-21 16:21:39 +0100
commitf3b88f2e646418ad3ed8ce7a19ea32d0b382654a (patch)
tree938f5b90f83c6738226074ff11e9e559af1768a3 /xen/arch/x86/time.c
parent8aca668075d380c94dac7dba9f292f8cde239b9c (diff)
downloadxen-f3b88f2e646418ad3ed8ce7a19ea32d0b382654a.tar.gz
xen-f3b88f2e646418ad3ed8ce7a19ea32d0b382654a.tar.bz2
xen-f3b88f2e646418ad3ed8ce7a19ea32d0b382654a.zip
Revert 21339:804304d4e05d "x86: TSC handling cleanups"
It very much breaks PV domU boot. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen/arch/x86/time.c')
-rw-r--r--xen/arch/x86/time.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 77fa8a5912..4863996930 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -804,13 +804,8 @@ static void __update_vcpu_system_time(struct vcpu *v, int force)
if ( d->arch.vtsc )
{
- u64 stime = t->stime_local_stamp;
- if ( is_hvm_domain(d) )
- {
- struct pl_time *pl = &v->domain->arch.hvm_domain.pl_time;
- stime += pl->stime_offset + v->arch.hvm_vcpu.stime_offset;
- }
- tsc_stamp = gtime_to_gtsc(d, stime);
+ u64 delta = max_t(s64, t->stime_local_stamp - d->arch.vtsc_offset, 0);
+ tsc_stamp = scale_delta(delta, &d->arch.ns_to_vtsc);
}
else
{
@@ -833,8 +828,6 @@ static void __update_vcpu_system_time(struct vcpu *v, int force)
_u.tsc_to_system_mul = t->tsc_scale.mul_frac;
_u.tsc_shift = (s8)t->tsc_scale.shift;
}
- if ( is_hvm_domain(d) )
- _u.tsc_timestamp += v->arch.hvm_vcpu.cache_tsc_offset;
/* Don't bother unless timestamp record has changed or we are forced. */
_u.version = u->version; /* make versions match for memcmp test */
@@ -1598,18 +1591,11 @@ struct tm wallclock_time(void)
* PV SoftTSC Emulation.
*/
-u64 gtime_to_gtsc(struct domain *d, u64 tsc)
-{
- if ( !is_hvm_domain(d) )
- tsc = max_t(s64, tsc - d->arch.vtsc_offset, 0);
- return scale_delta(tsc, &d->arch.ns_to_vtsc);
-}
-
void pv_soft_rdtsc(struct vcpu *v, struct cpu_user_regs *regs, int rdtscp)
{
s_time_t now = get_s_time();
struct domain *d = v->domain;
- u64 tsc;
+ u64 delta;
spin_lock(&d->arch.vtsc_lock);
@@ -1625,7 +1611,8 @@ void pv_soft_rdtsc(struct vcpu *v, struct cpu_user_regs *regs, int rdtscp)
spin_unlock(&d->arch.vtsc_lock);
- tsc = gtime_to_gtsc(d, now);
+ delta = max_t(s64, now - d->arch.vtsc_offset, 0);
+ now = scale_delta(delta, &d->arch.ns_to_vtsc);
regs->eax = (uint32_t)now;
regs->edx = (uint32_t)(now >> 32);
@@ -1766,10 +1753,8 @@ void tsc_set_info(struct domain *d,
d->arch.vtsc_offset = get_s_time() - elapsed_nsec;
d->arch.tsc_khz = gtsc_khz ? gtsc_khz : cpu_khz;
set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000 );
- /* use native TSC if initial host has safe TSC, has not migrated
- * yet and tsc_khz == cpu_khz */
- if ( host_tsc_is_safe() && incarnation == 0 &&
- d->arch.tsc_khz == cpu_khz )
+ /* use native TSC if initial host has safe TSC and not migrated yet */
+ if ( host_tsc_is_safe() && incarnation == 0 )
d->arch.vtsc = 0;
else
d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
@@ -1794,7 +1779,7 @@ void tsc_set_info(struct domain *d,
}
d->arch.incarnation = incarnation + 1;
if ( is_hvm_domain(d) )
- hvm_set_rdtsc_exiting(d, d->arch.vtsc);
+ hvm_set_rdtsc_exiting(d, d->arch.vtsc || hvm_gtsc_need_scale(d));
}
/* vtsc may incur measurable performance degradation, diagnose with this */