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: 0dd376e709
("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>
This commit is contained in:
parent
be6f33a61f
commit
a40f0ccd4f
2 changed files with 10 additions and 2 deletions
|
@ -143,6 +143,14 @@ static inline bool guest_cpuid_has_pcommit(struct kvm_vcpu *vcpu)
|
||||||
return best && (best->ebx & bit(X86_FEATURE_PCOMMIT));
|
return best && (best->ebx & bit(X86_FEATURE_PCOMMIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
static inline bool guest_cpuid_has_rdtscp(struct kvm_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
struct kvm_cpuid_entry2 *best;
|
struct kvm_cpuid_entry2 *best;
|
||||||
|
|
|
@ -2812,7 +2812,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
|
||||||
msr_info->data = vmcs_readl(GUEST_SYSENTER_ESP);
|
msr_info->data = vmcs_readl(GUEST_SYSENTER_ESP);
|
||||||
break;
|
break;
|
||||||
case MSR_IA32_BNDCFGS:
|
case MSR_IA32_BNDCFGS:
|
||||||
if (!kvm_mpx_supported())
|
if (!kvm_mpx_supported() || !guest_cpuid_has_mpx(vcpu))
|
||||||
return 1;
|
return 1;
|
||||||
msr_info->data = vmcs_read64(GUEST_BNDCFGS);
|
msr_info->data = vmcs_read64(GUEST_BNDCFGS);
|
||||||
break;
|
break;
|
||||||
|
@ -2889,7 +2889,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
|
||||||
vmcs_writel(GUEST_SYSENTER_ESP, data);
|
vmcs_writel(GUEST_SYSENTER_ESP, data);
|
||||||
break;
|
break;
|
||||||
case MSR_IA32_BNDCFGS:
|
case MSR_IA32_BNDCFGS:
|
||||||
if (!kvm_mpx_supported())
|
if (!kvm_mpx_supported() || !guest_cpuid_has_mpx(vcpu))
|
||||||
return 1;
|
return 1;
|
||||||
vmcs_write64(GUEST_BNDCFGS, data);
|
vmcs_write64(GUEST_BNDCFGS, data);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue