linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] x86: Rewrite the retpoline rewrite logic
@ 2021-10-13 12:22 Peter Zijlstra
  2021-10-13 12:22 ` [PATCH 1/9] objtool,x86: Replace alternatives with .retpoline_sites Peter Zijlstra
                   ` (8 more replies)
  0 siblings, 9 replies; 52+ messages in thread
From: Peter Zijlstra @ 2021-10-13 12:22 UTC (permalink / raw)
  To: x86, jpoimboe, andrew.cooper3
  Cc: linux-kernel, peterz, alexei.starovoitov, ndesaulniers

Hi,

These patches rewrite the way retpolines are rewritten. Currently objtool emits
alternative entries for most retpoline calls. However trying to extend that led
to trouble (ELF files are horrid).

Therefore completely overhaul this and have objtool emit a .retpoline_sites
section that lists all compiler generated retpoline thunk calls. Then the
kernel can do with them as it pleases.

Notably it will:

 - rewrite them to indirect instructions for !RETPOLINE
 - rewrite them to lfence; indirect; for RETPOLINE_AMD,
   where size allows (boo clang!)

Specifically, the !RETPOLINE case can now also deal with the clang-special
conditional-indirect-tail-call:

  Jcc __x86_indirect_thunk_\reg.

Finally, also update the x86 BPF jit to catch up to recent times and do these
same things.

All this should help improve performance by removing an indirection.

The series has been booted in kvm using 'debug-alternative spectre_v2=off' and
'debug-alternative spectre_v2=retpoline,amd' on a x86_64
defconfig+kvm_guest.config build. IOW, early days.

---
 arch/x86/include/asm/GEN-for-each-reg.h |  10 +-
 arch/x86/include/asm/alternative.h      |   1 +
 arch/x86/kernel/alternative.c           | 186 +++++++++++++++++++++++++++++++-
 arch/x86/kernel/cpu/bugs.c              |   7 --
 arch/x86/kernel/module.c                |   9 +-
 arch/x86/kernel/vmlinux.lds.S           |  12 +++
 arch/x86/lib/retpoline.S                |  42 --------
 arch/x86/net/bpf_jit_comp.c             |  18 ++--
 tools/objtool/arch/x86/decode.c         | 126 +++++-----------------
 tools/objtool/elf.c                     |  84 ---------------
 tools/objtool/include/objtool/elf.h     |   1 -
 11 files changed, 246 insertions(+), 250 deletions(-)


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

end of thread, other threads:[~2021-10-20  8:30 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 12:22 [PATCH 0/9] x86: Rewrite the retpoline rewrite logic Peter Zijlstra
2021-10-13 12:22 ` [PATCH 1/9] objtool,x86: Replace alternatives with .retpoline_sites Peter Zijlstra
2021-10-13 13:29   ` Borislav Petkov
2021-10-13 20:11   ` Josh Poimboeuf
2021-10-14 15:43     ` Peter Zijlstra
2021-10-13 12:22 ` [PATCH 2/9] x86/retpoline: Remove unused replacement symbols Peter Zijlstra
2021-10-13 12:22 ` [PATCH 3/9] x86/asm: Fix register order Peter Zijlstra
2021-10-13 20:15   ` Josh Poimboeuf
2021-10-13 12:22 ` [PATCH 4/9] x86/alternative: Implement .retpoline_sites support Peter Zijlstra
2021-10-13 14:38   ` Andrew Cooper
2021-10-13 15:12     ` Peter Zijlstra
2021-10-13 17:11       ` Andrew Cooper
2021-10-14 10:05       ` Peter Zijlstra
2021-10-13 20:39   ` Josh Poimboeuf
2021-10-13 21:20     ` Peter Zijlstra
2021-10-13 21:49       ` Josh Poimboeuf
2021-10-13 21:52         ` Josh Poimboeuf
2021-10-13 22:10         ` Peter Zijlstra
2021-10-13 22:47           ` Andrew Cooper
2021-10-13 20:52   ` Josh Poimboeuf
2021-10-13 21:00     ` Peter Zijlstra
2021-10-19 11:37     ` Peter Zijlstra
2021-10-19 16:46       ` Josh Poimboeuf
2021-10-19 16:49         ` Josh Poimboeuf
2021-10-20  8:25           ` Peter Zijlstra
2021-10-20  8:30           ` Peter Zijlstra
2021-10-13 21:11   ` Josh Poimboeuf
2021-10-13 21:43     ` Peter Zijlstra
2021-10-13 22:05       ` Josh Poimboeuf
2021-10-13 22:14         ` Peter Zijlstra
2021-10-15 14:24   ` Borislav Petkov
2021-10-15 16:56     ` Peter Zijlstra
2021-10-18 23:06       ` Alexander Lobakin
2021-10-19  0:25         ` Alexander Lobakin
2021-10-19  9:47           ` Alexander Lobakin
2021-10-19 10:16             ` Peter Zijlstra
2021-10-19 15:37               ` Sami Tolvanen
2021-10-19 18:00                 ` Alexander Lobakin
2021-10-19  9:40         ` Peter Zijlstra
2021-10-19 10:02           ` Peter Zijlstra
2021-10-13 12:22 ` [PATCH 5/9] x86/alternative: Handle Jcc __x86_indirect_thunk_\reg Peter Zijlstra
2021-10-13 20:11   ` Nick Desaulniers
2021-10-13 21:08     ` Peter Zijlstra
2021-10-13 12:22 ` [PATCH 6/9] x86/alternative: Try inline spectre_v2=retpoline,amd Peter Zijlstra
2021-10-13 12:22 ` [PATCH 7/9] x86/alternative: Add debug prints to apply_retpolines() Peter Zijlstra
2021-10-13 12:22 ` [PATCH 8/9] x86,bugs: Unconditionally allow spectre_v2=retpoline,amd Peter Zijlstra
2021-10-13 12:22 ` [PATCH 9/9] bpf,x86: Respect X86_FEATURE_RETPOLINE* Peter Zijlstra
2021-10-13 21:06   ` Josh Poimboeuf
2021-10-13 21:54     ` Peter Zijlstra
2021-10-14  9:46       ` Peter Zijlstra
2021-10-14  9:48         ` Peter Zijlstra
2021-10-20  7:34         ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).