Commit 71c2a2d0 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Thomas Gleixner
Browse files

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: default avatarLadi Prosek <>
Signed-off-by: default avatarVitaly Kuznetsov <>
Signed-off-by: default avatarThomas Gleixner <>
Cc: Stephen Hemminger <>
Cc: Haiyang Zhang <>
Cc: Jork Loeser <>
Cc: "K. Y. Srinivasan" <>
parent 2cf02842
......@@ -161,6 +161,15 @@ static int hv_nmi_unknown(unsigned int val, struct pt_regs *regs)
static unsigned long hv_get_tsc_khz(void)
unsigned long freq;
rdmsrl(HV_X64_MSR_TSC_FREQUENCY, freq);
return freq / 1000;
static void __init ms_hyperv_init_platform(void)
int hv_host_info_eax;
......@@ -193,6 +202,12 @@ static void __init ms_hyperv_init_platform(void)
hv_host_info_edx >> 24, hv_host_info_edx & 0xFFFFFF);
if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS &&
ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
x86_platform.calibrate_tsc = hv_get_tsc_khz;
x86_platform.calibrate_cpu = hv_get_tsc_khz;
if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS &&
ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment