Skip to content

Commit bd72249

Browse files
committed
x86/KVM/VMX: Expose SPEC_CTRL Bit(2) to the guest
Expose the CPUID.7.EDX[31] bit to the guest, and also guard against various combinations of SPEC_CTRL MSR values. The handling of the MSR (to take into account the host value of SPEC_CTRL Bit(2)) is taken care of in patch: KVM/SVM/VMX/x86/spectre_v2: Support the combination of guest and host IBRS Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> (cherry picked from commit da39556) Orabug: 28034177 CVE: CVE-2018-3639 Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Mihai Carabas <[email protected]> Reviewed-by: Mihai Carabas <[email protected]> Reviewed-by: John Haxby <[email protected]> Conflicts: arch/x86/kvm/vmx.c [As we were using our own define for #SPEC_CTRL_MSR]
1 parent d4b75c9 commit bd72249

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
402402

403403
/* cpuid 7.0.edx*/
404404
const u32 kvm_cpuid_7_0_edx_x86_features =
405-
F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
405+
F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(RDS) |
406406
F(ARCH_CAPABILITIES);
407407

408408
/* all calls to cpuid_count() should be made on the same cpu */

arch/x86/kvm/vmx.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,7 +3283,8 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
32833283
case MSR_IA32_SPEC_CTRL:
32843284
if (!msr_info->host_initiated &&
32853285
!guest_cpuid_has(vcpu, X86_FEATURE_IBRS) &&
3286-
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))
3286+
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
3287+
!guest_cpuid_has(vcpu, X86_FEATURE_RDS))
32873288
return 1;
32883289

32893290
msr_info->data = to_vmx(vcpu)->spec_ctrl;
@@ -3404,11 +3405,12 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
34043405
case MSR_IA32_SPEC_CTRL:
34053406
if (!msr_info->host_initiated &&
34063407
!guest_cpuid_has(vcpu, X86_FEATURE_IBRS) &&
3407-
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))
3408+
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
3409+
!guest_cpuid_has(vcpu, X86_FEATURE_RDS))
34083410
return 1;
34093411

34103412
/* The STIBP bit doesn't fault even if it's not advertised */
3411-
if (data & ~(SPEC_CTRL_FEATURE_ENABLE_IBRS | SPEC_CTRL_STIBP))
3413+
if (data & ~(SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_RDS))
34123414
return 1;
34133415

34143416
vmx->spec_ctrl = data;

0 commit comments

Comments
 (0)