public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] IBPB cleanups and a fixup
@ 2025-02-19 22:08 Yosry Ahmed
  2025-02-19 22:08 ` [PATCH 1/6] x86/bugs: Move the X86_FEATURE_USE_IBPB check into callers Yosry Ahmed
                   ` (6 more replies)
  0 siblings, 7 replies; 21+ messages in thread
From: Yosry Ahmed @ 2025-02-19 22:08 UTC (permalink / raw)
  To: x86
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
	Andy Lutomirski, Sean Christopherson, Paolo Bonzini, kvm,
	linux-kernel

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.

I wanted to do more, but decided to stay conservative. I was mainly
hoping to merge indirect_branch_prediction_barrier() with entry_ibpb()
to have a single IBPB primitive that always stuffs the RSB if the IBPB
doesn't, but this would add some overhead in paths that currently use
indirect_branch_prediction_barrier(), and I was not sure if that's
acceptable.

For the record, my measurements of the latency of
indirect_branch_prediction_barrier() and entry_ibpb() on Rome and Milan
(both do not have X86_FEATURE_AMD_IBPB_RET) are as follows:

Rome:
400ns (indirect_branch_prediction_barrier) vs 500ns (entry_ibpb)

Milan:
220ns (indirect_branch_prediction_barrier) vs 280ns (entry_ibpb)

I also wanted to move controlling the IBPB on vCPU load from
being under spectre_v2_user to spectre_v2, because "user" in a lot of
mitigation contexts does not include VMs.

Just laying out these thoughts in case others have any comments.

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 load
  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               | 7 +++++--
 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(+), 9 deletions(-)

-- 
2.48.1.601.g30ceb7b040-goog


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2025-02-27  0:54 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 22:08 [PATCH 0/6] IBPB cleanups and a fixup Yosry Ahmed
2025-02-19 22:08 ` [PATCH 1/6] x86/bugs: Move the X86_FEATURE_USE_IBPB check into callers Yosry Ahmed
2025-02-25 19:47   ` Sean Christopherson
2025-02-25 21:28     ` Yosry Ahmed
2025-02-19 22:08 ` [PATCH 2/6] x86/mm: Remove X86_FEATURE_USE_IBPB checks in cond_mitigation() Yosry Ahmed
2025-02-19 22:08 ` [PATCH 3/6] x86/bugs: Remove the X86_FEATURE_USE_IBPB check in ib_prctl_set() Yosry Ahmed
2025-02-19 22:08 ` [PATCH 4/6] x86/bugs: Use a static branch to guard IBPB on vCPU load Yosry Ahmed
2025-02-25 19:49   ` Sean Christopherson
2025-02-25 21:27     ` Yosry Ahmed
2025-02-25 22:40       ` Sean Christopherson
2025-02-26  2:49         ` Yosry Ahmed
2025-02-27  0:46           ` Sean Christopherson
2025-02-27  0:54             ` Yosry Ahmed
2025-02-19 22:08 ` [PATCH 5/6] KVM: nVMX: Always use IBPB to properly virtualize IBRS Yosry Ahmed
2025-02-19 23:09   ` Jim Mattson
2025-02-25 19:50   ` Sean Christopherson
2025-02-19 22:08 ` [PATCH 6/6] x86/bugs: Remove X86_FEATURE_USE_IBPB Yosry Ahmed
2025-02-20 19:04 ` [PATCH 0/6] IBPB cleanups and a fixup Josh Poimboeuf
2025-02-20 19:59   ` Yosry Ahmed
2025-02-20 20:47     ` Josh Poimboeuf
2025-02-20 21:50       ` Yosry Ahmed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox