Skip to content

Commit a0a12c3

Browse files
nickdesaulnierstorvalds
authored andcommitted
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 <[email protected]> Suggested-by: Masahiro Yamada <[email protected]> Suggested-by: Alexei Starovoitov <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Reviewed-by: Alexandre Belloni <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 15b3f48 commit a0a12c3

File tree

10 files changed

+7
-89
lines changed

10 files changed

+7
-89
lines changed

Documentation/kbuild/kconfig-language.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ followed by a test macro::
525525
If you need to expose a compiler capability to makefiles and/or C source files,
526526
`CC_HAS_` is the recommended prefix for the config option::
527527

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

531531
Build as module only
532532
~~~~~~~~~~~~~~~~~~~~

arch/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ config KPROBES
5353
config JUMP_LABEL
5454
bool "Optimize very unlikely/likely branches"
5555
depends on HAVE_ARCH_JUMP_LABEL
56-
depends on CC_HAS_ASM_GOTO
5756
select OBJTOOL if HAVE_JUMP_LABEL_HACK
5857
help
5958
This option enables a transparent branch optimization that
@@ -1361,7 +1360,7 @@ config HAVE_PREEMPT_DYNAMIC_CALL
13611360

13621361
config HAVE_PREEMPT_DYNAMIC_KEY
13631362
bool
1364-
depends on HAVE_ARCH_JUMP_LABEL && CC_HAS_ASM_GOTO
1363+
depends on HAVE_ARCH_JUMP_LABEL
13651364
select HAVE_PREEMPT_DYNAMIC
13661365
help
13671366
An architecture should select this if it can handle the preemption

arch/um/include/asm/cpufeature.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,6 @@ extern void setup_clear_cpu_cap(unsigned int bit);
6565

6666
#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit)
6767

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-
8268
/*
8369
* Static testing of CPU features. Used the same as boot_cpu_has(). It
8470
* statically patches the target code for additional performance. Use
@@ -137,7 +123,6 @@ static __always_inline bool _static_cpu_has(u16 bit)
137123
boot_cpu_has(bit) : \
138124
_static_cpu_has(bit) \
139125
)
140-
#endif
141126

142127
#define cpu_has_bug(c, bit) cpu_has(c, (bit))
143128
#define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))

arch/x86/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,6 @@ vdso_install:
286286

287287
archprepare: checkbin
288288
checkbin:
289-
ifndef CONFIG_CC_HAS_ASM_GOTO
290-
@echo Compiler lacks asm-goto support.
291-
@exit 1
292-
endif
293289
ifdef CONFIG_RETPOLINE
294290
ifeq ($(RETPOLINE_CFLAGS),)
295291
@echo "You are building kernel with non-retpoline compiler." >&2

arch/x86/include/asm/cpufeature.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,6 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
155155

156156
#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit)
157157

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-
172158
/*
173159
* Static testing of CPU features. Used the same as boot_cpu_has(). It
174160
* statically patches the target code for additional performance. Use
@@ -208,7 +194,6 @@ static __always_inline bool _static_cpu_has(u16 bit)
208194
boot_cpu_has(bit) : \
209195
_static_cpu_has(bit) \
210196
)
211-
#endif
212197

213198
#define cpu_has_bug(c, bit) cpu_has(c, (bit))
214199
#define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))

arch/x86/include/asm/rmwcc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#define __CLOBBERS_MEM(clb...) "memory", ## clb
1313

14-
#if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CONFIG_CC_HAS_ASM_GOTO)
14+
#ifndef __GCC_ASM_FLAG_OUTPUTS__
1515

1616
/* Use asm goto */
1717

@@ -27,7 +27,7 @@ cc_label: c = true; \
2727
c; \
2828
})
2929

30-
#else /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CONFIG_CC_HAS_ASM_GOTO) */
30+
#else /* defined(__GCC_ASM_FLAG_OUTPUTS__) */
3131

3232
/* Use flags output or a set instruction */
3333

@@ -40,7 +40,7 @@ cc_label: c = true; \
4040
c; \
4141
})
4242

43-
#endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CONFIG_CC_HAS_ASM_GOTO) */
43+
#endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) */
4444

4545
#define GEN_UNARY_RMWcc_4(op, var, cc, arg0) \
4646
__GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM())

arch/x86/kvm/emulate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ FOP_END;
479479

480480
/*
481481
* 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.
483483
*/
484484
#define asm_safe(insn, inoutclob...) \
485485
({ \

init/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ config CC_CAN_LINK_STATIC
7070
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m64-flag) -static) if 64BIT
7171
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m32-flag) -static)
7272

73-
config CC_HAS_ASM_GOTO
74-
def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
75-
7673
config CC_HAS_ASM_GOTO_OUTPUT
77-
depends on CC_HAS_ASM_GOTO
7874
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)
7975

8076
config CC_HAS_ASM_GOTO_TIED_OUTPUT

scripts/gcc-goto.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

tools/arch/x86/include/asm/rmwcc.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#ifndef _TOOLS_LINUX_ASM_X86_RMWcc
33
#define _TOOLS_LINUX_ASM_X86_RMWcc
44

5-
#ifdef CONFIG_CC_HAS_ASM_GOTO
6-
75
#define __GEN_RMWcc(fullop, var, cc, ...) \
86
do { \
97
asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \
@@ -20,23 +18,4 @@ cc_label: \
2018
#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
2119
__GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
2220

23-
#else /* !CONFIG_CC_HAS_ASM_GOTO */
24-
25-
#define __GEN_RMWcc(fullop, var, cc, ...) \
26-
do { \
27-
char c; \
28-
asm volatile (fullop "; set" cc " %1" \
29-
: "+m" (var), "=qm" (c) \
30-
: __VA_ARGS__ : "memory"); \
31-
return c != 0; \
32-
} while (0)
33-
34-
#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
35-
__GEN_RMWcc(op " " arg0, var, cc)
36-
37-
#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
38-
__GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
39-
40-
#endif /* CONFIG_CC_HAS_ASM_GOTO */
41-
4221
#endif /* _TOOLS_LINUX_ASM_X86_RMWcc */

0 commit comments

Comments
 (0)