Skip to content

Commit e9f545d

Browse files
puranjaymohanborkmann
authored andcommitted
selftests/bpf: Enable private stack tests for arm64
As arm64 JIT now supports private stack, make sure all relevant tests run on arm64 architecture. Relevant tests: #415/1 struct_ops_private_stack/private_stack:OK #415/2 struct_ops_private_stack/private_stack_fail:OK #415/3 struct_ops_private_stack/private_stack_recur:OK #415 struct_ops_private_stack:OK #549/1 verifier_private_stack/Private stack, single prog:OK #549/2 verifier_private_stack/Private stack, subtree > MAX_BPF_STACK:OK #549/3 verifier_private_stack/No private stack:OK #549/4 verifier_private_stack/Private stack, callback:OK #549/5 verifier_private_stack/Private stack, exception in mainprog:OK #549/6 verifier_private_stack/Private stack, exception in subprog:OK #549/7 verifier_private_stack/Private stack, async callback, not nested:OK #549/8 verifier_private_stack/Private stack, async callback, potential nesting:OK #549 verifier_private_stack:OK Summary: 2/11 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Puranjay Mohan <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 6c17a88 commit e9f545d

File tree

4 files changed

+91
-4
lines changed

4 files changed

+91
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
char _license[] SEC("license") = "GPL";
99

10-
#if defined(__TARGET_ARCH_x86)
10+
#if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)
1111
bool skip __attribute((__section__(".data"))) = false;
1212
#else
1313
bool skip = true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
char _license[] SEC("license") = "GPL";
99

10-
#if defined(__TARGET_ARCH_x86)
10+
#if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)
1111
bool skip __attribute((__section__(".data"))) = false;
1212
#else
1313
bool skip = true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
char _license[] SEC("license") = "GPL";
99

10-
#if defined(__TARGET_ARCH_x86)
10+
#if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)
1111
bool skip __attribute((__section__(".data"))) = false;
1212
#else
1313
bool skip = true;

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

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/* From include/linux/filter.h */
99
#define MAX_BPF_STACK 512
1010

11-
#if defined(__TARGET_ARCH_x86)
11+
#if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)
1212

1313
struct elem {
1414
struct bpf_timer t;
@@ -30,6 +30,18 @@ __jited(" movabsq $0x{{.*}}, %r9")
3030
__jited(" addq %gs:{{.*}}, %r9")
3131
__jited(" movl $0x2a, %edi")
3232
__jited(" movq %rdi, -0x100(%r9)")
33+
__arch_arm64
34+
__jited(" stp x25, x27, [sp, {{.*}}]!")
35+
__jited(" mov x27, {{.*}}")
36+
__jited(" movk x27, {{.*}}, lsl #16")
37+
__jited(" movk x27, {{.*}}")
38+
__jited(" mrs x10, TPIDR_EL{{[0-1]}}")
39+
__jited(" add x27, x27, x10")
40+
__jited(" add x25, x27, {{.*}}")
41+
__jited(" mov x0, #0x2a")
42+
__jited(" str x0, [x27]")
43+
__jited("...")
44+
__jited(" ldp x25, x27, [sp], {{.*}}")
3345
__naked void private_stack_single_prog(void)
3446
{
3547
asm volatile (" \
@@ -45,6 +57,9 @@ __description("No private stack")
4557
__success
4658
__arch_x86_64
4759
__jited(" subq $0x8, %rsp")
60+
__arch_arm64
61+
__jited(" mov x25, sp")
62+
__jited(" sub sp, sp, #0x10")
4863
__naked void no_private_stack_nested(void)
4964
{
5065
asm volatile (" \
@@ -81,6 +96,19 @@ __jited(" pushq %r9")
8196
__jited(" callq 0x{{.*}}")
8297
__jited(" popq %r9")
8398
__jited(" xorl %eax, %eax")
99+
__arch_arm64
100+
__jited(" stp x25, x27, [sp, {{.*}}]!")
101+
__jited(" mov x27, {{.*}}")
102+
__jited(" movk x27, {{.*}}, lsl #16")
103+
__jited(" movk x27, {{.*}}")
104+
__jited(" mrs x10, TPIDR_EL{{[0-1]}}")
105+
__jited(" add x27, x27, x10")
106+
__jited(" add x25, x27, {{.*}}")
107+
__jited(" mov x0, #0x2a")
108+
__jited(" str x0, [x27]")
109+
__jited(" bl {{.*}}")
110+
__jited("...")
111+
__jited(" ldp x25, x27, [sp], {{.*}}")
84112
__naked void private_stack_nested_1(void)
85113
{
86114
asm volatile (" \
@@ -131,6 +159,24 @@ __jited(" movq %rdi, -0x200(%r9)")
131159
__jited(" pushq %r9")
132160
__jited(" callq")
133161
__jited(" popq %r9")
162+
__arch_arm64
163+
__jited("func #1")
164+
__jited("...")
165+
__jited(" stp x25, x27, [sp, {{.*}}]!")
166+
__jited(" mov x27, {{.*}}")
167+
__jited(" movk x27, {{.*}}, lsl #16")
168+
__jited(" movk x27, {{.*}}")
169+
__jited(" mrs x10, TPIDR_EL{{[0-1]}}")
170+
__jited(" add x27, x27, x10")
171+
__jited(" add x25, x27, {{.*}}")
172+
__jited(" bl 0x{{.*}}")
173+
__jited(" add x7, x0, #0x0")
174+
__jited(" mov x0, #0x2a")
175+
__jited(" str x0, [x27]")
176+
__jited(" bl 0x{{.*}}")
177+
__jited(" add x7, x0, #0x0")
178+
__jited(" mov x7, #0x0")
179+
__jited(" ldp x25, x27, [sp], {{.*}}")
134180
__naked void private_stack_callback(void)
135181
{
136182
asm volatile (" \
@@ -154,6 +200,28 @@ __arch_x86_64
154200
__jited(" pushq %r9")
155201
__jited(" callq")
156202
__jited(" popq %r9")
203+
__arch_arm64
204+
__jited(" stp x29, x30, [sp, #-0x10]!")
205+
__jited(" mov x29, sp")
206+
__jited(" stp xzr, x26, [sp, #-0x10]!")
207+
__jited(" mov x26, sp")
208+
__jited(" stp x19, x20, [sp, #-0x10]!")
209+
__jited(" stp x21, x22, [sp, #-0x10]!")
210+
__jited(" stp x23, x24, [sp, #-0x10]!")
211+
__jited(" stp x25, x26, [sp, #-0x10]!")
212+
__jited(" stp x27, x28, [sp, #-0x10]!")
213+
__jited(" mov x27, {{.*}}")
214+
__jited(" movk x27, {{.*}}, lsl #16")
215+
__jited(" movk x27, {{.*}}")
216+
__jited(" mrs x10, TPIDR_EL{{[0-1]}}")
217+
__jited(" add x27, x27, x10")
218+
__jited(" add x25, x27, {{.*}}")
219+
__jited(" mov x0, #0x2a")
220+
__jited(" str x0, [x27]")
221+
__jited(" mov x0, #0x0")
222+
__jited(" bl 0x{{.*}}")
223+
__jited(" add x7, x0, #0x0")
224+
__jited(" ldp x27, x28, [sp], #0x10")
157225
int private_stack_exception_main_prog(void)
158226
{
159227
asm volatile (" \
@@ -179,6 +247,19 @@ __jited(" movq %rdi, -0x200(%r9)")
179247
__jited(" pushq %r9")
180248
__jited(" callq")
181249
__jited(" popq %r9")
250+
__arch_arm64
251+
__jited(" stp x27, x28, [sp, #-0x10]!")
252+
__jited(" mov x27, {{.*}}")
253+
__jited(" movk x27, {{.*}}, lsl #16")
254+
__jited(" movk x27, {{.*}}")
255+
__jited(" mrs x10, TPIDR_EL{{[0-1]}}")
256+
__jited(" add x27, x27, x10")
257+
__jited(" add x25, x27, {{.*}}")
258+
__jited(" mov x0, #0x2a")
259+
__jited(" str x0, [x27]")
260+
__jited(" bl 0x{{.*}}")
261+
__jited(" add x7, x0, #0x0")
262+
__jited(" ldp x27, x28, [sp], #0x10")
182263
int private_stack_exception_sub_prog(void)
183264
{
184265
asm volatile (" \
@@ -220,6 +301,10 @@ __description("Private stack, async callback, not nested")
220301
__success __retval(0)
221302
__arch_x86_64
222303
__jited(" movabsq $0x{{.*}}, %r9")
304+
__arch_arm64
305+
__jited(" mrs x10, TPIDR_EL{{[0-1]}}")
306+
__jited(" add x27, x27, x10")
307+
__jited(" add x25, x27, {{.*}}")
223308
int private_stack_async_callback_1(void)
224309
{
225310
struct bpf_timer *arr_timer;
@@ -241,6 +326,8 @@ __description("Private stack, async callback, potential nesting")
241326
__success __retval(0)
242327
__arch_x86_64
243328
__jited(" subq $0x100, %rsp")
329+
__arch_arm64
330+
__jited(" sub sp, sp, #0x100")
244331
int private_stack_async_callback_2(void)
245332
{
246333
struct bpf_timer *arr_timer;

0 commit comments

Comments
 (0)