Commit 86ecc9d3 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Juerg Haefliger

KVM/x86: Remove indirect MSR op calls from SPEC_CTRL

BugLink: https://bugs.launchpad.net/bugs/1811080

commit ecb586bd upstream.

Having a paravirt indirect call in the IBRS restore path is not a
good idea, since we are trying to protect from speculative execution
of bogus indirect branch targets.  It is also slower, so use
native_wrmsrl() on the vmentry path too.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarJim Mattson <jmattson@google.com>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: KarimAllah Ahmed <karahmed@amazon.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: kvm@vger.kernel.org
Cc: stable@vger.kernel.org
Fixes: d28b387f
Link: http://lkml.kernel.org/r/20180222154318.20361-2-pbonzini@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 4.4: adjust context]
Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
[juergh: Backported to Xenial 4.4: Dropped replacements of wrmsrl (code not
 present in Xenial).]
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 60634bf0
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <asm/desc.h> #include <asm/desc.h>
#include <asm/debugreg.h> #include <asm/debugreg.h>
#include <asm/kvm_para.h> #include <asm/kvm_para.h>
#include <asm/microcode.h>
#include <asm/spec-ctrl.h> #include <asm/spec-ctrl.h>
#include <asm/virtext.h> #include <asm/virtext.h>
...@@ -4049,7 +4050,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) ...@@ -4049,7 +4050,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
* save it. * save it.
*/ */
if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)) if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL))
rdmsrl(MSR_IA32_SPEC_CTRL, svm->spec_ctrl); svm->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL);
x86_spec_ctrl_restore_host(svm->spec_ctrl, svm->virt_spec_ctrl); x86_spec_ctrl_restore_host(svm->spec_ctrl, svm->virt_spec_ctrl);
......
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
#include <asm/kexec.h> #include <asm/kexec.h>
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/irq_remapping.h> #include <asm/irq_remapping.h>
#include <asm/spec-ctrl.h>
#include <asm/microcode.h> #include <asm/microcode.h>
#include <asm/spec-ctrl.h>
#include "trace.h" #include "trace.h"
#include "pmu.h" #include "pmu.h"
...@@ -9052,7 +9052,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) ...@@ -9052,7 +9052,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
* save it. * save it.
*/ */
if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)) if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL))
rdmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); vmx->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL);
x86_spec_ctrl_restore_host(vmx->spec_ctrl, 0); x86_spec_ctrl_restore_host(vmx->spec_ctrl, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment