From 498939c29778d4c807afb68fa84141dce4c87e14 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 25 Mar 2021 17:40:04 +0100 Subject: [PATCH] hyperv: Fix CPU hotadd The following is from the Hyper-V specification v6.0b. Cpuid leaf 0x40000003 EDX: Bit 3: Support for physical CPU dynamic partitioning events is available. When Windows determines to be running under a hypervisor, it will require this cpuid bit to be set to support dynamic CPU operations. Cpuid leaf 0x40000004 EAX: Bit 5: Recommend using relaxed timing for this partition. If used, the VM should disable any watchdog timeouts that rely on the timely delivery of external interrupts. This bit has been figured out as required after seeing guest BSOD when CPU hotplug bit is enabled. Race conditions seem to arise after a hotplug operation, when a system watchdog has expired. Closes #1799. Signed-off-by: Anatol Belski (cherry picked from commit 5b168f54a69260137cf05a5fde229334c85c4af7) Signed-off-by: Rob Bradford --- vmm/src/cpu.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index ad42b8340..67bf9015a 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -742,10 +742,18 @@ impl CpuManager { | 1 << 2 // AccessSynicRegs | 1 << 3 // AccessSyntheticTimerRegs | 1 << 9, // AccessPartitionReferenceTsc + edx: 1 << 3, // CPU dynamic partitioning ..Default::default() }) .map_err(Error::CpuidKvmHyperV)?; - for i in 0x4000_0004..=0x4000_000a { + cpuid + .push(CpuIdEntry { + function: 0x4000_0004, + eax: 1 << 5, // Recommend relaxed timing + ..Default::default() + }) + .map_err(Error::CpuidKvmHyperV)?; + for i in 0x4000_0005..=0x4000_000a { cpuid .push(CpuIdEntry { function: i,