lkml.org 
[lkml]   [2021]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[PATCH 0/9] 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.

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(-)

\
 
 \ /
  Last update: 2021-10-13 14:43    [W:0.367 / U:0.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site