Skip to content

Commit da39556

Browse files
konradwilkKAGA-KOKO
authored andcommitted
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]>
1 parent 764f3c2 commit da39556

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
@@ -407,7 +407,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
407407

408408
/* cpuid 7.0.edx*/
409409
const u32 kvm_cpuid_7_0_edx_x86_features =
410-
F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
410+
F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(RDS) |
411411
F(ARCH_CAPABILITIES);
412412

413413
/* 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
@@ -3524,7 +3524,8 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
35243524
case MSR_IA32_SPEC_CTRL:
35253525
if (!msr_info->host_initiated &&
35263526
!guest_cpuid_has(vcpu, X86_FEATURE_IBRS) &&
3527-
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))
3527+
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
3528+
!guest_cpuid_has(vcpu, X86_FEATURE_RDS))
35283529
return 1;
35293530

35303531
msr_info->data = to_vmx(vcpu)->spec_ctrl;
@@ -3643,11 +3644,12 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
36433644
case MSR_IA32_SPEC_CTRL:
36443645
if (!msr_info->host_initiated &&
36453646
!guest_cpuid_has(vcpu, X86_FEATURE_IBRS) &&
3646-
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))
3647+
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
3648+
!guest_cpuid_has(vcpu, X86_FEATURE_RDS))
36473649
return 1;
36483650

36493651
/* The STIBP bit doesn't fault even if it's not advertised */
3650-
if (data & ~(SPEC_CTRL_IBRS | SPEC_CTRL_STIBP))
3652+
if (data & ~(SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_RDS))
36513653
return 1;
36523654

36533655
vmx->spec_ctrl = data;

0 commit comments

Comments
 (0)