BPF kselftest cross-build/RISC-V fixes
Subsystems (6)
cover BPF kselftest cross-build/RISC-V fixes
From: Björn Töpel <[email protected]>
This series has two minor fixes, found when cross-compiling for the RISC-V architecture.
Some RISC-V systems do not define HAVE_EFFICIENT_UNALIGNED_ACCESS, which made some of tests bail out. Fix the failing tests by adding F_NEEDS_EFFICIENT_UNALIGNED_ACCESS.
...and some RISC-V systems *do* define HAVE_EFFICIENT_UNALIGNED_ACCESS. In this case the autoconf.h was not correctly picked up by the build system.
Cheers,
Björn
Björn Töpel (2):
selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests selftests/bpf: Honor $(O) when figuring out paths
tools/testing/selftests/bpf/Makefile | 4 ++++ tools/testing/selftests/bpf/verifier/atomic_cmpxchg.c | 1 + tools/testing/selftests/bpf/verifier/ctx_skb.c | 2 ++ tools/testing/selftests/bpf/verifier/jmp32.c | 8 ++++++++ tools/testing/selftests/bpf/verifier/map_kptr.c | 2 ++ tools/testing/selftests/bpf/verifier/precise.c | 2 +- 6 files changed, 18 insertions(+), 1 deletion(-)
base-commit: a94098d490e17d652770f2309fcb9b46bc4cf864
Signature · 1 line
2.39.2
PATCH 1/2 selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests
From: Björn Töpel <[email protected]>
Some verifier tests were missing F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, which made the test fail. Add the flag where needed.
--- tools/testing/selftests/bpf/verifier/atomic_cmpxchg.c | 1 + tools/testing/selftests/bpf/verifier/ctx_skb.c | 2 ++ tools/testing/selftests/bpf/verifier/jmp32.c | 8 ++++++++ tools/testing/selftests/bpf/verifier/map_kptr.c | 2 ++ tools/testing/selftests/bpf/verifier/precise.c | 2 +- 5 files changed, 14 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/verifier/atomic_cmpxchg.c +1 -0
@@ -242,4 +242,5 @@ .result = REJECT, .errstr = "R0 invalid mem access", .errstr_unpriv = "R10 partial copy of pointer", + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, },
tools/testing/selftests/bpf/verifier/ctx_skb.c +2 -0
@@ -1169,6 +1169,7 @@ }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_SK_SKB, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "pkt_end < pkt taken check",
@@ -1190,4 +1191,5 @@ }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_SK_SKB, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, },
tools/testing/selftests/bpf/verifier/jmp32.c +8 -0
@@ -290,6 +290,7 @@ .result_unpriv = REJECT, .result = ACCEPT, .retval = 2, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "jgt32: BPF_K",
@@ -360,6 +361,7 @@ .result_unpriv = REJECT, .result = ACCEPT, .retval = 2, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "jle32: BPF_K",
@@ -430,6 +432,7 @@ .result_unpriv = REJECT, .result = ACCEPT, .retval = 2, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "jlt32: BPF_K",
@@ -500,6 +503,7 @@ .result_unpriv = REJECT, .result = ACCEPT, .retval = 2, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "jsge32: BPF_K",
@@ -570,6 +574,7 @@ .result_unpriv = REJECT, .result = ACCEPT, .retval = 2, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "jsgt32: BPF_K",
@@ -640,6 +645,7 @@ .result_unpriv = REJECT, .result = ACCEPT, .retval = 2, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "jsle32: BPF_K",
@@ -710,6 +716,7 @@ .result_unpriv = REJECT, .result = ACCEPT, .retval = 2, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "jslt32: BPF_K",
@@ -780,6 +787,7 @@ .result_unpriv = REJECT, .result = ACCEPT, .retval = 2, + .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { "jgt32: range bound deduction, reg op imm",
tools/testing/selftests/bpf/verifier/map_kptr.c +2 -0
@@ -68,6 +68,7 @@ .fixup_map_kptr = { 1 }, .result = REJECT, .errstr = "kptr access cannot have variable offset", + .flags =F_NEEDS_EFFICIENT_UNALIGNED_ACCESS , }, { "map_kptr: bpf_kptr_xchg non-const var_off",
@@ -121,6 +122,7 @@ .fixup_map_kptr = { 1 }, .result = REJECT, .errstr = "kptr access misaligned expected=0 off=7", + .flags =F_NEEDS_EFFICIENT_UNALIGNED_ACCESS , }, { "map_kptr: reject var_off != 0",
tools/testing/selftests/bpf/verifier/precise.c +1 -1
@@ -216,7 +216,7 @@ }, .fixup_map_ringbuf = { 1 }, .prog_type = BPF_PROG_TYPE_XDP, - .flags = BPF_F_TEST_STATE_FREQ, + .flags = BPF_F_TEST_STATE_FREQ | F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, .errstr = "invalid access to memory, mem_size=1 off=42 size=8", .result = REJECT, },
Signature · 1 line
2.39.2
PATCH 2/2 selftests/bpf: Honor $(O) when figuring out paths
In reply to Björn TöpelFrom: Björn Töpel <[email protected]>
When building the kselftests out-of-tree, e.g.
| make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- \ | O=/tmp/kselftest headers | make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- \ | O=/tmp/kselftest HOSTCC=gcc FORMAT= \ | SKIP_TARGETS="arm64 ia64 powerpc sparc64 x86 sgx" \ | -C tools/testing/selftests gen_tar
the kselftest build would not pick up the correct GENDIR path, and therefore not including autoconf.h.
Correct that by taking $(O) into consideration when figuring out the GENDIR path.
--- tools/testing/selftests/bpf/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/bpf/Makefile +4 -0
@@ -12,7 +12,11 @@ BPFDIR := $(LIBDIR)/bpf TOOLSINCDIR := $(TOOLSDIR)/include BPFTOOLDIR := $(TOOLSDIR)/bpf/bpftool APIDIR := $(TOOLSINCDIR)/uapi +ifneq ($(O),) +GENDIR := $(O)/include/generated +else GENDIR := $(abspath ../../../../include/generated) +endif GENHDR := $(GENDIR)/autoconf.h HOSTPKG_CONFIG := pkg-config
Signature · 1 line
2.39.2
Daniel Borkmann
maintainerQuoted 5 lines · Björn Töpel
From: Björn Töpel <[email protected]>
This series has two minor fixes, found when cross-compiling for the RISC-V architecture.
Quoted 7 lines
Some RISC-V systems do not define
HAVE_EFFICIENT_UNALIGNED_ACCESS, which made some of tests bail out. Fix the failing tests by addingF_NEEDS_EFFICIENT_UNALIGNED_ACCESS....and some RISC-V systems *do* define
HAVE_EFFICIENT_UNALIGNED_ACCESS. In this case theautoconf.hwas not correctly picked up by the build system.
Looks good, applied thanks! Any plans on working towards integrating riscv into upstream BPF CI? Would love to see that happening. :)
Thanks,
Daniel
Quoted 10 lines · Daniel Borkmann
Quoted 9 lines · Björn Töpel
From: Björn Töpel <[email protected]>
This series has two minor fixes, found when cross-compiling for the RISC-V architecture.
Some RISC-V systems do not define
HAVE_EFFICIENT_UNALIGNED_ACCESS, which made some of tests bail out. Fix the failing tests by addingF_NEEDS_EFFICIENT_UNALIGNED_ACCESS.
Quoted 5 lines
Quoted 3 lines
...and some RISC-V systems *do* define
HAVE_EFFICIENT_UNALIGNED_ACCESS. In this case theautoconf.hwas not correctly picked up by the build system.Looks good, applied thanks!
Thank you!
Quoted 2 lines
Any plans on working towards integrating riscv into upstream BPF CI? Would love to see that happening. :)
Yes! I started hacking a bit on that some time back:
https://github.com/libbpf/ci/pull/87
https://github.com/kernel-patches/vmtest/pull/194
(TL;DR: I'll continuing that work at some point.)
RISC-V still needs cross-compilation, and testing on qemu/TCG (on typically x86-hosts), which puts some constraints on the rootfs/cross-compilation host; For RISC-V Debian Bullseye is way too old (a lot packages are missing/broken). Typically for BPF it would be Ubuntu Kinetic (or later), or some Debian Sid snapshot.
The rootfs, the host, and the host foreign arch would need to be the same for "no-hassle cross-compilation on Debian derivatives" -- and at least younger than "Ubuntu Kinetic"-age.
AFAIU, there are some issues with rootfs version and build host versioning for other archs as well: https://github.com/libbpf/ci/pull/83
Björn