x86: Remove dynamic NOP selection
This ensures that a NOP is a NOP and not a random other instruction that is also a NOP. It allows simplification of dynamic code patching that wants to verify existing code before writing new instructions (ftrace, jump_label, static_call, etc..). Differentiating on NOPs is not a feature. This pessimises 32bit (DONTCARE) and 32bit on 64bit CPUs (CARELESS). 32bit is not a performance target. Everything x86_64 since AMD K10 (2007) and Intel IvyBridge (2012) is fine with using NOPL (as opposed to prefix NOP). And per FEATURE_NOPL being required for x86_64, all x86_64 CPUs can use NOPL. So stop caring about NOPs, simplify things and get on with life. [ The problem seems to be that some uarchs can only decode NOPL on a single front-end port while others have severe decode penalties for excessive prefixes. All modern uarchs can handle both, except Atom, which has prefix penalties. ] [ Also, much doubt you can actually measure any of this on normal workloads. ] After this, FEATURE_NOPL is unused except for required-features for x86_64. FEATURE_K8 is only used for PTI. [ bp: Kernel build measurements showed ~0.3s slowdown on Sandybridge which is hardly a slowdown. Get rid of X86_FEATURE_K7, while at it. ] Signed-off-by:Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by:
Borislav Petkov <bp@suse.de> Acked-by: Alexei Starovoitov <alexei.starovoitov@gmail.com> # bpf Acked-by:
Linus Torvalds <torvalds@linuxfoundation.org> Link: https://lkml.kernel.org/r/20210312115749.065275711@infradead.org
Showing
- arch/x86/include/asm/cpufeatures.h 1 addition, 1 deletionarch/x86/include/asm/cpufeatures.h
- arch/x86/include/asm/jump_label.h 3 additions, 9 deletionsarch/x86/include/asm/jump_label.h
- arch/x86/include/asm/nops.h 55 additions, 121 deletionsarch/x86/include/asm/nops.h
- arch/x86/include/asm/special_insns.h 2 additions, 2 deletionsarch/x86/include/asm/special_insns.h
- arch/x86/kernel/alternative.c 21 additions, 177 deletionsarch/x86/kernel/alternative.c
- arch/x86/kernel/cpu/amd.c 0 additions, 5 deletionsarch/x86/kernel/cpu/amd.c
- arch/x86/kernel/ftrace.c 2 additions, 2 deletionsarch/x86/kernel/ftrace.c
- arch/x86/kernel/jump_label.c 6 additions, 26 deletionsarch/x86/kernel/jump_label.c
- arch/x86/kernel/kprobes/core.c 1 addition, 1 deletionarch/x86/kernel/kprobes/core.c
- arch/x86/kernel/setup.c 0 additions, 1 deletionarch/x86/kernel/setup.c
- arch/x86/kernel/static_call.c 2 additions, 2 deletionsarch/x86/kernel/static_call.c
- arch/x86/net/bpf_jit_comp.c 4 additions, 4 deletionsarch/x86/net/bpf_jit_comp.c
Loading
Please register or sign in to comment