Messages in this thread | | | Date | Wed, 20 Oct 2021 12:44:42 +0200 | From | Peter Zijlstra <> | Subject | [PATCH v2 00/14] x86: Rewrite the retpoline rewrite logic |
| |
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.
Patches can also be found here:
git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git objtool/core
Changes since v1: - objtool: avoid self-modifying-code in .altinstr_replacement - objtool: shrink struct instruction - objtool: more cleanups - x86: more #ifdef - x86: GEN-for-each-reg cleanups/comments - x86: retpoline thunk array - x86,bpf: more complete retpoline replacement - build fixes
--- arch/um/kernel/um_arch.c | 4 + arch/x86/include/asm/GEN-for-each-reg.h | 13 ++- arch/x86/include/asm/alternative.h | 1 + arch/x86/include/asm/asm-prototypes.h | 6 +- arch/x86/include/asm/nospec-branch.h | 59 ---------- arch/x86/kernel/alternative.c | 192 ++++++++++++++++++++++++++++++- arch/x86/kernel/cpu/bugs.c | 7 -- arch/x86/kernel/module.c | 9 +- arch/x86/kernel/vmlinux.lds.S | 14 +++ arch/x86/lib/retpoline.S | 50 ++------ arch/x86/net/bpf_jit_comp.c | 71 +++++++----- arch/x86/net/bpf_jit_comp32.c | 22 +++- tools/objtool/arch/x86/decode.c | 120 -------------------- tools/objtool/check.c | 195 ++++++++++++++++++++++---------- tools/objtool/elf.c | 84 -------------- tools/objtool/include/objtool/check.h | 1 - tools/objtool/include/objtool/elf.h | 2 +- tools/objtool/special.c | 8 -- 18 files changed, 431 insertions(+), 427 deletions(-)
| |