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

x86/cpufeature: Guard asm_volatile_goto usage for BPF compilation

Workaround for the sake of BPF compilation which utilizes kernel
headers, but clang does not support ASM GOTO and fails the build.

Fixes: d0266046ad54 ("x86: Remove FAST_FEATURE_TESTS")
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: daniel@iogearbox.net
Cc: peterz@infradead.org
Cc: netdev@vger.kernel.org
Cc: bp@alien8.de
Cc: yhs@fb.com
Cc: kernel-team@fb.com
Cc: torvalds@linux-foundation.org
Cc: davem@davemloft.net
Link: https://lkml.kernel.org/r/20180513193222.1997938-1-ast@kernel.org

authored by

Alexei Starovoitov and committed by
Thomas Gleixner
b1ae32db 13ebe18c

+16 -1
+15
arch/x86/include/asm/cpufeature.h
··· 140 140 141 141 #define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit) 142 142 143 + #if defined(__clang__) && !defined(CC_HAVE_ASM_GOTO) 144 + 145 + /* 146 + * Workaround for the sake of BPF compilation which utilizes kernel 147 + * headers, but clang does not support ASM GOTO and fails the build. 148 + */ 149 + #ifndef __BPF_TRACING__ 150 + #warning "Compiler lacks ASM_GOTO support. Add -D __BPF_TRACING__ to your compiler arguments" 151 + #endif 152 + 153 + #define static_cpu_has(bit) boot_cpu_has(bit) 154 + 155 + #else 156 + 143 157 /* 144 158 * Static testing of CPU features. Used the same as boot_cpu_has(). 145 159 * These will statically patch the target code for additional ··· 209 195 boot_cpu_has(bit) : \ 210 196 _static_cpu_has(bit) \ 211 197 ) 198 + #endif 212 199 213 200 #define cpu_has_bug(c, bit) cpu_has(c, (bit)) 214 201 #define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))
+1 -1
samples/bpf/Makefile
··· 255 255 $(obj)/%.o: $(src)/%.c 256 256 $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \ 257 257 -I$(srctree)/tools/testing/selftests/bpf/ \ 258 - -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \ 258 + -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \ 259 259 -D__TARGET_ARCH_$(ARCH) -Wno-compare-distinct-pointer-types \ 260 260 -Wno-gnu-variable-sized-type-not-at-end \ 261 261 -Wno-address-of-packed-member -Wno-tautological-compare \