From 1182d8528b620c23d043bccbbef092b42062960a Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Mon, 5 Mar 2007 00:30:36 -0800 Subject: [PATCH] vmi: cpu cycles fix In order to share the common code in tsc.c which does CPU Khz calibration, we need to make an accurate value of CPU speed available to the tsc.c code. This value loses a lot of precision in a VM because of the timing differences with real hardware, but we need it to be as precise as possible so the guest can make accurate time calculations with the cycle counters. Signed-off-by: Zachary Amsden Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-i386/paravirt.h | 2 ++ include/asm-i386/timer.h | 2 ++ include/asm-i386/vmi_time.h | 1 + 3 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h index a13230254f4..a35c8148065 100644 --- a/include/asm-i386/paravirt.h +++ b/include/asm-i386/paravirt.h @@ -95,6 +95,7 @@ struct paravirt_ops u64 (*read_tsc)(void); u64 (*read_pmc)(void); u64 (*get_scheduled_cycles)(void); + unsigned long (*get_cpu_khz)(void); void (*load_tr_desc)(void); void (*load_gdt)(const struct Xgt_desc_struct *); @@ -275,6 +276,7 @@ static inline void halt(void) #define rdtscll(val) (val = paravirt_ops.read_tsc()) #define get_scheduled_cycles(val) (val = paravirt_ops.get_scheduled_cycles()) +#define calculate_cpu_khz() (paravirt_ops.get_cpu_khz()) #define write_tsc(val1,val2) wrmsr(0x10, val1, val2) diff --git a/include/asm-i386/timer.h b/include/asm-i386/timer.h index d1f7b4f575b..12dd67bf760 100644 --- a/include/asm-i386/timer.h +++ b/include/asm-i386/timer.h @@ -7,6 +7,7 @@ void setup_pit_timer(void); unsigned long long native_sched_clock(void); +unsigned long native_calculate_cpu_khz(void); /* Modifiers for buggy PIT handling */ extern int pit_latch_buggy; @@ -17,6 +18,7 @@ extern int recalibrate_cpu_khz(void); #ifndef CONFIG_PARAVIRT #define get_scheduled_cycles(val) rdtscll(val) +#define calculate_cpu_khz() native_calculate_cpu_khz() #endif #endif diff --git a/include/asm-i386/vmi_time.h b/include/asm-i386/vmi_time.h index f59c35d3735..1f971eb7f71 100644 --- a/include/asm-i386/vmi_time.h +++ b/include/asm-i386/vmi_time.h @@ -50,6 +50,7 @@ extern void __init vmi_time_init(void); extern unsigned long vmi_get_wallclock(void); extern int vmi_set_wallclock(unsigned long now); extern unsigned long long vmi_get_sched_cycles(void); +extern unsigned long vmi_cpu_khz(void); #ifdef CONFIG_X86_LOCAL_APIC extern void __init vmi_timer_setup_boot_alarm(void); -- cgit v1.2.3