Skip to content

Commit 2770d47

Browse files
maciejsszmigierosean-jc
authored andcommitted
KVM: x86: Ignore MSR_AMD64_TW_CFG access
Hyper-V enabled Windows Server 2022 KVM VM cannot be started on Zen1 Ryzen since it crashes at boot with SYSTEM_THREAD_EXCEPTION_NOT_HANDLED + STATUS_PRIVILEGED_INSTRUCTION (in other words, because of an unexpected #GP in the guest kernel). This is because Windows tries to set bit 8 in MSR_AMD64_TW_CFG and can't handle receiving a #GP when doing so. Give this MSR the same treatment that commit 2e32b71 ("x86, kvm: Add MSR_AMD64_BU_CFG2 to the list of ignored MSRs") gave MSR_AMD64_BU_CFG2 under justification that this MSR is baremetal-relevant only. Although apparently it was then needed for Linux guests, not Windows as in this case. With this change, the aforementioned guest setup is able to finish booting successfully. This issue can be reproduced either on a Summit Ridge Ryzen (with just "-cpu host") or on a Naples EPYC (with "-cpu host,stepping=1" since EPYC is ordinarily stepping 2). Alternatively, userspace could solve the problem by using MSR filters, but forcing every userspace to define a filter isn't very friendly and doesn't add much, if any, value. The only potential hiccup is if one of these "baremetal-only" MSRs ever requires actual emulation and/or has F/M/S specific behavior. But if that happens, then KVM can still punt *that* handling to userspace since userspace MSR filters "win" over KVM's default handling. Signed-off-by: Maciej S. Szmigiero <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/1ce85d9c7c9e9632393816cf19c902e0a3f411f1.1697731406.git.maciej.szmigiero@oracle.com [sean: call out MSR filtering alternative] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 122ae01 commit 2770d47

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

arch/x86/include/asm/msr-index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@
553553
#define MSR_AMD64_CPUID_FN_1 0xc0011004
554554
#define MSR_AMD64_LS_CFG 0xc0011020
555555
#define MSR_AMD64_DC_CFG 0xc0011022
556+
#define MSR_AMD64_TW_CFG 0xc0011023
556557

557558
#define MSR_AMD64_DE_CFG 0xc0011029
558559
#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT 1

arch/x86/kvm/x86.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,6 +3722,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
37223722
case MSR_AMD64_PATCH_LOADER:
37233723
case MSR_AMD64_BU_CFG2:
37243724
case MSR_AMD64_DC_CFG:
3725+
case MSR_AMD64_TW_CFG:
37253726
case MSR_F15H_EX_CFG:
37263727
break;
37273728

@@ -4168,6 +4169,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
41684169
case MSR_AMD64_BU_CFG2:
41694170
case MSR_IA32_PERF_CTL:
41704171
case MSR_AMD64_DC_CFG:
4172+
case MSR_AMD64_TW_CFG:
41714173
case MSR_F15H_EX_CFG:
41724174
/*
41734175
* Intel Sandy Bridge CPUs must support the RAPL (running average power

0 commit comments

Comments
 (0)