Skip to content

Commit e06da84

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]>
1 parent 6d22435 commit e06da84

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__)
80+
#if !defined(__x86_64__) && !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
@@ -9,6 +9,7 @@
99
SEC("raw_tp")
1010
__description("may_goto 0")
1111
__arch_x86_64
12+
__arch_arm64
1213
__xlated("0: r0 = 1")
1314
__xlated("1: exit")
1415
__success
@@ -27,6 +28,7 @@ __naked void may_goto_simple(void)
2728
SEC("raw_tp")
2829
__description("batch 2 of may_goto 0")
2930
__arch_x86_64
31+
__arch_arm64
3032
__xlated("0: r0 = 1")
3133
__xlated("1: exit")
3234
__success
@@ -47,6 +49,7 @@ __naked void may_goto_batch_0(void)
4749
SEC("raw_tp")
4850
__description("may_goto batch with offsets 2/1/0")
4951
__arch_x86_64
52+
__arch_arm64
5053
__xlated("0: r0 = 1")
5154
__xlated("1: exit")
5255
__success
@@ -69,8 +72,9 @@ __naked void may_goto_batch_1(void)
6972
}
7073

7174
SEC("raw_tp")
72-
__description("may_goto batch with offsets 2/0 - x86_64")
75+
__description("may_goto batch with offsets 2/0")
7376
__arch_x86_64
77+
__arch_arm64
7478
__xlated("0: *(u64 *)(r10 -16) = 65535")
7579
__xlated("1: *(u64 *)(r10 -8) = 0")
7680
__xlated("2: r11 = *(u64 *)(r10 -16)")
@@ -84,33 +88,7 @@ __xlated("9: r0 = 1")
8488
__xlated("10: r0 = 2")
8589
__xlated("11: exit")
8690
__success
87-
__naked void may_goto_batch_2_x86_64(void)
88-
{
89-
asm volatile (
90-
".8byte %[may_goto1];"
91-
".8byte %[may_goto3];"
92-
"r0 = 1;"
93-
"r0 = 2;"
94-
"exit;"
95-
:
96-
: __imm_insn(may_goto1, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 2 /* offset */, 0)),
97-
__imm_insn(may_goto3, BPF_RAW_INSN(BPF_JMP | BPF_JCOND, 0, 0, 0 /* offset */, 0))
98-
: __clobber_all);
99-
}
100-
101-
SEC("raw_tp")
102-
__description("may_goto batch with offsets 2/0 - arm64")
103-
__arch_arm64
104-
__xlated("0: *(u64 *)(r10 -8) = 8388608")
105-
__xlated("1: r11 = *(u64 *)(r10 -8)")
106-
__xlated("2: if r11 == 0x0 goto pc+3")
107-
__xlated("3: r11 -= 1")
108-
__xlated("4: *(u64 *)(r10 -8) = r11")
109-
__xlated("5: r0 = 1")
110-
__xlated("6: r0 = 2")
111-
__xlated("7: exit")
112-
__success
113-
__naked void may_goto_batch_2_arm64(void)
91+
__naked void may_goto_batch_2(void)
11492
{
11593
asm volatile (
11694
".8byte %[may_goto1];"

0 commit comments

Comments
 (0)