]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/hyperv: Set X86_FEATURE_TSC_KNOWN_FREQ when Hyper-V provides frequency
authorMichael Kelley <mhklinux@outlook.com>
Thu, 6 Jun 2024 02:55:59 +0000 (19:55 -0700)
committerWei Liu <wei.liu@kernel.org>
Fri, 2 Aug 2024 23:47:30 +0000 (23:47 +0000)
A Linux guest on Hyper-V gets the TSC frequency from a synthetic MSR, if
available. In this case, set X86_FEATURE_TSC_KNOWN_FREQ so that Linux
doesn't unnecessarily do refined TSC calibration when setting up the TSC
clocksource.

With this change, a message such as this is no longer output during boot
when the TSC is used as the clocksource:

[    1.115141] tsc: Refined TSC clocksource calibration: 2918.408 MHz

Furthermore, the guest and host will have exactly the same view of the
TSC frequency, which is important for features such as the TSC deadline
timer that are emulated by the Hyper-V host.

Signed-off-by: Michael Kelley <mhklinux@outlook.com>
Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
Link: https://lore.kernel.org/r/20240606025559.1631-1-mhklinux@outlook.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <20240606025559.1631-1-mhklinux@outlook.com>

arch/x86/kernel/cpu/mshyperv.c

index 954b7cbfa2f0211d041c0c4c8562817a92e3bc69..6a9aa057f9ca099193519e950d72fb6aa97b6e21 100644 (file)
@@ -424,6 +424,7 @@ static void __init ms_hyperv_init_platform(void)
            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;
+               setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
        }
 
        if (ms_hyperv.priv_high & HV_ISOLATION) {