Skip to content

Commit a40f0cc

Browse files
jsmattsonjrgregkh
authored andcommitted
kvm: x86: Guest BNDCFGS requires guest MPX support
commit 4439af9f911ae0243ffe4e2dfc12bace49605d8b upstream. The BNDCFGS MSR should only be exposed to the guest if the guest supports MPX. (cf. the TSC_AUX MSR and RDTSCP.) Fixes: 0dd376e ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent be6f33a commit a40f0cc

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

arch/x86/kvm/cpuid.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ static inline bool guest_cpuid_has_pcommit(struct kvm_vcpu *vcpu)
143143
return best && (best->ebx & bit(X86_FEATURE_PCOMMIT));
144144
}
145145

146+
static inline bool guest_cpuid_has_mpx(struct kvm_vcpu *vcpu)
147+
{
148+
struct kvm_cpuid_entry2 *best;
149+
150+
best = kvm_find_cpuid_entry(vcpu, 7, 0);
151+
return best && (best->ebx & bit(X86_FEATURE_MPX));
152+
}
153+
146154
static inline bool guest_cpuid_has_rdtscp(struct kvm_vcpu *vcpu)
147155
{
148156
struct kvm_cpuid_entry2 *best;

arch/x86/kvm/vmx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,7 +2812,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
28122812
msr_info->data = vmcs_readl(GUEST_SYSENTER_ESP);
28132813
break;
28142814
case MSR_IA32_BNDCFGS:
2815-
if (!kvm_mpx_supported())
2815+
if (!kvm_mpx_supported() || !guest_cpuid_has_mpx(vcpu))
28162816
return 1;
28172817
msr_info->data = vmcs_read64(GUEST_BNDCFGS);
28182818
break;
@@ -2889,7 +2889,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
28892889
vmcs_writel(GUEST_SYSENTER_ESP, data);
28902890
break;
28912891
case MSR_IA32_BNDCFGS:
2892-
if (!kvm_mpx_supported())
2892+
if (!kvm_mpx_supported() || !guest_cpuid_has_mpx(vcpu))
28932893
return 1;
28942894
vmcs_write64(GUEST_BNDCFGS, data);
28952895
break;

0 commit comments

Comments
 (0)