Skip to content

Commit 27ff58a

Browse files
mhklinuxchessturo
authored andcommitted
x86/hyperv: Don’t enable TSCInvariant on some older Hyper-V hosts
Hyper-V host builds earlier than 22621 (Windows 11 22H2) have a bug in the TSC Invariant feature that may result in the guest seeing a "slow" TSC after the Hyper-V host resumes from hiberation. As a result, time advances more slowly in the guest than in the host. When Linux programs the Hyper-V synthetic timer, the timer interrupt can occur sooner than expected or even immediately. As the guest time falls further and further behind, a timer interrupt storm and unresponsive Linux guest can result, along with excessive load on the host. Since the problem occurs only after a Hyper-V host resumes from hibernation, the scenario is primarily on Windows client devices that are running Linux guests such as WSLv2. Avoid the bug by assuming the TSC Invariant feature is not present when WSLv2 is running on these builds. Closes: microsoft/WSL#6982 Signed-off-by: Michael Kelley <mhklinux@outlook.com> Signed-off-by: Mitchell Levy <levymitchell0@gmail.com>
1 parent c5994cd commit 27ff58a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ int hv_get_hypervisor_version(union hv_hypervisor_version_info *info)
364364

365365
static void __init ms_hyperv_init_platform(void)
366366
{
367+
union hv_hypervisor_version_info version;
368+
unsigned int build = 0;
367369
int hv_max_functions_eax;
368370

369371
#ifdef CONFIG_PARAVIRT
@@ -390,6 +392,18 @@ static void __init ms_hyperv_init_platform(void)
390392
pr_debug("Hyper-V: max %u virtual processors, %u logical processors\n",
391393
ms_hyperv.max_vp_index, ms_hyperv.max_lp_index);
392394

395+
/*
396+
* Host builds earlier than 22621 (Win 11 22H2) have a bug in the
397+
* invariant TSC feature that may result in the guest seeing a "slow"
398+
* TSC after host hibernation. This causes problems with synthetic
399+
* timer interrupts. In such a case, avoid the bug by assuming the
400+
* feature is not present.
401+
*/
402+
if (!hv_get_hypervisor_version(&version))
403+
build = version.build_number;
404+
if (build < 22621)
405+
ms_hyperv.features &= ~HV_ACCESS_TSC_INVARIANT;
406+
393407
/*
394408
* Check CPU management privilege.
395409
*

0 commit comments

Comments
 (0)