]> git.baikalelectronics.ru Git - kernel.git/commitdiff
kvm: x86: Guest BNDCFGS requires guest MPX support
authorJim Mattson <jmattson@google.com>
Wed, 24 May 2017 17:49:25 +0000 (10:49 -0700)
committerRadim Krčmář <rkrcmar@redhat.com>
Wed, 7 Jun 2017 14:28:15 +0000 (16:28 +0200)
The BNDCFGS MSR should only be exposed to the guest if the guest
supports MPX. (cf. the TSC_AUX MSR and RDTSCP.)

Fixes: 5a3fc88905906c02 ("KVM: x86: add MSR_IA32_BNDCFGS to msrs_to_save")
Change-Id: I3ad7c01bda616715137ceac878f3fa7e66b6b387
Signed-off-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/cpuid.h
arch/x86/kvm/vmx.c

index a6fd40aade7cbf9e798591382c2382267d3141fc..da67283830521dcdee6071c8b3d78225aed7ead0 100644 (file)
@@ -144,6 +144,14 @@ static inline bool guest_cpuid_has_rtm(struct kvm_vcpu *vcpu)
        return best && (best->ebx & bit(X86_FEATURE_RTM));
 }
 
+static inline bool guest_cpuid_has_mpx(struct kvm_vcpu *vcpu)
+{
+       struct kvm_cpuid_entry2 *best;
+
+       best = kvm_find_cpuid_entry(vcpu, 7, 0);
+       return best && (best->ebx & bit(X86_FEATURE_MPX));
+}
+
 static inline bool guest_cpuid_has_rdtscp(struct kvm_vcpu *vcpu)
 {
        struct kvm_cpuid_entry2 *best;
index 577bb1d75e1eadccca36eab7742a7678bd0363cf..a339e97e26a339f93a5baecfff58e2caaa56375e 100644 (file)
@@ -3195,7 +3195,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
                msr_info->data = vmcs_readl(GUEST_SYSENTER_ESP);
                break;
        case MSR_IA32_BNDCFGS:
-               if (!kvm_mpx_supported())
+               if (!kvm_mpx_supported() || !guest_cpuid_has_mpx(vcpu))
                        return 1;
                msr_info->data = vmcs_read64(GUEST_BNDCFGS);
                break;
@@ -3277,7 +3277,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
                vmcs_writel(GUEST_SYSENTER_ESP, data);
                break;
        case MSR_IA32_BNDCFGS:
-               if (!kvm_mpx_supported())
+               if (!kvm_mpx_supported() || !guest_cpuid_has_mpx(vcpu))
                        return 1;
                vmcs_write64(GUEST_BNDCFGS, data);
                break;