Skip to content

Commit df7e881

Browse files
committed
KVM: SVM: relax conditions for allowing MSR_IA32_SPEC_CTRL accesses
Userspace that does not know about the AMD_IBRS bit might still allow the guest to protect itself with MSR_IA32_SPEC_CTRL using the Intel SPEC_CTRL bit. However, svm.c disallows this and will cause a #GP in the guest when writing to the MSR. Fix this by loosening the test and allowing the Intel CPUID bit, and in fact allow the AMD_STIBP bit as well since it allows writing to MSR_IA32_SPEC_CTRL too. Reported-by: Zhiyi Guo <[email protected]> Analyzed-by: Dr. David Alan Gilbert <[email protected]> Analyzed-by: Laszlo Ersek <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 4400cf5 commit df7e881

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/kvm/svm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4225,6 +4225,8 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
42254225
break;
42264226
case MSR_IA32_SPEC_CTRL:
42274227
if (!msr_info->host_initiated &&
4228+
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
4229+
!guest_cpuid_has(vcpu, X86_FEATURE_AMD_STIBP) &&
42284230
!guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBRS) &&
42294231
!guest_cpuid_has(vcpu, X86_FEATURE_AMD_SSBD))
42304232
return 1;
@@ -4310,6 +4312,8 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
43104312
break;
43114313
case MSR_IA32_SPEC_CTRL:
43124314
if (!msr->host_initiated &&
4315+
!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
4316+
!guest_cpuid_has(vcpu, X86_FEATURE_AMD_STIBP) &&
43134317
!guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBRS) &&
43144318
!guest_cpuid_has(vcpu, X86_FEATURE_AMD_SSBD))
43154319
return 1;

0 commit comments

Comments
 (0)