diff options
author | Vitaly Kuznetsov <vkuznets@redhat.com> | 2017-06-22 06:07:30 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-06-22 09:35:12 -0400 |
commit | 71c2a2d0a81f096a2932fccb39a500116fece554 (patch) | |
tree | 0d633df9e9084d3f46b1cfea517c3f36165a6eca | |
parent | 2cf0284223a40773bd0ec76a409a7cbf0607ca28 (diff) |
x86/hyperv: Read TSC frequency from a synthetic MSR
It was found that SMI_TRESHOLD of 50000 is not enough for Hyper-V
guests in nested environment and falling back to counting jiffies
is not an option for Gen2 guests as they don't have PIT. As Hyper-V
provides TSC frequency in a synthetic MSR we can just use this information
instead of doing a error prone calibration.
Reported-and-tested-by: Ladi Prosek <lprosek@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Jork Loeser <jloeser@microsoft.com>
Cc: devel@linuxdriverproject.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Link: http://lkml.kernel.org/r/20170622100730.18112-3-vkuznets@redhat.com
-rw-r--r-- | arch/x86/kernel/cpu/mshyperv.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 3563c8e6c014..70e717fccdd6 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c | |||
@@ -161,6 +161,15 @@ static int hv_nmi_unknown(unsigned int val, struct pt_regs *regs) | |||
161 | } | 161 | } |
162 | #endif | 162 | #endif |
163 | 163 | ||
164 | static unsigned long hv_get_tsc_khz(void) | ||
165 | { | ||
166 | unsigned long freq; | ||
167 | |||
168 | rdmsrl(HV_X64_MSR_TSC_FREQUENCY, freq); | ||
169 | |||
170 | return freq / 1000; | ||
171 | } | ||
172 | |||
164 | static void __init ms_hyperv_init_platform(void) | 173 | static void __init ms_hyperv_init_platform(void) |
165 | { | 174 | { |
166 | int hv_host_info_eax; | 175 | int hv_host_info_eax; |
@@ -193,6 +202,12 @@ static void __init ms_hyperv_init_platform(void) | |||
193 | hv_host_info_edx >> 24, hv_host_info_edx & 0xFFFFFF); | 202 | hv_host_info_edx >> 24, hv_host_info_edx & 0xFFFFFF); |
194 | } | 203 | } |
195 | 204 | ||
205 | if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS && | ||
206 | ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) { | ||
207 | x86_platform.calibrate_tsc = hv_get_tsc_khz; | ||
208 | x86_platform.calibrate_cpu = hv_get_tsc_khz; | ||
209 | } | ||
210 | |||
196 | #ifdef CONFIG_X86_LOCAL_APIC | 211 | #ifdef CONFIG_X86_LOCAL_APIC |
197 | if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS && | 212 | if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS && |
198 | ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) { | 213 | ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) { |