Message ID | 20171212012532.30268-4-daniel@iogearbox.net |
---|---|
State | Accepted, archived |
Delegated to: | BPF Maintainers |
Headers | show |
Series | Misc BPF fixes | expand |
Hi Daniel, On Tue, Dec 12, 2017 at 02:25:32AM +0100, Daniel Borkmann wrote: > 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> > --- > tools/include/uapi/asm/bpf_perf_event.h | 7 +++++++ > tools/testing/selftests/bpf/Makefile | 13 +------------ > 2 files changed, 8 insertions(+), 12 deletions(-) > create mode 100644 tools/include/uapi/asm/bpf_perf_event.h > > diff --git a/tools/include/uapi/asm/bpf_perf_event.h b/tools/include/uapi/asm/bpf_perf_event.h > new file mode 100644 > index 0000000..13a5853 > --- /dev/null > +++ b/tools/include/uapi/asm/bpf_perf_event.h > @@ -0,0 +1,7 @@ > +#if defined(__aarch64__) > +#include "../../arch/arm64/include/uapi/asm/bpf_perf_event.h" > +#elif defined(__s390__) > +#include "../../arch/s390/include/uapi/asm/bpf_perf_event.h" > +#else > +#include <uapi/asm-generic/bpf_perf_event.h> > +#endif > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > index 21a2d76..792af7c 100644 > --- a/tools/testing/selftests/bpf/Makefile > +++ b/tools/testing/selftests/bpf/Makefile > @@ -1,19 +1,8 @@ > # SPDX-License-Identifier: GPL-2.0 > > -ifeq ($(srctree),) > -srctree := $(patsubst %/,%,$(dir $(CURDIR))) > -srctree := $(patsubst %/,%,$(dir $(srctree))) > -srctree := $(patsubst %/,%,$(dir $(srctree))) > -srctree := $(patsubst %/,%,$(dir $(srctree))) > -endif > -include $(srctree)/tools/scripts/Makefile.arch > - > -$(call detected_var,SRCARCH) > - > LIBDIR := ../../../lib > BPFDIR := $(LIBDIR)/bpf > APIDIR := ../../../include/uapi > -ASMDIR:= ../../../arch/$(ARCH)/include/uapi This is actually necessary on s390: cc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../../include/generated -I../../../include test_verifier.c /root/git/linux/tools/testing/selftests/bpf/libbpf.a /root/git/linux/tools/testing/selftests/bpf/cgroup_helpers.c -lcap -lelf -o /root/git/linux/tools/testing/selftests/bpf/test_verifier In file included from ../../../include/uapi/asm/bpf_perf_event.h:4:0, from ../../../include/uapi/linux/bpf_perf_event.h:11, from test_verifier.c:29: ../../../include/uapi/../../arch/s390/include/uapi/asm/bpf_perf_event.h:7:9: error: unknown type name 'user_pt_regs' typedef user_pt_regs bpf_user_pt_regs_t; ^~~~~~~~~~~~ make: *** [../lib.mk:109: /root/git/linux/tools/testing/selftests/bpf/test_verifier] Error 1 The s390 bpf_perf_event.h header file contains an #include for asm/ptrace.h that defines the user_pt_regs (introduce with my patch set). For building, the ptrace.h header file from the tooling must be used, not the local installed version. Including the ptrace.h header file directly solves the issue. Feel free to merge below snippet into your patch. Thanks and kind regards, Hendrik --- diff --git a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h index cefe7c7cd4f6..0a8e37a519f2 100644 --- a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h +++ b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h @@ -2,7 +2,7 @@ #ifndef _UAPI__ASM_BPF_PERF_EVENT_H__ #define _UAPI__ASM_BPF_PERF_EVENT_H__ -#include <asm/ptrace.h> +#include "ptrace.h" typedef user_pt_regs bpf_user_pt_regs_t;
On 12/18/2017 10:28 AM, Hendrik Brueckner wrote: [...] > This is actually necessary on s390: > > cc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../../include/generated -I../../../include test_verifier.c /root/git/linux/tools/testing/selftests/bpf/libbpf.a /root/git/linux/tools/testing/selftests/bpf/cgroup_helpers.c -lcap -lelf -o /root/git/linux/tools/testing/selftests/bpf/test_verifier > In file included from ../../../include/uapi/asm/bpf_perf_event.h:4:0, > from ../../../include/uapi/linux/bpf_perf_event.h:11, > from test_verifier.c:29: > ../../../include/uapi/../../arch/s390/include/uapi/asm/bpf_perf_event.h:7:9: error: unknown type name 'user_pt_regs' > typedef user_pt_regs bpf_user_pt_regs_t; > ^~~~~~~~~~~~ > make: *** [../lib.mk:109: /root/git/linux/tools/testing/selftests/bpf/test_verifier] Error 1 > > The s390 bpf_perf_event.h header file contains an #include for asm/ptrace.h > that defines the user_pt_regs (introduce with my patch set). For building, > the ptrace.h header file from the tooling must be used, not the local > installed version. > > Including the ptrace.h header file directly solves the issue. Feel free to > merge below snippet into your patch. Argh, fwiw, I tested on x86 and arm64. :/ Given it already landed in Linus' tree, could you send me the below as an official patch and I'll take it via bpf? I think the below is minimal enough, and should then hopefully be the last remaining fallout on this uapi issue. I think it's fine to do it this way. The other option would be to pull in ptrace.h for all the others as well and map it similarly as with bpf_perf_event.h, but that gets out of hand very quickly (plus we could not have a default fallback include since it would otherwise be recursive). Anyway, could you add a comment over the include below stating that this is necessary to include this way? Just to make sure it doesn't accidentally get changed back until we have a proper framework in tools/ for dealing with asm includes. Thanks a lot, Daniel > Thanks and kind regards, > Hendrik > > --- > diff --git a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h > index cefe7c7cd4f6..0a8e37a519f2 100644 > --- a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h > +++ b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h > @@ -2,7 +2,7 @@ > #ifndef _UAPI__ASM_BPF_PERF_EVENT_H__ > #define _UAPI__ASM_BPF_PERF_EVENT_H__ > > -#include <asm/ptrace.h> > +#include "ptrace.h" > > typedef user_pt_regs bpf_user_pt_regs_t; > >
diff --git a/tools/include/uapi/asm/bpf_perf_event.h b/tools/include/uapi/asm/bpf_perf_event.h new file mode 100644 index 0000000..13a5853 --- /dev/null +++ b/tools/include/uapi/asm/bpf_perf_event.h @@ -0,0 +1,7 @@ +#if defined(__aarch64__) +#include "../../arch/arm64/include/uapi/asm/bpf_perf_event.h" +#elif defined(__s390__) +#include "../../arch/s390/include/uapi/asm/bpf_perf_event.h" +#else +#include <uapi/asm-generic/bpf_perf_event.h> +#endif diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 21a2d76..792af7c 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -1,19 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -ifeq ($(srctree),) -srctree := $(patsubst %/,%,$(dir $(CURDIR))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -endif -include $(srctree)/tools/scripts/Makefile.arch - -$(call detected_var,SRCARCH) - LIBDIR := ../../../lib BPFDIR := $(LIBDIR)/bpf APIDIR := ../../../include/uapi -ASMDIR:= ../../../arch/$(ARCH)/include/uapi GENDIR := ../../../../include/generated GENHDR := $(GENDIR)/autoconf.h @@ -21,7 +10,7 @@ ifneq ($(wildcard $(GENHDR)),) GENFLAGS := -DHAVE_GENHDR endif -CFLAGS += -Wall -O2 -I$(APIDIR) -I$(ASMDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include +CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include LDLIBS += -lcap -lelf TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \