Skip to content

Commit 38608ee

Browse files
Xu Kuohaiborkmann
authored andcommitted
bpf, tests: Add load store test case for tail call
Add test case to enusre that the caller and callee's fp offsets are correct during tail call (mainly asserting for arm64 JIT). Tested on both big-endian and little-endian arm64 qemu, result: test_bpf: Summary: 1026 PASSED, 0 FAILED, [1014/1014 JIT'ed] test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed] test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED Signed-off-by: Xu Kuohai <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent f516420 commit 38608ee

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

lib/test_bpf.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14950,6 +14950,36 @@ static struct tail_call_test tail_call_tests[] = {
1495014950
},
1495114951
.result = 10,
1495214952
},
14953+
{
14954+
"Tail call load/store leaf",
14955+
.insns = {
14956+
BPF_ALU64_IMM(BPF_MOV, R1, 1),
14957+
BPF_ALU64_IMM(BPF_MOV, R2, 2),
14958+
BPF_ALU64_REG(BPF_MOV, R3, BPF_REG_FP),
14959+
BPF_STX_MEM(BPF_DW, R3, R1, -8),
14960+
BPF_STX_MEM(BPF_DW, R3, R2, -16),
14961+
BPF_LDX_MEM(BPF_DW, R0, BPF_REG_FP, -8),
14962+
BPF_JMP_REG(BPF_JNE, R0, R1, 3),
14963+
BPF_LDX_MEM(BPF_DW, R0, BPF_REG_FP, -16),
14964+
BPF_JMP_REG(BPF_JNE, R0, R2, 1),
14965+
BPF_ALU64_IMM(BPF_MOV, R0, 0),
14966+
BPF_EXIT_INSN(),
14967+
},
14968+
.result = 0,
14969+
.stack_depth = 32,
14970+
},
14971+
{
14972+
"Tail call load/store",
14973+
.insns = {
14974+
BPF_ALU64_IMM(BPF_MOV, R0, 3),
14975+
BPF_STX_MEM(BPF_DW, BPF_REG_FP, R0, -8),
14976+
TAIL_CALL(-1),
14977+
BPF_ALU64_IMM(BPF_MOV, R0, -1),
14978+
BPF_EXIT_INSN(),
14979+
},
14980+
.result = 0,
14981+
.stack_depth = 16,
14982+
},
1495314983
{
1495414984
"Tail call error path, max count reached",
1495514985
.insns = {

0 commit comments

Comments
 (0)