Skip to content

Commit 5f92b45

Browse files
ani-sinhaliuw
authored andcommitted
x86/hyperv: add comment describing TSC_INVARIANT_CONTROL MSR setting bit 0
Commit dce7cd6 ("x86/hyperv: Allow guests to enable InvariantTSC") added the support for HV_X64_MSR_TSC_INVARIANT_CONTROL. Setting bit 0 of this synthetic MSR will allow hyper-v guests to report invariant TSC CPU feature through CPUID. This comment adds this explanation to the code and mentions where the Intel's generic platform init code reads this feature bit from CPUID. The comment will help developers understand how the two parts of the initialization (hyperV specific and non-hyperV specific generic hw init) are related. Signed-off-by: Ani Sinha <[email protected]> Reviewed-by: Vitaly Kuznetsov <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent 6dc77fa commit 5f92b45

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,15 @@ static void __init ms_hyperv_init_platform(void)
353353
machine_ops.crash_shutdown = hv_machine_crash_shutdown;
354354
#endif
355355
if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
356+
/*
357+
* Writing to synthetic MSR 0x40000118 updates/changes the
358+
* guest visible CPUIDs. Setting bit 0 of this MSR enables
359+
* guests to report invariant TSC feature through CPUID
360+
* instruction, CPUID 0x800000007/EDX, bit 8. See code in
361+
* early_init_intel() where this bit is examined. The
362+
* setting of this MSR bit should happen before init_intel()
363+
* is called.
364+
*/
356365
wrmsrl(HV_X64_MSR_TSC_INVARIANT_CONTROL, 0x1);
357366
setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
358367
}

0 commit comments

Comments
 (0)