Skip to content

IBPB cleanups and a fixup

Yosry Ahmed kvm lkml 2 versions – Applied

Status from this message: The following commit has been merged into the x86/bugs branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 2 repliesApplied
  2. v16 patches 14 repliesSuperseded

Changes in v2 from the cover letter

- Collected Ack/Review tags (thanks everyone!).
- Combined the if statements in vmx_vcpu_load_vmcs() and moved the static branch check ahead (Sean Christopherson).
- Renamed the static branch to switch_vcpu_ibpb (Sean Christopherson).
- Fixed a typo in the commit message (Jim Mattson).

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/6x86/bugs: Move the X86_FEATURE_USE_IBPB check into callersarch/x86/include/asm/nospec-branch.h arch/x86/kernel/cpu/bugs.c arch/x86/kvm/svm/svm.c +3 more+12 -81 reply
2/6x86/mm: Remove X86_FEATURE_USE_IBPB checks in cond_mitigation()arch/x86/mm/tlb.c+2 -40 replies
3/6x86/bugs: Remove the X86_FEATURE_USE_IBPB check in ib_prctl_set()arch/x86/kernel/cpu/bugs.c+1 -10 replies
4/6x86/bugs: Use a static branch to guard IBPB on vCPU switcharch/x86/include/asm/nospec-branch.h arch/x86/kernel/cpu/bugs.c arch/x86/kvm/svm/svm.c +1 more+9 -21 reply
5/6KVM: nVMX: Always use IBPB to properly virtualize IBRSarch/x86/kvm/vmx/nested.c+1 -20 replies
6/6x86/bugs: Remove X86_FEATURE_USE_IBPBarch/x86/include/asm/cpufeatures.h arch/x86/kernel/cpu/bugs.c tools/arch/x86/include/asm/cpufeatures.h+0 -30 replies

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchJosh PoimboeufJim MattsonSean Christopherson
1/6A-b A-b
2/6A-b
3/6A-b
4/6A-b A-b
5/6A-b R-b A-b
6/6A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/6] IBPB cleanups and a fixup

This series removes X86_FEATURE_USE_IBPB, and fixes a KVM nVMX bug in the process. The motivation is mostly the confusing name of X86_FEATURE_USE_IBPB, which sounds like it controls IBPBs in general, but it only controls IBPBs for spectre_v2_mitigation. A side effect of this confusion is the nVMX bug, where virtualizing IBRS correctly depends on the spectre_v2_user mitigation.

The feature bit is mostly redundant, except in controlling the IBPB in the vCPU load path. For that, a separate static branch is introduced, similar to switch_mm_*_ibpb.

We should also unify indirect_branch_prediction_barrier() with entry_ibpb() to have a single IBPB primitive that always stuffs the RSB if needed. Josh will be sending follow up changes for that.

v1 -> v2:
- Collected Ack/Review tags (thanks everyone!).
- Combined the if statements in vmx_vcpu_load_vmcs() and moved the static branch check ahead (Sean Christopherson).
- Renamed the static branch to switch_vcpu_ibpb (Sean Christopherson).
- Fixed a typo in the commit message (Jim Mattson).

Yosry Ahmed (6):
x86/bugs: Move the X86_FEATURE_USE_IBPB check into callers x86/mm: Remove X86_FEATURE_USE_IBPB checks in cond_mitigation() x86/bugs: Remove the X86_FEATURE_USE_IBPB check in ib_prctl_set() x86/bugs: Use a static branch to guard IBPB on vCPU switch
KVM: nVMX: Always use IBPB to properly virtualize IBRS x86/bugs: Remove X86_FEATURE_USE_IBPB

 arch/x86/include/asm/cpufeatures.h       | 1 -
 arch/x86/include/asm/nospec-branch.h     | 4 +++-
 arch/x86/kernel/cpu/bugs.c               | 6 +++++-
 arch/x86/kvm/svm/svm.c                   | 3 ++-
 arch/x86/kvm/vmx/vmx.c                   | 3 ++-
 arch/x86/mm/tlb.c                        | 3 +--
 tools/arch/x86/include/asm/cpufeatures.h | 1 -
 7 files changed, 13 insertions(+), 8 deletions(-)
Signature · 1 line
2.48.1.658.g4767266eb4-goog