* [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes
@ 2023-07-05 11:39 Björn Töpel
2023-07-05 11:39 ` [PATCH bpf-next 1/2] selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests Björn Töpel
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Björn Töpel @ 2023-07-05 11:39 UTC (permalink / raw)
To: Andrii Nakryiko, Mykola Lysenko, bpf, netdev
Cc: Björn Töpel, Alexei Starovoitov, Daniel Borkmann,
linux-kselftest, linux-kernel, linux-riscv
From: Björn Töpel <bjorn@rivosinc.com>
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
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH bpf-next 1/2] selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests
2023-07-05 11:39 [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes Björn Töpel
@ 2023-07-05 11:39 ` Björn Töpel
2023-07-05 11:39 ` [PATCH bpf-next 2/2] selftests/bpf: Honor $(O) when figuring out paths Björn Töpel
2023-07-05 12:38 ` [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes Daniel Borkmann
2 siblings, 0 replies; 5+ messages in thread
From: Björn Töpel @ 2023-07-05 11:39 UTC (permalink / raw)
To: Andrii Nakryiko, Mykola Lysenko, bpf, netdev
Cc: Björn Töpel, Alexei Starovoitov, Daniel Borkmann,
linux-kselftest, linux-kernel, linux-riscv
From: Björn Töpel <bjorn@rivosinc.com>
Some verifier tests were missing F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
which made the test fail. Add the flag where needed.
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
---
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(-)
diff --git a/tools/testing/selftests/bpf/verifier/atomic_cmpxchg.c b/tools/testing/selftests/bpf/verifier/atomic_cmpxchg.c
index b39665f33524..319337bdcfc8 100644
--- a/tools/testing/selftests/bpf/verifier/atomic_cmpxchg.c
+++ b/tools/testing/selftests/bpf/verifier/atomic_cmpxchg.c
@@ -242,4 +242,5 @@
.result = REJECT,
.errstr = "R0 invalid mem access",
.errstr_unpriv = "R10 partial copy of pointer",
+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
},
diff --git a/tools/testing/selftests/bpf/verifier/ctx_skb.c b/tools/testing/selftests/bpf/verifier/ctx_skb.c
index 83cecfbd6739..0b394a7f7a2d 100644
--- a/tools/testing/selftests/bpf/verifier/ctx_skb.c
+++ b/tools/testing/selftests/bpf/verifier/ctx_skb.c
@@ -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,
},
diff --git a/tools/testing/selftests/bpf/verifier/jmp32.c b/tools/testing/selftests/bpf/verifier/jmp32.c
index 1a27a6210554..43776f6f92f4 100644
--- a/tools/testing/selftests/bpf/verifier/jmp32.c
+++ b/tools/testing/selftests/bpf/verifier/jmp32.c
@@ -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",
diff --git a/tools/testing/selftests/bpf/verifier/map_kptr.c b/tools/testing/selftests/bpf/verifier/map_kptr.c
index a0cfc06d75bc..d25c3e9605f1 100644
--- a/tools/testing/selftests/bpf/verifier/map_kptr.c
+++ b/tools/testing/selftests/bpf/verifier/map_kptr.c
@@ -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",
diff --git a/tools/testing/selftests/bpf/verifier/precise.c b/tools/testing/selftests/bpf/verifier/precise.c
index 99272bb890da..0d84dd1f38b6 100644
--- a/tools/testing/selftests/bpf/verifier/precise.c
+++ b/tools/testing/selftests/bpf/verifier/precise.c
@@ -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,
},
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH bpf-next 2/2] selftests/bpf: Honor $(O) when figuring out paths
2023-07-05 11:39 [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes Björn Töpel
2023-07-05 11:39 ` [PATCH bpf-next 1/2] selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests Björn Töpel
@ 2023-07-05 11:39 ` Björn Töpel
2023-07-05 12:38 ` [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes Daniel Borkmann
2 siblings, 0 replies; 5+ messages in thread
From: Björn Töpel @ 2023-07-05 11:39 UTC (permalink / raw)
To: Andrii Nakryiko, Mykola Lysenko, bpf, netdev
Cc: Björn Töpel, Alexei Starovoitov, Daniel Borkmann,
linux-kselftest, linux-kernel, linux-riscv
From: Björn Töpel <bjorn@rivosinc.com>
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.
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
---
tools/testing/selftests/bpf/Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index ad6b585e0d7c..daccc1b8573a 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -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
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes
2023-07-05 11:39 [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes Björn Töpel
2023-07-05 11:39 ` [PATCH bpf-next 1/2] selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests Björn Töpel
2023-07-05 11:39 ` [PATCH bpf-next 2/2] selftests/bpf: Honor $(O) when figuring out paths Björn Töpel
@ 2023-07-05 12:38 ` Daniel Borkmann
2023-07-05 13:45 ` Björn Töpel
2 siblings, 1 reply; 5+ messages in thread
From: Daniel Borkmann @ 2023-07-05 12:38 UTC (permalink / raw)
To: Björn Töpel, Andrii Nakryiko, Mykola Lysenko, bpf,
netdev
Cc: Björn Töpel, Alexei Starovoitov, linux-kselftest,
linux-kernel, linux-riscv
On 7/5/23 1:39 PM, Björn Töpel wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
>
> 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.
Looks good, applied thanks! Any plans on working towards integrating riscv
into upstream BPF CI? Would love to see that happening. :)
Thanks,
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes
2023-07-05 12:38 ` [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes Daniel Borkmann
@ 2023-07-05 13:45 ` Björn Töpel
0 siblings, 0 replies; 5+ messages in thread
From: Björn Töpel @ 2023-07-05 13:45 UTC (permalink / raw)
To: Daniel Borkmann, Andrii Nakryiko, Mykola Lysenko, bpf, netdev
Cc: Björn Töpel, Alexei Starovoitov, linux-kselftest,
linux-kernel, linux-riscv
Daniel Borkmann <daniel@iogearbox.net> writes:
> On 7/5/23 1:39 PM, Björn Töpel wrote:
>> From: Björn Töpel <bjorn@rivosinc.com>
>>
>> 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.
>
> Looks good, applied thanks!
Thank you!
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-05 13:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05 11:39 [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes Björn Töpel
2023-07-05 11:39 ` [PATCH bpf-next 1/2] selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests Björn Töpel
2023-07-05 11:39 ` [PATCH bpf-next 2/2] selftests/bpf: Honor $(O) when figuring out paths Björn Töpel
2023-07-05 12:38 ` [PATCH bpf-next 0/2] BPF kselftest cross-build/RISC-V fixes Daniel Borkmann
2023-07-05 13:45 ` Björn Töpel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).