]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: VMX: Fix IBRS handling after vmexit
authorJosh Poimboeuf <jpoimboe@kernel.org>
Mon, 3 Oct 2022 13:10:30 +0000 (10:10 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Oct 2022 07:16:56 +0000 (09:16 +0200)
commit 2d2a6410a9f4f1d8f406812b4b7700e92e68e213 upstream.

For legacy IBRS to work, the IBRS bit needs to be always re-written
after vmexit, even if it's already on.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/vmx/vmx.c

index 85d5dfb261f5484fc07fdebfe89a0c1f5b519f6b..d522c9de41df9be0cb8c668a35d6f8a2ff6673f4 100644 (file)
@@ -6571,8 +6571,13 @@ void noinstr vmx_spec_ctrl_restore_host(struct vcpu_vmx *vmx,
 
        /*
         * If the guest/host SPEC_CTRL values differ, restore the host value.
+        *
+        * For legacy IBRS, the IBRS bit always needs to be written after
+        * transitioning from a less privileged predictor mode, regardless of
+        * whether the guest/host values differ.
         */
-       if (vmx->spec_ctrl != hostval)
+       if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) ||
+           vmx->spec_ctrl != hostval)
                native_wrmsrl(MSR_IA32_SPEC_CTRL, hostval);
 
        barrier_nospec();