Skip to content

Commit 0c54914

Browse files
committed
KVM: x86: use Intel speculation bugs and features as derived in generic x86 code
Similar to AMD bits, set the Intel bits from the vendor-independent feature and bug flags, because KVM_GET_SUPPORTED_CPUID does not care about the vendor and they should be set on AMD processors as well. Suggested-by: Jim Mattson <[email protected]> Reviewed-by: Jim Mattson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 50896de commit 0c54914

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index)
392392

393393
entry->edx &= kvm_cpuid_7_0_edx_x86_features;
394394
cpuid_mask(&entry->edx, CPUID_7_EDX);
395+
if (boot_cpu_has(X86_FEATURE_IBPB) && boot_cpu_has(X86_FEATURE_IBRS))
396+
entry->edx |= F(SPEC_CTRL);
397+
if (boot_cpu_has(X86_FEATURE_STIBP))
398+
entry->edx |= F(INTEL_STIBP);
399+
if (boot_cpu_has(X86_FEATURE_SSBD))
400+
entry->edx |= F(SPEC_CTRL_SSBD);
395401
/*
396402
* We emulate ARCH_CAPABILITIES in software even
397403
* if the host doesn't support it.

arch/x86/kvm/x86.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,13 @@ static u64 kvm_get_arch_capabilities(void)
12541254
if (l1tf_vmx_mitigation != VMENTER_L1D_FLUSH_NEVER)
12551255
data |= ARCH_CAP_SKIP_VMENTRY_L1DFLUSH;
12561256

1257+
if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN))
1258+
data |= ARCH_CAP_RDCL_NO;
1259+
if (!boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS))
1260+
data |= ARCH_CAP_SSB_NO;
1261+
if (!boot_cpu_has_bug(X86_BUG_MDS))
1262+
data |= ARCH_CAP_MDS_NO;
1263+
12571264
return data;
12581265
}
12591266

0 commit comments

Comments
 (0)