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>
This commit is contained in:
committed by
Avi Kivity
parent
3cf57fed21
commit
3807f345b2
@@ -97,6 +97,18 @@ static unsigned pvclock_get_time_values(struct pvclock_shadow_time *dst,
|
|||||||
return dst->version;
|
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)
|
cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
|
||||||
{
|
{
|
||||||
struct pvclock_shadow_time shadow;
|
struct pvclock_shadow_time shadow;
|
||||||
|
@@ -198,17 +198,10 @@ unsigned long long xen_sched_clock(void)
|
|||||||
/* Get the TSC speed from Xen */
|
/* Get the TSC speed from Xen */
|
||||||
unsigned long xen_tsc_khz(void)
|
unsigned long xen_tsc_khz(void)
|
||||||
{
|
{
|
||||||
u64 xen_khz = 1000000ULL << 32;
|
struct pvclock_vcpu_time_info *info =
|
||||||
const struct pvclock_vcpu_time_info *info =
|
|
||||||
&HYPERVISOR_shared_info->vcpu_info[0].time;
|
&HYPERVISOR_shared_info->vcpu_info[0].time;
|
||||||
|
|
||||||
do_div(xen_khz, info->tsc_to_system_mul);
|
return pvclock_tsc_khz(info);
|
||||||
if (info->tsc_shift < 0)
|
|
||||||
xen_khz <<= -info->tsc_shift;
|
|
||||||
else
|
|
||||||
xen_khz >>= info->tsc_shift;
|
|
||||||
|
|
||||||
return xen_khz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cycle_t xen_clocksource_read(void)
|
cycle_t xen_clocksource_read(void)
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
/* some helper functions for xen and kvm pv clock sources */
|
/* some helper functions for xen and kvm pv clock sources */
|
||||||
cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src);
|
cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src);
|
||||||
|
unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
|
||||||
void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
|
void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
|
||||||
struct pvclock_vcpu_time_info *vcpu,
|
struct pvclock_vcpu_time_info *vcpu,
|
||||||
struct timespec *ts);
|
struct timespec *ts);
|
||||||
|
Reference in New Issue
Block a user