* [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware
@ 2026-11-16 3:59 Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 1/4] selftests/bpf: Add SKIP_TESTS() helper for test_loader Tiezhu Yang
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Tiezhu Yang @ 2026-11-16 3:59 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: bpf, loongarch, linux-kernel
v3:
- Introduce SKIP_TESTS() as a generic utility to avoid fragile
hardcoded string arrays in test runners.
- Add missing Fixes tag to the fexit_bpf2bpf alignment fix patch.
- Add a new patch (PATCH 4) to handle another unaligned access
failure encountered in jit_insns/tail_call.
Tiezhu Yang (4):
selftests/bpf: Add SKIP_TESTS() helper for test_loader
selftests/bpf: Skip jit_insns_arena tests if not supported
selftests/bpf: Fix unaligned access failure in fexit_bpf2bpf
selftests/bpf: Allow unaligned access in jit_insns/tail_call
tools/testing/selftests/bpf/prog_tests/jit_insns.c | 7 ++++++-
tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c | 1 +
tools/testing/selftests/bpf/progs/test_pkt_access.c | 1 +
tools/testing/selftests/bpf/test_loader.c | 5 +++++
tools/testing/selftests/bpf/test_progs.h | 8 ++++++++
5 files changed, 21 insertions(+), 1 deletion(-)
--
2.42.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH bpf-next v3 1/4] selftests/bpf: Add SKIP_TESTS() helper for test_loader
2026-11-16 3:59 [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
@ 2026-11-16 3:59 ` Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 2/4] selftests/bpf: Skip jit_insns_arena tests if not supported Tiezhu Yang
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Tiezhu Yang @ 2026-11-16 3:59 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: bpf, loongarch, linux-kernel
When running BPF selftests on underlying hardware that lacks specific
execution extensions (such as BPF Arena support), loading certain test
skeletons failed, logging unexpected failures instead of declaring them
as skipped.
Manually hardcoding a skip list of subtest names inside the prog_tests
runner files is fragile and prone to silent omission when new subtests
are appended to the skeleton.
Add a `skip` field to `struct test_loader` along with a `SKIP_TESTS()`
macro (mirroring `RUN_TESTS()`) so test runners can iterate through
and mark all subtests in a skeleton as skipped.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/testing/selftests/bpf/test_loader.c | 5 +++++
tools/testing/selftests/bpf/test_progs.h | 8 ++++++++
2 files changed, 13 insertions(+)
diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/selftests/bpf/test_loader.c
index d24e4fedae46..b5e85bb627d3 100644
--- a/tools/testing/selftests/bpf/test_loader.c
+++ b/tools/testing/selftests/bpf/test_loader.c
@@ -1374,6 +1374,11 @@ void run_subtest(struct test_loader *tester,
if (!test__start_subtest_with_desc(subspec->name, subspec->description))
return;
+ if (tester->skip) {
+ test__skip();
+ return;
+ }
+
if (spec->skip_reason) {
printf("%s:SKIP: %s\n", __func__, spec->skip_reason);
test__skip();
diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h
index adc18f5eceb6..89572c762b57 100644
--- a/tools/testing/selftests/bpf/test_progs.h
+++ b/tools/testing/selftests/bpf/test_progs.h
@@ -530,6 +530,7 @@ struct test_loader {
pre_execution_cb pre_execution_cb;
struct bpf_object *obj;
+ bool skip;
};
static inline void test_loader__set_pre_execution_cb(struct test_loader *tester,
@@ -553,6 +554,13 @@ extern void test_loader_fini(struct test_loader *tester);
test_loader_fini(&tester); \
})
+#define SKIP_TESTS(skel) ({ \
+ struct test_loader tester = { .skip = true }; \
+ \
+ test_loader__run_subtests(&tester, #skel, skel##__elf_bytes); \
+ test_loader_fini(&tester); \
+})
+
struct expect_msg {
const char *substr; /* substring match */
regex_t regex;
--
2.42.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH bpf-next v3 2/4] selftests/bpf: Skip jit_insns_arena tests if not supported
2026-11-16 3:59 [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 1/4] selftests/bpf: Add SKIP_TESTS() helper for test_loader Tiezhu Yang
@ 2026-11-16 3:59 ` Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 3/4] selftests/bpf: Fix unaligned access failure in fexit_bpf2bpf Tiezhu Yang
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Tiezhu Yang @ 2026-11-16 3:59 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: bpf, loongarch, linux-kernel
When loading a BPF skeleton program via test_loader, certain test cases
such as jit_insns/cast_to_user may fail if the underlying hardware lacks
specific execution extensions required by newer features like BPF Arena.
Use libbpf_probe_bpf_map_type() in prog_tests/jit_insns.c to explicitly
check for BPF_MAP_TYPE_ARENA support before loading the jit_insns_arena
test skeleton. If the JIT backend or hardware does not support Arena,
use SKIP_TESTS() to cleanly report all subtests within the skeleton as
skipped.
This prevents false-alarm test failures on unsupported hardware while
preserving the core verification coverage for the rest of the standard
JIT instruction tests (such as alu_imm, alu_reg).
Before:
$ sudo ./test_progs -a jit_insns/cast_to_user
...
libbpf: map 'arena': failed to create: -EOPNOTSUPP
run_subtest:FAIL:unexpected_load_failure unexpected error: -95 (errno 95)
...
Summary: 0/0 PASSED, 0 SKIPPED, 1/1 FAILED
After:
$ sudo ./test_progs -a jit_insns/cast_to_user
...
Summary: 1/0 PASSED, 1 SKIPPED, 0/0 FAILED
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/testing/selftests/bpf/prog_tests/jit_insns.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/jit_insns.c b/tools/testing/selftests/bpf/prog_tests/jit_insns.c
index 0aaab23a2eef..4110b1ff6ff8 100644
--- a/tools/testing/selftests/bpf/prog_tests/jit_insns.c
+++ b/tools/testing/selftests/bpf/prog_tests/jit_insns.c
@@ -3688,7 +3688,11 @@ static void test_tail_call(void)
void test_jit_insns(void)
{
- RUN_TESTS(jit_insns_arena);
+ if (libbpf_probe_bpf_map_type(BPF_MAP_TYPE_ARENA, NULL))
+ RUN_TESTS(jit_insns_arena);
+ else
+ SKIP_TESTS(jit_insns_arena);
+
if (test__start_subtest("alu_imm"))
test_alu_imm();
if (test__start_subtest("alu_reg"))
--
2.42.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH bpf-next v3 3/4] selftests/bpf: Fix unaligned access failure in fexit_bpf2bpf
2026-11-16 3:59 [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 1/4] selftests/bpf: Add SKIP_TESTS() helper for test_loader Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 2/4] selftests/bpf: Skip jit_insns_arena tests if not supported Tiezhu Yang
@ 2026-11-16 3:59 ` Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 4/4] selftests/bpf: Allow unaligned access in jit_insns/tail_call Tiezhu Yang
2026-12-01 1:29 ` [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
4 siblings, 0 replies; 6+ messages in thread
From: Tiezhu Yang @ 2026-11-16 3:59 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: bpf, loongarch, linux-kernel
When executing "./test_progs -t fexit_bpf2bpf", there are 5 subtest
failures on platforms where CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
is not set, as the BPF verifier enforces strict alignment checks:
; tcp->check++; @ test_pkt_access.c:98
226: (69) r1 = *(u16 *)(r2 +16)
misaligned packet access off 2+(0x0; 0x3f)+16 size 2
...
libbpf: prog 'test_pkt_access': failed to load: -EACCES
libbpf: failed to load object './test_pkt_access.bpf.o'
Rather than skipping the tests or setting BPF_F_ANY_ALIGNMENT to
bypass the alignment check, fix this at the source by applying a
bitmask 'off &= ~1' right after the initial range check.
This explicitly communicates the 2-byte alignment state to pass
the verifier and run the full fexit_bpf2bpf test matrix.
Before:
$ sudo ./test_progs -t fexit_bpf2bpf | tail -1
Summary: 0/10 PASSED, 1 SKIPPED, 1/5 FAILED
After:
$ sudo ./test_progs -t fexit_bpf2bpf | tail -1
Summary: 1/15 PASSED, 1 SKIPPED, 0/0 FAILED
Fixes: 6dc03dc71387 ("selftests/bpf: Add test for freplace program with write access")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c | 1 +
tools/testing/selftests/bpf/progs/test_pkt_access.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c b/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
index f4bbf87b82dd..ed06345825e2 100644
--- a/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
+++ b/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
@@ -173,6 +173,7 @@ int new_test_pkt_write_access_subprog(struct __sk_buff *skb, __u32 off)
if (off > sizeof(struct ethhdr) + sizeof(struct ipv6hdr))
return -1;
+ off &= ~1;
tcp = data + off;
if (tcp + 1 > data_end)
return -1;
diff --git a/tools/testing/selftests/bpf/progs/test_pkt_access.c b/tools/testing/selftests/bpf/progs/test_pkt_access.c
index bce7173152c6..21f28a762d60 100644
--- a/tools/testing/selftests/bpf/progs/test_pkt_access.c
+++ b/tools/testing/selftests/bpf/progs/test_pkt_access.c
@@ -91,6 +91,7 @@ int test_pkt_write_access_subprog(struct __sk_buff *skb, __u32 off)
if (off > sizeof(struct ethhdr) + sizeof(struct ipv6hdr))
return -1;
+ off &= ~1;
tcp = data + off;
if (tcp + 1 > data_end)
return -1;
--
2.42.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH bpf-next v3 4/4] selftests/bpf: Allow unaligned access in jit_insns/tail_call
2026-11-16 3:59 [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
` (2 preceding siblings ...)
2026-11-16 3:59 ` [PATCH bpf-next v3 3/4] selftests/bpf: Fix unaligned access failure in fexit_bpf2bpf Tiezhu Yang
@ 2026-11-16 3:59 ` Tiezhu Yang
2026-12-01 1:29 ` [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
4 siblings, 0 replies; 6+ messages in thread
From: Tiezhu Yang @ 2026-11-16 3:59 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: bpf, loongarch, linux-kernel
On architectures that may lack CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
such as RISC-V and LoongArch, the verifier rejects test_tail_call due
to a misaligned 8-byte load (BPF_DW) from the packet pointer, which is
triggered by the architecture-specific NET_IP_ALIGN offset variation.
As this test focuses on tail call rather than alignment enforcement,
set `.prog_flags = BPF_F_ANY_ALIGNMENT` in `bpf_prog_load_opts` to
bypass strict alignment checks on architectures lacking efficient
unaligned access.
Before:
$ sudo ./test_progs -a "jit_insns/tail_call"
...
6: (79) r3 = *(u64 *)(r2 +0)
misaligned packet access off 2+0+0 size 8
...
Summary: 0/0 PASSED, 0 SKIPPED, 1/1 FAILED
After:
$ sudo ./test_progs -a "jit_insns/tail_call"
...
Summary: 1/1 PASSED, 0 SKIPPED, 0/0 FAILED
Fixes: a9fee553d3db ("selftests/bpf: Extend the JIT instruction tests for arm64 encodings")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/testing/selftests/bpf/prog_tests/jit_insns.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/jit_insns.c b/tools/testing/selftests/bpf/prog_tests/jit_insns.c
index 4110b1ff6ff8..bdde6caa871e 100644
--- a/tools/testing/selftests/bpf/prog_tests/jit_insns.c
+++ b/tools/testing/selftests/bpf/prog_tests/jit_insns.c
@@ -3620,6 +3620,7 @@ static void test_tail_call(void)
{ (~0ULL << 32) | 2, TAIL_FALL }, { ~0ULL, TAIL_FALL },
};
LIBBPF_OPTS(bpf_prog_load_opts, lopts,
+ .prog_flags = BPF_F_ANY_ALIGNMENT,
.log_buf = log,
.log_size = sizeof(log),
);
--
2.42.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware
2026-11-16 3:59 [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
` (3 preceding siblings ...)
2026-11-16 3:59 ` [PATCH bpf-next v3 4/4] selftests/bpf: Allow unaligned access in jit_insns/tail_call Tiezhu Yang
@ 2026-12-01 1:29 ` Tiezhu Yang
4 siblings, 0 replies; 6+ messages in thread
From: Tiezhu Yang @ 2026-12-01 1:29 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: bpf, loongarch, linux-kernel
On 11/16/26 11:59 AM, Tiezhu Yang wrote:
> v3:
> - Introduce SKIP_TESTS() as a generic utility to avoid fragile
> hardcoded string arrays in test runners.
> - Add missing Fixes tag to the fexit_bpf2bpf alignment fix patch.
> - Add a new patch (PATCH 4) to handle another unaligned access
> failure encountered in jit_insns/tail_call.
>
> Tiezhu Yang (4):
> selftests/bpf: Add SKIP_TESTS() helper for test_loader
> selftests/bpf: Skip jit_insns_arena tests if not supported
> selftests/bpf: Fix unaligned access failure in fexit_bpf2bpf
> selftests/bpf: Allow unaligned access in jit_insns/tail_call
>
> tools/testing/selftests/bpf/prog_tests/jit_insns.c | 7 ++++++-
> tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c | 1 +
> tools/testing/selftests/bpf/progs/test_pkt_access.c | 1 +
> tools/testing/selftests/bpf/test_loader.c | 5 +++++
> tools/testing/selftests/bpf/test_progs.h | 8 ++++++++
> 5 files changed, 21 insertions(+), 1 deletion(-)
A gentle ping on this series. Any comments?
Thanks,
Tiezhu
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-01 1:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 3:59 [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 1/4] selftests/bpf: Add SKIP_TESTS() helper for test_loader Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 2/4] selftests/bpf: Skip jit_insns_arena tests if not supported Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 3/4] selftests/bpf: Fix unaligned access failure in fexit_bpf2bpf Tiezhu Yang
2026-11-16 3:59 ` [PATCH bpf-next v3 4/4] selftests/bpf: Allow unaligned access in jit_insns/tail_call Tiezhu Yang
2026-12-01 1:29 ` [PATCH bpf-next v3 0/4] selftests/bpf: Handle unexpected failures on unsupported hardware Tiezhu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®