summaryrefslogtreecommitdiff
path: root/arch/x86
diff options
context:
space:
mode:
authorGlauber Costa <gcosta@redhat.com>2008-07-28 11:47:52 -0300
committerAvi Kivity <avi@qumranet.com>2008-10-15 10:15:17 +0200
commit3807f345b2c610336c17c7624a0d496a38df75a0 (patch)
tree63142e06c85b938ddd6f1b0ced11724f362d6d5d /arch/x86
parent3cf57fed216e2c1b6fdfeccb792650bab72a350a (diff)
x86: paravirt: factor out cpu_khz to common code
KVM intends to use paravirt code to calibrate khz. Xen current code will do just fine. So as a first step, factor out code to pvclock.c. Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/pvclock.c12
-rw-r--r--arch/x86/xen/time.c11
2 files changed, 14 insertions, 9 deletions
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 05fbe9a0325a..1c54b5fb7aed 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -97,6 +97,18 @@ static unsigned pvclock_get_time_values(struct pvclock_shadow_time *dst,
return dst->version;
}
+unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
+{
+ u64 tsc_khz = 1000000ULL << 32;
+
+ do_div(tsc_khz, src->tsc_to_system_mul);
+ if (src->tsc_shift < 0)
+ tsc_khz <<= -src->tsc_shift;
+ else
+ tsc_khz >>= src->tsc_shift;
+ return tsc_khz;
+}
+
cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
{
struct pvclock_shadow_time shadow;
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 004ba86326ae..c9f7cda48ed7 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -198,17 +198,10 @@ unsigned long long xen_sched_clock(void)
/* Get the TSC speed from Xen */
unsigned long xen_tsc_khz(void)
{
- u64 xen_khz = 1000000ULL << 32;
- const struct pvclock_vcpu_time_info *info =
+ struct pvclock_vcpu_time_info *info =
&HYPERVISOR_shared_info->vcpu_info[0].time;
- do_div(xen_khz, info->tsc_to_system_mul);
- if (info->tsc_shift < 0)
- xen_khz <<= -info->tsc_shift;
- else
- xen_khz >>= info->tsc_shift;
-
- return xen_khz;
+ return pvclock_tsc_khz(info);
}
cycle_t xen_clocksource_read(void)