Re: [PATCH v3 00/16] x86: Rewrite the retpoline rewrite logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 26, 2021 at 02:01:32PM +0200, Peter Zijlstra wrote:
> 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 (soon) be found here:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git objtool/core
> 
> Changes since v2:
> 
>  - rewrite the __x86_indirect_thunk_array[] stuff again
>  - rewrite the retpoline,amd rewrite logic, it now also supports
>    rewriting the Jcc case, if the original instruction is long enough, but
>    more importantly, it's simpler code.
>  - bpf label simplification patch
>  - random assorted cleanups
>  - actually managed to get bpf selftests working
> 
> ---
>  arch/um/kernel/um_arch.c                |   4 +
>  arch/x86/include/asm/GEN-for-each-reg.h |  14 ++-
>  arch/x86/include/asm/alternative.h      |   1 +
>  arch/x86/include/asm/asm-prototypes.h   |  18 ---
>  arch/x86/include/asm/nospec-branch.h    |  72 ++---------
>  arch/x86/kernel/alternative.c           | 189 ++++++++++++++++++++++++++++-
>  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                |  56 ++-------
>  arch/x86/net/bpf_jit_comp.c             | 160 +++++++++---------------
>  arch/x86/net/bpf_jit_comp32.c           |  22 +++-
>  tools/objtool/arch/x86/decode.c         | 120 ------------------
>  tools/objtool/check.c                   | 208 ++++++++++++++++++++++----------
>  tools/objtool/elf.c                     |  84 -------------
>  tools/objtool/include/objtool/check.h   |   1 -
>  tools/objtool/include/objtool/elf.h     |   6 +-
>  tools/objtool/special.c                 |   8 --
>  18 files changed, 472 insertions(+), 521 deletions(-)

Ok, this all looks real nice, thx!

Reviewed-by: Borislav Petkov <bp@xxxxxxx> 

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux