[PATCH bpf-next v1 1/2] selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader

From: Tiezhu Yang

Date: Mon Nov 02 2026 - 03:16:55 EST


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.

Now that arch-specific JIT backends can dynamically report these missing
hardware extensions by returning -EOPNOTSUPP during object loading, the
user-space testing should handle this gracefully rather than treating it
as a generic loading failure.

Check the errno of bpf_object__load() to evaluate whether a load failure
originates from an unsupported platform capability (errno == EOPNOTSUPP).
If true, cleanly detour execution via test__skip() and branch to cleanup.
This allows test_progs to mark the test status as SKIPPED rather than
logging a false-alarm failure if the feature is not supported.

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)
...
#193/2 jit_insns/cast_to_user:FAIL
#193 jit_insns:FAIL
Summary: 0/0 PASSED, 0 SKIPPED, 1/1 FAILED

After:
$ sudo ./test_progs -a jit_insns/cast_to_user
#193/2 jit_insns/cast_to_user:SKIP
#193 jit_insns:OK (SKIP: 1/33)
Summary: 1/0 PASSED, 1 SKIPPED, 0/0 FAILED

Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
tools/testing/selftests/bpf/test_loader.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/selftests/bpf/test_loader.c
index d24e4fedae46..021818afbd3b 100644
--- a/tools/testing/selftests/bpf/test_loader.c
+++ b/tools/testing/selftests/bpf/test_loader.c
@@ -1474,6 +1474,10 @@ void run_subtest(struct test_loader *tester,
goto tobj_cleanup;
}
} else {
+ if (err < 0 && errno == EOPNOTSUPP) {
+ test__skip();
+ goto tobj_cleanup;
+ }
if (!ASSERT_OK(err, "unexpected_load_failure")) {
emit_verifier_log(tester->log_buf, true /*force*/);
goto tobj_cleanup;
--
2.42.0