From c9308233677dc6ea9ef5f1299e3e2c2b7ba10978 Mon Sep 17 00:00:00 2001 From: Jun Nakajima Date: Wed, 20 Dec 2017 08:04:53 -0800 Subject: [PATCH] Use the ibpb_inuse variable. Orabug: 27344012 CVE: CVE-2017-5715 Signed-off-by: Jun Nakajima Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: John Haxby Signed-off-by: Kirtikar Kashyap --- arch/x86/kvm/svm.c | 4 ++-- arch/x86/kvm/vmx.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index a9b04baf01b32..8cc1f5347d75d 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1310,7 +1310,7 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu) * The VMCB could be recycled, causing a false negative in svm_vcpu_load; * block speculative execution. */ - if (static_cpu_has(X86_FEATURE_IBPB_SUPPORT)) + if (ibpb_inuse) wrmsrl(MSR_IA32_PRED_CMD, FEATURE_SET_IBPB); } @@ -1342,7 +1342,7 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu) } if (sd->current_vmcb != svm->vmcb) { sd->current_vmcb = svm->vmcb; - if (static_cpu_has(X86_FEATURE_IBPB_SUPPORT)) + if (ibpb_inuse) wrmsrl(MSR_IA32_PRED_CMD, FEATURE_SET_IBPB); } diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index a245dce60bfad..cd15ec76602f4 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -8181,7 +8181,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) vmx_set_interrupt_shadow(vcpu, 0); - if (static_cpu_has(X86_FEATURE_SPEC_CTRL) && + if (ibpb_inuse && vmx->spec_ctrl != FEATURE_ENABLE_IBRS) wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); @@ -8311,7 +8311,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) #endif ); - if (static_cpu_has(X86_FEATURE_SPEC_CTRL)) { + if (ibpb_inuse) { rdmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); if (vmx->spec_ctrl) wrmsrl(MSR_IA32_SPEC_CTRL, FEATURE_ENABLE_IBRS); -- 2.50.1