Skip to content

Commit 44ac5a8

Browse files
puranjaymohanKernel Patches Daemon
authored andcommitted
selftests/bpf: Enable timed may_goto tests for arm64
As arm64 JIT now supports timed may_goto instruction, make sure all relevant tests run on this architecture. Some tests were enabled and other required modifications to work properly on arm64. $ ./test_progs -a "stream*","*may_goto*",verifier_bpf_fastcall #404 stream_errors:OK [...] #406/2 stream_success/stream_cond_break:OK [...] #494/23 verifier_bpf_fastcall/may_goto_interaction_x86_64:SKIP #494/24 verifier_bpf_fastcall/may_goto_interaction_arm64:OK [...] #539/1 verifier_may_goto_1/may_goto 0:OK #539/2 verifier_may_goto_1/batch 2 of may_goto 0:OK #539/3 verifier_may_goto_1/may_goto batch with offsets 2/1/0:OK #539/4 verifier_may_goto_1/may_goto batch with offsets 2/0:OK #539 verifier_may_goto_1:OK #540/1 verifier_may_goto_2/C code with may_goto 0:OK #540 verifier_may_goto_2:OK Summary: 7/16 PASSED, 25 SKIPPED, 0 FAILED Signed-off-by: Puranjay Mohan <[email protected]> Acked-by: Kumar Kartikeya Dwivedi <[email protected]> Acked-by: Xu Kuohai <[email protected]>
1 parent d67f22c commit 44ac5a8

File tree

3 files changed

+23
-40
lines changed

3 files changed

+23
-40
lines changed

tools/testing/selftests/bpf/prog_tests/stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void test_stream_errors(void)
7777
ASSERT_OK(ret, "ret");
7878
ASSERT_OK(opts.retval, "retval");
7979

80-
#if !defined(__x86_64__) && !defined(__s390x__)
80+
#if !defined(__x86_64__) && !defined(__s390x__) && !defined(__aarch64__)
8181
ASSERT_TRUE(1, "Timed may_goto unsupported, skip.");
8282
if (i == 0) {
8383
ret = bpf_prog_stream_read(prog_fd, 2, buf, sizeof(buf), &ropts);

tools/testing/selftests/bpf/progs/verifier_bpf_fastcall.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -660,19 +660,24 @@ __naked void may_goto_interaction_x86_64(void)
660660

661661
SEC("raw_tp")
662662
__arch_arm64
663-
__log_level(4) __msg("stack depth 16")
664-
/* may_goto counter at -16 */
665-
__xlated("0: *(u64 *)(r10 -16) =")
666-
__xlated("1: r1 = 1")
667-
__xlated("2: call bpf_get_smp_processor_id")
663+
__log_level(4) __msg("stack depth 24")
664+
/* may_goto counter at -24 */
665+
__xlated("0: *(u64 *)(r10 -24) =")
666+
/* may_goto timestamp at -16 */
667+
__xlated("1: *(u64 *)(r10 -16) =")
668+
__xlated("2: r1 = 1")
669+
__xlated("3: call bpf_get_smp_processor_id")
668670
/* may_goto expansion starts */
669-
__xlated("3: r11 = *(u64 *)(r10 -16)")
670-
__xlated("4: if r11 == 0x0 goto pc+3")
671-
__xlated("5: r11 -= 1")
672-
__xlated("6: *(u64 *)(r10 -16) = r11")
671+
__xlated("4: r11 = *(u64 *)(r10 -24)")
672+
__xlated("5: if r11 == 0x0 goto pc+6")
673+
__xlated("6: r11 -= 1")
674+
__xlated("7: if r11 != 0x0 goto pc+2")
675+
__xlated("8: r11 = -24")
676+
__xlated("9: call unknown")
677+
__xlated("10: *(u64 *)(r10 -24) = r11")
673678
/* may_goto expansion ends */
674-
__xlated("7: *(u64 *)(r10 -8) = r1")
675-
__xlated("8: exit")
679+
__xlated("11: *(u64 *)(r10 -8) = r1")
680+
__xlated("12: exit")
676681
__success
677682
__naked void may_goto_interaction_arm64(void)
678683
{

tools/testing/selftests/bpf/progs/verifier_may_goto_1.c

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ SEC("raw_tp")
1010
__description("may_goto 0")
1111
__arch_x86_64
1212
__arch_s390x
13+
__arch_arm64
1314
__xlated("0: r0 = 1")
1415
__xlated("1: exit")
1516
__success
@@ -29,6 +30,7 @@ SEC("raw_tp")
2930
__description("batch 2 of may_goto 0")
3031
__arch_x86_64
3132
__arch_s390x
33+
__arch_arm64
3234
__xlated("0: r0 = 1")
3335
__xlated("1: exit")
3436
__success
@@ -50,6 +52,7 @@ SEC("raw_tp")
5052
__description("may_goto batch with offsets 2/1/0")
5153
__arch_x86_64
5254
__arch_s390x
55+
__arch_arm64
5356
__xlated("0: r0 = 1")
5457
__xlated("1: exit")
5558
__success
@@ -72,9 +75,10 @@ __naked void may_goto_batch_1(void)
7275
}
7376

7477
SEC("raw_tp")
75-
__description("may_goto batch with offsets 2/0 - x86_64 and s390x")
78+
__description("may_goto batch with offsets 2/0")
7679
__arch_x86_64
7780
__arch_s390x
81+
__arch_arm64
7882
__xlated("0: *(u64 *)(r10 -16) = 65535")
7983
__xlated("1: *(u64 *)(r10 -8) = 0")
8084
__xlated("2: r11 = *(u64 *)(r10 -16)")
@@ -88,33 +92,7 @@ __xlated("9: r0 = 1")
8892
__xlated("10: r0 = 2")
8993
__xlated("11: exit")
9094
__success
91-
__naked void may_goto_batch_2_x86_64_s390x(void)
92-
{
93-
asm volatile (
94-
".8byte %[may_goto1];"
95-
".8byte %[may_goto3];"
96-
"r0 = 1;"
97-
"r0 = 2;"
98-
"exit;"
99-
:
100-
: __imm_insn(may_goto1, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 2 /* offset */, 0)),
101-
__imm_insn(may_goto3, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 0 /* offset */, 0))
102-
: __clobber_all);
103-
}
104-
105-
SEC("raw_tp")
106-
__description("may_goto batch with offsets 2/0 - arm64")
107-
__arch_arm64
108-
__xlated("0: *(u64 *)(r10 -8) = 8388608")
109-
__xlated("1: r11 = *(u64 *)(r10 -8)")
110-
__xlated("2: if r11 == 0x0 goto pc+3")
111-
__xlated("3: r11 -= 1")
112-
__xlated("4: *(u64 *)(r10 -8) = r11")
113-
__xlated("5: r0 = 1")
114-
__xlated("6: r0 = 2")
115-
__xlated("7: exit")
116-
__success
117-
__naked void may_goto_batch_2_arm64(void)
95+
__naked void may_goto_batch_2(void)
11896
{
11997
asm volatile (
12098
".8byte %[may_goto1];"

0 commit comments

Comments
 (0)