Skip to content

Commit 8c4f28c

Browse files
yosrym93Ingo Molnar
authored andcommitted
KVM: nVMX: Always use IBPB to properly virtualize IBRS
On synthesized nested VM-exits in VMX, an IBPB is performed if IBRS is advertised to the guest to properly provide separate prediction domains for L1 and L2. However, this is currently conditional on X86_FEATURE_USE_IBPB, which depends on the host spectre_v2_user mitigation. In short, if spectre_v2_user=no, IBRS is not virtualized correctly and L1 becomes susceptible to attacks from L2. Fix this by performing the IBPB regardless of X86_FEATURE_USE_IBPB. Fixes: 2e7eab8 ("KVM: VMX: Execute IBPB on emulated VM-exit when guest has IBRS") Signed-off-by: Yosry Ahmed <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Jim Mattson <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Acked-by: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 80dacb0 commit 8c4f28c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5026,8 +5026,7 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
50265026
* doesn't isolate different VMCSs, i.e. in this case, doesn't provide
50275027
* separate modes for L2 vs L1.
50285028
*/
5029-
if (guest_cpu_cap_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
5030-
cpu_feature_enabled(X86_FEATURE_USE_IBPB))
5029+
if (guest_cpu_cap_has(vcpu, X86_FEATURE_SPEC_CTRL))
50315030
indirect_branch_prediction_barrier();
50325031

50335032
/* Update any VMCS fields that might have changed while L2 ran */

0 commit comments

Comments
 (0)