Skip to content

Commit 24778b1

Browse files
bonziniMichael Tokarev
authored andcommitted
target/i386: do not expose ARCH_CAPABILITIES on AMD CPU
KVM emulates the ARCH_CAPABILITIES on x86 for both Intel and AMD cpus, although the IA32_ARCH_CAPABILITIES MSR is an Intel-specific MSR and it makes no sense to emulate it on AMD. As a consequence, VMs created on AMD with qemu -cpu host and using KVM will advertise the ARCH_CAPABILITIES feature and provide the IA32_ARCH_CAPABILITIES MSR. This can cause issues (like Windows BSOD) as the guest OS might not expect this MSR to exist on such cpus (the AMD documentation specifies that ARCH_CAPABILITIES feature and MSR are not defined on the AMD architecture). A fix was proposed in KVM code, however KVM maintainers don't want to change this behavior that exists for 6+ years and suggest changes to be done in QEMU instead. Therefore, hide the bit from "-cpu host": migration of -cpu host guests is only possible between identical host kernel and QEMU versions, therefore this is not a problematic breakage. If a future AMD machine does include the MSR, that would re-expose the Windows guest bug; but it would not be KVM/QEMU's problem at that point, as we'd be following a genuine physical CPU impl. Reported-by: Alexandre Chartre <[email protected]> Suggested-by: Daniel P. Berrangé <[email protected]> Reviewed-by: Xiaoyao Li <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> (cherry picked from commit d3a24134e37d57abd3e7445842cda2717f49e96d) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 8251738 commit 24778b1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

target/i386/kvm/kvm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,12 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
500500
* Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM hosts.
501501
* We can detect the bug by checking if MSR_IA32_ARCH_CAPABILITIES is
502502
* returned by KVM_GET_MSR_INDEX_LIST.
503+
*
504+
* But also, because Windows does not like ARCH_CAPABILITIES on AMD
505+
* mcahines at all, do not show the fake ARCH_CAPABILITIES MSR that
506+
* KVM sets up.
503507
*/
504-
if (!has_msr_arch_capabs) {
508+
if (!has_msr_arch_capabs || !(edx & CPUID_7_0_EDX_ARCH_CAPABILITIES)) {
505509
ret &= ~CPUID_7_0_EDX_ARCH_CAPABILITIES;
506510
}
507511
} else if (function == 7 && index == 1 && reg == R_EAX) {

0 commit comments

Comments
 (0)