Skip to content

x86/speculation: Remedy the STIBP/IBPB overhead

Thomas Gleixner lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest28 patches 55 repliesIn review
  2. v124 patches 69 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/28x86/speculation: Update the TIF_SSBD commentarch/x86/include/asm/thread_info.h+1 -11 reply
2/28x86/speculation: Clean up spectre_v2_parse_cmdline()arch/x86/kernel/cpu/bugs.c+13 -141 reply
3/28x86/speculation: Remove unnecessary ret variable in cpu_show_common()arch/x86/kernel/cpu/bugs.c+1 -41 reply
4/28x86/speculation: Reorganize cpu_show_common()arch/x86/kernel/cpu/bugs.c+18 -22 replies
5/28x86/speculation: Disable STIBP when enhanced IBRS is in usearch/x86/kernel/cpu/bugs.c+7 -01 reply
6/28x86/speculation: Rename SSBD update functionsarch/x86/include/asm/spec-ctrl.h arch/x86/kernel/cpu/bugs.c arch/x86/kernel/process.c+11 -112 replies
7/28x86/speculation: Reorganize speculation control MSRs updatearch/x86/kernel/process.c+32 -102 replies
8/28sched/smt: Make sched_smt_present track topologykernel/sched/core.c+11 -83 replies
9/28x86/Kconfig: Select SCHED_SMT if SMP enabledarch/x86/Kconfig+1 -71 reply
10/28sched/smt: Expose sched_smt_present static keyinclude/linux/sched/smt.h kernel/sched/sched.h+19 -31 reply
11/28x86/speculation: Rework SMT state changearch/x86/kernel/cpu/bugs.c include/linux/sched/smt.h kernel/cpu.c+16 -120 replies
12/28x86/l1tf: Show actual SMT statearch/x86/kernel/cpu/bugs.c+3 -20 replies
13/28x86/speculation: Reorder the spec_v2 codearch/x86/kernel/cpu/bugs.c+84 -841 reply
14/28x86/speculation: Mark string arrays const correctlyarch/x86/kernel/cpu/bugs.c+3 -30 replies
15/28x86/speculataion: Mark command line parser data __initdataarch/x86/kernel/cpu/bugs.c+2 -20 replies
16/28x86/speculation: Unify conditional spectre v2 print functionsarch/x86/kernel/cpu/bugs.c+4 -130 replies
17/28x86/speculation: Add command line control for indirect branch speculationDocumentation/admin-guide/kernel-parameters.txt arch/x86/include/asm/nospec-branch.h arch/x86/kernel/cpu/bugs.c+156 -190 replies
18/28x86/speculation: Prepare for per task indirect branch speculation controlarch/x86/include/asm/msr-index.h arch/x86/include/asm/spec-ctrl.h arch/x86/include/asm/thread_info.h +2 more+44 -56 replies
19/28x86/process: Consolidate and simplify switch_to_xtra() codearch/x86/include/asm/switch_to.h arch/x86/kernel/process.c arch/x86/kernel/process.h +2 more+37 -221 reply
20/28x86/speculation: Avoid __switch_to_xtra() callsarch/x86/include/asm/thread_info.h arch/x86/kernel/process.h+26 -20 replies
21/28x86/speculation: Prepare for conditional IBPB in switch_mm()arch/x86/include/asm/nospec-branch.h arch/x86/include/asm/tlbflush.h arch/x86/kernel/cpu/bugs.c +1 more+110 -388 replies
22/28ptrace: Remove unused ptrace_may_access_sched() and MODE_IBRSinclude/linux/ptrace.h kernel/ptrace.c+0 -270 replies
23/28x86/speculation: Split out TIF updatearch/x86/kernel/cpu/bugs.c+23 -120 replies
24/28x86/speculation: Prepare arch_smt_update() for PRCTL modearch/x86/kernel/cpu/bugs.c+25 -213 replies
25/28x86/speculation: Add prctl() control for indirect branch speculationDocumentation/userspace-api/spec_ctrl.rst arch/x86/include/asm/nospec-branch.h arch/x86/kernel/cpu/bugs.c +3 more+88 -00 replies
26/28x86/speculation: Enable prctl mode for spectre_v2_userDocumentation/admin-guide/kernel-parameters.txt arch/x86/kernel/cpu/bugs.c+38 -101 reply
27/28x86/speculation: Add seccomp Spectre v2 user space protection modeDocumentation/admin-guide/kernel-parameters.txt arch/x86/include/asm/nospec-branch.h arch/x86/kernel/cpu/bugs.c+25 -216 replies
28/28x86/speculation: Provide IBPB always command line optionsDocumentation/admin-guide/kernel-parameters.txt arch/x86/kernel/cpu/bugs.c+35 -110 replies

Reviews trailers per patch

10 of 28 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchTim ChenThomas LendackyIngo MolnarKonrad Rzeszutek Wilk
SeriesR-b
1/28R-b
2/28R-b
3/28R-b
4/28R-b
5/28R-b
6/28R-b
7/28Originally-by R-b
8/28R-b
9/28R-b
10/28R-b
11/28
12/28
13/28
14/28
15/28
16/28
17/28Originally-by
18/28
19/28
20/28
21/28
22/28
23/28
24/28
25/28
26/28
27/28
28/28

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

Read the v2 thread

Cover letter [patch V2 00/28] x86/speculation: Remedy the STIBP/IBPB overhead

Thats hopefully the final version of this. Changes since V1:

- Renamed the command line option and related code to spectre_v2_user= as suggested by Josh.

- Thought more about the back to back optimization and finally left the IBPB code in switch_mm().

It still removes the ptrace check for the always IBPB case. That's substantial overhead for dubious value now that the default is conditional (prctl/seccomp) IBPB.

- Added two options which allow conditional STIBP and IBPB always mode.

- Addressed the review comments

Documentation is still work in progress. Thanks Andi for providing the first draft for it.

Still based on tip.git x86/pti as it has been discussed to remove the minimal RETPOLINE bandaid from stable kernels as well.

It's avaiable from git:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.x86/pti

Thanks,

tglx

8<------------------------

 Documentation/admin-guide/kernel-parameters.txt |   56 ++
 Documentation/userspace-api/spec_ctrl.rst       |    9 
 arch/x86/Kconfig                                |    8 
 arch/x86/include/asm/msr-index.h                |    5 
 arch/x86/include/asm/nospec-branch.h            |   14 
 arch/x86/include/asm/spec-ctrl.h                |   18 
 arch/x86/include/asm/switch_to.h                |    3 
 arch/x86/include/asm/thread_info.h              |   18 
 arch/x86/include/asm/tlbflush.h                 |    8 
 arch/x86/kernel/cpu/bugs.c                      |  520 ++++++++++++++++++------
 arch/x86/kernel/process.c                       |   79 ++-
 arch/x86/kernel/process.h                       |   39 +
 arch/x86/kernel/process_32.c                    |   10 
 arch/x86/kernel/process_64.c                    |   10 
 arch/x86/mm/tlb.c                               |  109 +++--
 include/linux/ptrace.h                          |   17 
 include/linux/sched.h                           |    9 
 include/linux/sched/smt.h                       |   20 
 include/uapi/linux/prctl.h                      |    1 
 kernel/cpu.c                                    |   15 
 kernel/ptrace.c                                 |   10 
 kernel/sched/core.c                             |   19 
 kernel/sched/sched.h                            |    4 
 tools/include/uapi/linux/prctl.h                |    1 
 24 files changed, 745 insertions(+), 257 deletions(-)