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

bpf: fix broken BPF selftest build

At least on x86_64, the kernel's BPF selftests seemed to have stopped
to build due to 618e165b2a8e ("selftests/bpf: sync kernel headers and
introduce arch support in Makefile"):

[...]
In file included from test_verifier.c:29:0:
../../../include/uapi/linux/bpf_perf_event.h:11:32:
fatal error: asm/bpf_perf_event.h: No such file or directory
#include <asm/bpf_perf_event.h>
^
compilation terminated.
[...]

While pulling in tools/arch/*/include/uapi/asm/bpf_perf_event.h seems
to work fine, there's no automated fall-back logic right now that would
do the same out of tools/include/uapi/asm-generic/bpf_perf_event.h. The
usual convention today is to add a include/[uapi/]asm/ equivalent that
would pull in the correct arch header or generic one as fall-back, all
ifdef'ed based on compiler target definition. It's similarly done also
in other cases such as tools/include/asm/barrier.h, thus adapt the same
here.

Fixes: 618e165b2a8e ("selftests/bpf: sync kernel headers and introduce arch support in Makefile")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Daniel Borkmann and committed by
Alexei Starovoitov
720f228e a23f06f0

+8 -12
+7
tools/include/uapi/asm/bpf_perf_event.h
··· 1 + #if defined(__aarch64__) 2 + #include "../../arch/arm64/include/uapi/asm/bpf_perf_event.h" 3 + #elif defined(__s390__) 4 + #include "../../arch/s390/include/uapi/asm/bpf_perf_event.h" 5 + #else 6 + #include <uapi/asm-generic/bpf_perf_event.h> 7 + #endif
+1 -12
tools/testing/selftests/bpf/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - ifeq ($(srctree),) 4 - srctree := $(patsubst %/,%,$(dir $(CURDIR))) 5 - srctree := $(patsubst %/,%,$(dir $(srctree))) 6 - srctree := $(patsubst %/,%,$(dir $(srctree))) 7 - srctree := $(patsubst %/,%,$(dir $(srctree))) 8 - endif 9 - include $(srctree)/tools/scripts/Makefile.arch 10 - 11 - $(call detected_var,SRCARCH) 12 - 13 3 LIBDIR := ../../../lib 14 4 BPFDIR := $(LIBDIR)/bpf 15 5 APIDIR := ../../../include/uapi 16 - ASMDIR:= ../../../arch/$(ARCH)/include/uapi 17 6 GENDIR := ../../../../include/generated 18 7 GENHDR := $(GENDIR)/autoconf.h 19 8 ··· 10 21 GENFLAGS := -DHAVE_GENHDR 11 22 endif 12 23 13 - CFLAGS += -Wall -O2 -I$(APIDIR) -I$(ASMDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include 24 + CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include 14 25 LDLIBS += -lcap -lelf 15 26 16 27 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \