Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

asm goto: eradicate CC_HAS_ASM_GOTO

GCC has supported asm goto since 4.5, and Clang has since version 9.0.0.
The minimum supported versions of these tools for the build according to
Documentation/process/changes.rst are 5.1 and 11.0.0 respectively.

Remove the feature detection script, Kconfig option, and clean up some
fallback code that is no longer supported.

The removed script was also testing for a GCC specific bug that was
fixed in the 4.7 release.

Also remove workarounds for bpftrace using clang older than 9.0.0, since
other BPF backend fixes are required at this point.

Link: https://lore.kernel.org/lkml/CAK7LNATSr=BXKfkdW8f-H5VT_w=xBpT2ZQcZ7rm6JfkdE+QnmA@mail.gmail.com/
Link: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48637
Acked-by: Borislav Petkov <bp@suse.de>
Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Suggested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Nick Desaulniers and committed by
Linus Torvalds
a0a12c3e 15b3f48a

+7 -89
+2 -2
Documentation/kbuild/kconfig-language.rst
··· 525 525 If you need to expose a compiler capability to makefiles and/or C source files, 526 526 `CC_HAS_` is the recommended prefix for the config option:: 527 527 528 - config CC_HAS_ASM_GOTO 529 - def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) 528 + config CC_HAS_FOO 529 + def_bool $(success,$(srctree)/scripts/cc-check-foo.sh $(CC)) 530 530 531 531 Build as module only 532 532 ~~~~~~~~~~~~~~~~~~~~
+1 -2
arch/Kconfig
··· 53 53 config JUMP_LABEL 54 54 bool "Optimize very unlikely/likely branches" 55 55 depends on HAVE_ARCH_JUMP_LABEL 56 - depends on CC_HAS_ASM_GOTO 57 56 select OBJTOOL if HAVE_JUMP_LABEL_HACK 58 57 help 59 58 This option enables a transparent branch optimization that ··· 1360 1361 1361 1362 config HAVE_PREEMPT_DYNAMIC_KEY 1362 1363 bool 1363 - depends on HAVE_ARCH_JUMP_LABEL && CC_HAS_ASM_GOTO 1364 + depends on HAVE_ARCH_JUMP_LABEL 1364 1365 select HAVE_PREEMPT_DYNAMIC 1365 1366 help 1366 1367 An architecture should select this if it can handle the preemption
-15
arch/um/include/asm/cpufeature.h
··· 65 65 66 66 #define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit) 67 67 68 - #if defined(__clang__) && !defined(CONFIG_CC_HAS_ASM_GOTO) 69 - 70 - /* 71 - * Workaround for the sake of BPF compilation which utilizes kernel 72 - * headers, but clang does not support ASM GOTO and fails the build. 73 - */ 74 - #ifndef __BPF_TRACING__ 75 - #warning "Compiler lacks ASM_GOTO support. Add -D __BPF_TRACING__ to your compiler arguments" 76 - #endif 77 - 78 - #define static_cpu_has(bit) boot_cpu_has(bit) 79 - 80 - #else 81 - 82 68 /* 83 69 * Static testing of CPU features. Used the same as boot_cpu_has(). It 84 70 * statically patches the target code for additional performance. Use ··· 123 137 boot_cpu_has(bit) : \ 124 138 _static_cpu_has(bit) \ 125 139 ) 126 - #endif 127 140 128 141 #define cpu_has_bug(c, bit) cpu_has(c, (bit)) 129 142 #define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))
-4
arch/x86/Makefile
··· 286 286 287 287 archprepare: checkbin 288 288 checkbin: 289 - ifndef CONFIG_CC_HAS_ASM_GOTO 290 - @echo Compiler lacks asm-goto support. 291 - @exit 1 292 - endif 293 289 ifdef CONFIG_RETPOLINE 294 290 ifeq ($(RETPOLINE_CFLAGS),) 295 291 @echo "You are building kernel with non-retpoline compiler." >&2
-15
arch/x86/include/asm/cpufeature.h
··· 155 155 156 156 #define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit) 157 157 158 - #if defined(__clang__) && !defined(CONFIG_CC_HAS_ASM_GOTO) 159 - 160 - /* 161 - * Workaround for the sake of BPF compilation which utilizes kernel 162 - * headers, but clang does not support ASM GOTO and fails the build. 163 - */ 164 - #ifndef __BPF_TRACING__ 165 - #warning "Compiler lacks ASM_GOTO support. Add -D __BPF_TRACING__ to your compiler arguments" 166 - #endif 167 - 168 - #define static_cpu_has(bit) boot_cpu_has(bit) 169 - 170 - #else 171 - 172 158 /* 173 159 * Static testing of CPU features. Used the same as boot_cpu_has(). It 174 160 * statically patches the target code for additional performance. Use ··· 194 208 boot_cpu_has(bit) : \ 195 209 _static_cpu_has(bit) \ 196 210 ) 197 - #endif 198 211 199 212 #define cpu_has_bug(c, bit) cpu_has(c, (bit)) 200 213 #define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))
+3 -3
arch/x86/include/asm/rmwcc.h
··· 11 11 12 12 #define __CLOBBERS_MEM(clb...) "memory", ## clb 13 13 14 - #if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CONFIG_CC_HAS_ASM_GOTO) 14 + #ifndef __GCC_ASM_FLAG_OUTPUTS__ 15 15 16 16 /* Use asm goto */ 17 17 ··· 27 27 c; \ 28 28 }) 29 29 30 - #else /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CONFIG_CC_HAS_ASM_GOTO) */ 30 + #else /* defined(__GCC_ASM_FLAG_OUTPUTS__) */ 31 31 32 32 /* Use flags output or a set instruction */ 33 33 ··· 40 40 c; \ 41 41 }) 42 42 43 - #endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CONFIG_CC_HAS_ASM_GOTO) */ 43 + #endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) */ 44 44 45 45 #define GEN_UNARY_RMWcc_4(op, var, cc, arg0) \ 46 46 __GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM())
+1 -1
arch/x86/kvm/emulate.c
··· 479 479 480 480 /* 481 481 * XXX: inoutclob user must know where the argument is being expanded. 482 - * Relying on CONFIG_CC_HAS_ASM_GOTO would allow us to remove _fault. 482 + * Using asm goto would allow us to remove _fault. 483 483 */ 484 484 #define asm_safe(insn, inoutclob...) \ 485 485 ({ \
-4
init/Kconfig
··· 70 70 default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m64-flag) -static) if 64BIT 71 71 default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m32-flag) -static) 72 72 73 - config CC_HAS_ASM_GOTO 74 - def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) 75 - 76 73 config CC_HAS_ASM_GOTO_OUTPUT 77 - depends on CC_HAS_ASM_GOTO 78 74 def_bool $(success,echo 'int foo(int x) { asm goto ("": "=r"(x) ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null) 79 75 80 76 config CC_HAS_ASM_GOTO_TIED_OUTPUT
-22
scripts/gcc-goto.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - # Test for gcc 'asm goto' support 4 - # Copyright (C) 2010, Jason Baron <jbaron@redhat.com> 5 - 6 - cat << "END" | $@ -x c - -fno-PIE -c -o /dev/null 7 - int main(void) 8 - { 9 - #if defined(__arm__) || defined(__aarch64__) 10 - /* 11 - * Not related to asm goto, but used by jump label 12 - * and broken on some ARM GCC versions (see GCC Bug 48637). 13 - */ 14 - static struct { int dummy; int state; } tp; 15 - asm (".long %c0" :: "i" (&tp.state)); 16 - #endif 17 - 18 - entry: 19 - asm goto ("" :::: entry); 20 - return 0; 21 - } 22 - END
-21
tools/arch/x86/include/asm/rmwcc.h
··· 2 2 #ifndef _TOOLS_LINUX_ASM_X86_RMWcc 3 3 #define _TOOLS_LINUX_ASM_X86_RMWcc 4 4 5 - #ifdef CONFIG_CC_HAS_ASM_GOTO 6 - 7 5 #define __GEN_RMWcc(fullop, var, cc, ...) \ 8 6 do { \ 9 7 asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \ ··· 17 19 18 20 #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \ 19 21 __GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val)) 20 - 21 - #else /* !CONFIG_CC_HAS_ASM_GOTO */ 22 - 23 - #define __GEN_RMWcc(fullop, var, cc, ...) \ 24 - do { \ 25 - char c; \ 26 - asm volatile (fullop "; set" cc " %1" \ 27 - : "+m" (var), "=qm" (c) \ 28 - : __VA_ARGS__ : "memory"); \ 29 - return c != 0; \ 30 - } while (0) 31 - 32 - #define GEN_UNARY_RMWcc(op, var, arg0, cc) \ 33 - __GEN_RMWcc(op " " arg0, var, cc) 34 - 35 - #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \ 36 - __GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val)) 37 - 38 - #endif /* CONFIG_CC_HAS_ASM_GOTO */ 39 22 40 23 #endif /* _TOOLS_LINUX_ASM_X86_RMWcc */