* [PATCH bpf-next v1 0/2] selftests/bpf: Make some tests skipped
@ 2026-11-02 8:12 Tiezhu Yang
2026-11-02 8:12 ` [PATCH bpf-next v1 1/2] selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader Tiezhu Yang
2026-11-02 8:12 ` [PATCH bpf-next v1 2/2] selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf Tiezhu Yang
0 siblings, 2 replies; 7+ messages in thread
From: Tiezhu Yang @ 2026-11-02 8:12 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: bpf, loongarch, linux-kernel
This version is based on bpf-next, tested on Loongson-3A5000 and
Loongson-3A6000 physical machines.
Tiezhu Yang (2):
selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader
selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf
.../testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c | 11 +++++++++++
tools/testing/selftests/bpf/test_loader.c | 4 ++++
tools/testing/selftests/bpf/unpriv_helpers.c | 5 +++++
tools/testing/selftests/bpf/unpriv_helpers.h | 1 +
4 files changed, 21 insertions(+)
--
2.42.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH bpf-next v1 1/2] selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader
2026-11-02 8:12 [PATCH bpf-next v1 0/2] selftests/bpf: Make some tests skipped Tiezhu Yang
@ 2026-11-02 8:12 ` Tiezhu Yang
2026-11-02 8:28 ` sashiko-bot
2026-11-02 8:12 ` [PATCH bpf-next v1 2/2] selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf Tiezhu Yang
1 sibling, 1 reply; 7+ messages in thread
From: Tiezhu Yang @ 2026-11-02 8:12 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.
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@loongson.cn>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH bpf-next v1 2/2] selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf
2026-11-02 8:12 [PATCH bpf-next v1 0/2] selftests/bpf: Make some tests skipped Tiezhu Yang
2026-11-02 8:12 ` [PATCH bpf-next v1 1/2] selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader Tiezhu Yang
@ 2026-11-02 8:12 ` Tiezhu Yang
2026-11-02 8:23 ` sashiko-bot
1 sibling, 1 reply; 7+ messages in thread
From: Tiezhu Yang @ 2026-11-02 8:12 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 failures
with the same log:
; 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'
This is because CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
on certain processors that lack hardware unaligned access support.
In this case, the affected tests should be skipped.
Add a get_unaligned_access_enabled() helper and use it to skip the
tests gracefully if the program fails to load with -EACCES.
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/10 PASSED, 6 SKIPPED, 0/0 FAILED
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
.../testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c | 11 +++++++++++
tools/testing/selftests/bpf/unpriv_helpers.c | 5 +++++
tools/testing/selftests/bpf/unpriv_helpers.h | 1 +
3 files changed, 17 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c b/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
index d2f2dcc0f2e1..1c0e93dcb3ce 100644
--- a/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
+++ b/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
@@ -3,6 +3,7 @@
#include <test_progs.h>
#include <network_helpers.h>
#include <bpf/btf.h>
+#include <unpriv_helpers.h>
#include "bind4_prog.skel.h"
#include "freplace_progmap.skel.h"
#include "fentry_sleepable.skel.h"
@@ -76,6 +77,11 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
err = bpf_prog_test_load(target_obj_file, BPF_PROG_TYPE_UNSPEC,
&tgt_obj, &tgt_fd);
+ if (err < 0 && errno == EACCES && !get_unaligned_access_enabled()) {
+ test__skip();
+ return;
+ }
+
if (!ASSERT_OK(err, "tgt_prog_load"))
return;
@@ -297,6 +303,11 @@ static void test_fmod_ret_freplace(void)
err = bpf_prog_test_load(tgt_name, BPF_PROG_TYPE_UNSPEC,
&pkt_obj, &pkt_fd);
+ if (err < 0 && errno == EACCES && !get_unaligned_access_enabled()) {
+ test__skip();
+ return;
+ }
+
/* the target prog should load fine */
if (CHECK(err, "tgt_prog_load", "file %s err %d errno %d\n",
tgt_name, err, errno))
diff --git a/tools/testing/selftests/bpf/unpriv_helpers.c b/tools/testing/selftests/bpf/unpriv_helpers.c
index c8dd5d848584..54ce342b3fe4 100644
--- a/tools/testing/selftests/bpf/unpriv_helpers.c
+++ b/tools/testing/selftests/bpf/unpriv_helpers.c
@@ -161,3 +161,8 @@ bool get_kasan_multi_shot_enabled(void)
{
return cmdline_contains("kasan_multi_shot");
}
+
+bool get_unaligned_access_enabled(void)
+{
+ return config_contains("CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y") == 1;
+}
diff --git a/tools/testing/selftests/bpf/unpriv_helpers.h b/tools/testing/selftests/bpf/unpriv_helpers.h
index c24d53e14f3a..6e3ad636ea83 100644
--- a/tools/testing/selftests/bpf/unpriv_helpers.h
+++ b/tools/testing/selftests/bpf/unpriv_helpers.h
@@ -9,3 +9,4 @@ bool get_unpriv_sysctl_disabled(void);
bool get_unpriv_mitigations_disabled(void);
bool get_kasan_jit_enabled(void);
bool get_kasan_multi_shot_enabled(void);
+bool get_unaligned_access_enabled(void);
--
2.42.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v1 2/2] selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf
2026-11-02 8:12 ` [PATCH bpf-next v1 2/2] selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf Tiezhu Yang
@ 2026-11-02 8:23 ` sashiko-bot
2026-11-03 2:06 ` Tiezhu Yang
0 siblings, 1 reply; 7+ messages in thread
From: sashiko-bot @ 2026-11-02 8:23 UTC (permalink / raw)
To: Tiezhu Yang; +Cc: bpf
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] selftests/bpf: fexit_bpf2bpf skips tests instead of aligning subprog offset
- [Medium] selftests/bpf: get_unaligned_access_enabled() masks EACCES verifier errors
--
commit 7711595f0d56f0638a8acca1420d5b1c4401c310
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf
This commit adds a get_unaligned_access_enabled() helper and uses it in
fexit_bpf2bpf to skip subtests when bpf_prog_test_load() fails with -EACCES
and CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not enabled.
> diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c b/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
> index d2f2dcc0f2e11..1c0e93dcb3ce5 100644
> --- a/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
> +++ b/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
[ ... ]
> @@ -76,6 +77,11 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
>
> err = bpf_prog_test_load(target_obj_file, BPF_PROG_TYPE_UNSPEC,
> &tgt_obj, &tgt_fd);
> + if (err < 0 && errno == EACCES && !get_unaligned_access_enabled()) {
> + test__skip();
> + return;
> + }
[Severity: Medium]
Should the packet offset alignment in test_pkt_write_access_subprog() and
new_test_pkt_write_access_subprog() be constrained instead of skipping these
subtests in test_fexit_bpf2bpf_common() and test_fmod_ret_freplace()?
The five subtests (target_yes_callees, func_replace, func_replace_multi,
fmod_ret_freplace, and func_replace_global_func) test BPF-to-BPF fexit,
freplace, and fmod_ret rather than unaligned packet access.
In tools/testing/selftests/bpf/progs/test_pkt_access.c, the caller
test_pkt_access() passes a 2-byte-aligned packet offset (void *)tcp - data.
However, because test_pkt_write_access_subprog() is a global function, the
verifier checks it standalone with an arbitrary scalar off bounded only by
off <= 54:
tools/testing/selftests/bpf/progs/test_pkt_access.c:test_pkt_write_access_subprog() {
...
if (off > sizeof(struct ethhdr) + sizeof(struct ipv6hdr))
return -1;
tcp = data + off;
if (tcp + 1 > data_end)
return -1;
/* make modification to the packet data */
tcp->check++;
...
}
And the replacement program in
tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c has the same pattern in
new_test_pkt_write_access_subprog():
tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c:new_test_pkt_write_access_subprog() {
...
if (off > sizeof(struct ethhdr) + sizeof(struct ipv6hdr))
return -1;
tcp = data + off;
if (tcp + 1 > data_end)
return -1;
/* make modifications to the packet data */
tcp->check++;
...
}
Skipping these tests in fexit_bpf2bpf drops fexit and freplace coverage on
strict-alignment architectures while leaving the other selftests that load
test_pkt_access.bpf.o (pkt_access, dynptr, kfree_skb, and prog_run_opts)
failing with the same -EACCES verifier error.
Would constraining the alignment of off (or performing a 1-byte modification)
in test_pkt_write_access_subprog() and new_test_pkt_write_access_subprog()
allow all of these tests to run on strict-alignment systems?
[ ... ]
> diff --git a/tools/testing/selftests/bpf/unpriv_helpers.c b/tools/testing/selftests/bpf/unpriv_helpers.c
> index c8dd5d8485841..54ce342b3fe41 100644
> --- a/tools/testing/selftests/bpf/unpriv_helpers.c
> +++ b/tools/testing/selftests/bpf/unpriv_helpers.c
> @@ -161,3 +161,8 @@ bool get_kasan_multi_shot_enabled(void)
> {
> return cmdline_contains("kasan_multi_shot");
> }
> +
> +bool get_unaligned_access_enabled(void)
> +{
> + return config_contains("CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y") == 1;
> +}
[Severity: Medium]
Can get_unaligned_access_enabled() cause test_fexit_bpf2bpf_common() and
test_fmod_ret_freplace() to mask genuine -EACCES verifier regressions as
skips?
In tools/testing/selftests/bpf/unpriv_helpers.c, open_config() returns NULL
and config_contains() returns -1 when neither /boot/config-$(uname -r) nor
/proc/config.gz is available in the test environment. Because
get_unaligned_access_enabled() checks for equality with 1, a -1 error return
is treated the same as CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS being disabled,
even on architectures where it is enabled.
In addition, EACCES is the generic error code returned by the BPF verifier for
most verification failures, and test_fexit_bpf2bpf_common() also loads target
objects that do not perform unaligned packet accesses
(./test_pkt_md_access.bpf.o, ./connect4_prog.bpf.o, and
./test_global_func7.bpf.o). Whenever get_unaligned_access_enabled() returns
false, wouldn't any verifier regression returning -EACCES in those programs be
silently reported as skipped instead of failing?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261102081230.7063-1-yangtiezhu@loongson.cn?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v1 1/2] selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader
2026-11-02 8:12 ` [PATCH bpf-next v1 1/2] selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader Tiezhu Yang
@ 2026-11-02 8:28 ` sashiko-bot
2026-11-03 2:01 ` Tiezhu Yang
0 siblings, 1 reply; 7+ messages in thread
From: sashiko-bot @ 2026-11-02 8:28 UTC (permalink / raw)
To: Tiezhu Yang; +Cc: bpf
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/bpf: indiscriminate EOPNOTSUPP skip in run_subtest()
--
commit 4fea47634d9e4204dd230efbc533c57d0013c98f
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader
This commit updates run_subtest() in test_loader to call test__skip() when
bpf_object__load() fails with errno == EOPNOTSUPP in the
!subspec->expect_failure path.
> diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/selftests/bpf/test_loader.c
> index d24e4fedae46f..021818afbd3bf 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;
> + }
[Severity: Medium]
Does checking errno == EOPNOTSUPP after bpf_object__load() in the
!subspec->expect_failure branch mask real verifier, BTF, CO-RE, and JIT
regressions while still leaving __failure and __prepare_priv subtests
broken when BPF_MAP_TYPE_ARENA is unsupported?
In tools/lib/bpf/libbpf.c, bpf_object__load() executes both
bpf_object_prepare() (BTF loading, CO-RE relocations, and
bpf_object__create_maps()) and bpf_object__load_progs() (program
verification and JIT compilation). During these steps, -EOPNOTSUPP is
returned for many conditions unrelated to missing platform hardware
extensions, such as add_kfunc_call(), require_callx_jit(),
process_timer_func(), sanitize_check_bounds(), check_hmul_jit(), and
check_attach_btf_id() in kernel/bpf/verifier.c, convert_ctx_accesses() in
kernel/bpf/fixups.c, btf_validate_return_type() and btf_scan_decl_tags()
in kernel/bpf/btf.c, check_struct_ops_btf_id() in
kernel/bpf/bpf_struct_ops.c, and bpf_core_apply_relo_insn() in
tools/lib/bpf/relo_core.c. Skipping any !subspec->expect_failure subtest
on EOPNOTSUPP will cause regressions in those paths to be silently skipped
instead of failing.
At the same time, when BPF_MAP_TYPE_ARENA is unsupported on the platform,
arena_map_alloc() in kernel/bpf/arena.c returns -EOPNOTSUPP during
bpf_object_prepare() -> bpf_object__create_maps(), so bpf_object__load()
aborts before bpf_object__load_progs() is called and leaves
tester->log_buf empty. For __failure subtests in objects declaring an
arena map (such as access_through_number in
tools/testing/selftests/bpf/progs/verifier_arena.c or arena_arg_bad_reg in
tools/testing/selftests/bpf/progs/arena_kfunc.c), run_subtest() takes the
subspec->expect_failure branch:
tools/testing/selftests/bpf/test_loader.c:run_subtest() {
...
if (subspec->expect_failure) {
if (!ASSERT_ERR(err, "unexpected_load_success")) {
emit_verifier_log(tester->log_buf, false /*force*/);
goto tobj_cleanup;
}
}
...
err = validate_msgs(tester->log_buf, &subspec->expect_msgs,
emit_verifier_log);
}
Here ASSERT_ERR() succeeds on the map creation error, and validate_msgs()
then fails because the verifier never ran and tester->log_buf is empty.
Similarly, if unpriv && spec->prepare_priv is set, bpf_object__prepare()
in run_subtest() fails at ASSERT_OK(err, "obj_prepare") before reaching
bpf_object__load():
tools/testing/selftests/bpf/test_loader.c:run_subtest() {
...
if (unpriv && spec->prepare_priv) {
err = bpf_object__prepare(tobj);
if (!ASSERT_OK(err, "obj_prepare"))
goto tobj_cleanup;
...
}
In addition, because run_subtest() enables map autocreation for all maps
in tobj in privileged mode, any object declaring an arena map alongside
unrelated non-arena subtests (such as compute_live_registers.c,
verifier_zext.c, and verifier_ldsx.c) will fail map creation in
bpf_object_prepare() and skip all non-arena subtests in that object when
BPF_MAP_TYPE_ARENA is unsupported.
Would it be better to explicitly probe for BPF_MAP_TYPE_ARENA support
(similar to libbpf_probe_bpf_map_type(BPF_MAP_TYPE_ARENA, NULL) in
test_verifier_hmul_arena() in
tools/testing/selftests/bpf/prog_tests/verifier_hmul_arena.c) or handle
unsupported map creation specifically, rather than catching all EOPNOTSUPP
errors from bpf_object__load()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261102081230.7063-1-yangtiezhu@loongson.cn?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v1 1/2] selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader
2026-11-02 8:28 ` sashiko-bot
@ 2026-11-03 2:01 ` Tiezhu Yang
0 siblings, 0 replies; 7+ messages in thread
From: Tiezhu Yang @ 2026-11-03 2:01 UTC (permalink / raw)
To: sashiko-reviews; +Cc: bpf
On 2026/11/2 下午4:28, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] selftests/bpf: indiscriminate EOPNOTSUPP skip in run_subtest()
...
> Would it be better to explicitly probe for BPF_MAP_TYPE_ARENA support
> (similar to libbpf_probe_bpf_map_type(BPF_MAP_TYPE_ARENA, NULL) in
> test_verifier_hmul_arena() in
> tools/testing/selftests/bpf/prog_tests/verifier_hmul_arena.c) or handle
> unsupported map creation specifically, rather than catching all EOPNOTSUPP
> errors from bpf_object__load()?
Will use libbpf_probe_bpf_map_type() in prog_tests instead of
handling EOPNOTSUPP globally in test_loader.
Something like this:
```
diff --git a/tools/testing/selftests/bpf/prog_tests/jit_insns.c
b/tools/testing/selftests/bpf/prog_tests/jit_insns.c
index 52bffe27199b..9c4cbf6807ae 100644
--- a/tools/testing/selftests/bpf/prog_tests/jit_insns.c
+++ b/tools/testing/selftests/bpf/prog_tests/jit_insns.c
@@ -3105,7 +3105,14 @@ static void test_helper_calls(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 {
+ if (test__start_subtest("arena_zero_off"))
+ test__skip();
+ if (test__start_subtest("cast_to_user"))
+ test__skip();
+ }
if (test__start_subtest("alu_imm"))
test_alu_imm();
if (test__start_subtest("alu_reg"))
```
I will send out v2 next week if no more comments.
Thanks,
Tiezhu
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next v1 2/2] selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf
2026-11-02 8:23 ` sashiko-bot
@ 2026-11-03 2:06 ` Tiezhu Yang
0 siblings, 0 replies; 7+ messages in thread
From: Tiezhu Yang @ 2026-11-03 2:06 UTC (permalink / raw)
To: sashiko-reviews; +Cc: bpf
On 2026/11/2 下午4:23, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
...
> Would constraining the alignment of off (or performing a 1-byte modification)
> in test_pkt_write_access_subprog() and new_test_pkt_write_access_subprog()
> allow all of these tests to run on strict-alignment systems?
Will fix unaligned access at the source by applying a bitmask
'off &= ~1' instead of skipping these tests entirely.
Something like this:
```
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;
```
I will send out v2 next week if no more comments.
Thanks,
Tiezhu
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-03 2:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 8:12 [PATCH bpf-next v1 0/2] selftests/bpf: Make some tests skipped Tiezhu Yang
2026-11-02 8:12 ` [PATCH bpf-next v1 1/2] selftests/bpf: Handle EOPNOTSUPP gracefully in test_loader Tiezhu Yang
2026-11-02 8:28 ` sashiko-bot
2026-11-03 2:01 ` Tiezhu Yang
2026-11-02 8:12 ` [PATCH bpf-next v1 2/2] selftests/bpf: Handle unaligned access failure in fexit_bpf2bpf Tiezhu Yang
2026-11-02 8:23 ` sashiko-bot
2026-11-03 2:06 ` Tiezhu Yang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.