Skip to content

Commit b700339

Browse files
seehearfeelKernel Patches Daemon
authored andcommitted
selftests/bpf: Check alignment flag if expected result is REJECT
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set unconditionally for the most archs such as x86_64, aarch64, ppc64el and s390x, but this config may be not set by users for riscv64 and loongarch64. If CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set, the BPF verifier detects if a program has unaligned access and then rejects them. So it should also check the flag F_NEEDS_EFFICIENT_UNALIGNED_ACCESS if the expected result is REJECT and set alignment_prevented_execution as 1, then the message "(NOTE: not executed due to unknown alignment)" can be printed for some testcases of test_verifier to reflect the reality. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
1 parent 026b5c1 commit b700339

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/testing/selftests/bpf/test_verifier.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,11 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
16401640
printf("FAIL\nUnexpected success to load!\n");
16411641
goto fail_log;
16421642
}
1643+
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
1644+
if (fd_prog < 0 &&
1645+
(test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS))
1646+
alignment_prevented_execution = 1;
1647+
#endif
16431648
if (!expected_err || !cmp_str_seq(bpf_vlog, expected_err)) {
16441649
printf("FAIL\nUnexpected error message!\n\tEXP: %s\n\tRES: %s\n",
16451650
expected_err, bpf_vlog);

0 commit comments

Comments
 (0)