1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
5 #include <bpf/bpf_tracing.h>
7 #include "../test_kmods/bpf_testmod.h"
8 #include "../test_kmods/bpf_testmod_kfunc.h"
10 char _license[] SEC("license") = "GPL";
14 __xlated("0: r6 = *(u64 *)(r1 +0)")
15 __xlated("1: r7 = *(u64 *)(r6 +0)")
16 __xlated("2: r7 += 1000")
17 __xlated("3: *(u64 *)(r6 +0) = r7")
19 __xlated("4: if r1 == 0x0 goto pc+5")
20 __xlated("5: if r1 == 0x1 goto pc+2")
22 __xlated("7: goto pc-3")
24 __xlated("9: goto pc-6")
25 __xlated("10: r0 = 0")
27 SEC("struct_ops/test_prologue_goto_start")
28 __naked int test_prologue_goto_start(void)
43 /* save __u64 *ctx to stack */
44 __xlated("0: *(u64 *)(r10 -8) = r1")
46 __xlated("1: if r1 == 0x0 goto pc+5")
47 __xlated("2: if r1 == 0x1 goto pc+2")
49 __xlated("4: goto pc-3")
51 __xlated("6: goto pc-6")
54 __xlated("8: r1 = *(u64 *)(r10 -8)")
55 __xlated("9: r1 = *(u64 *)(r1 +0)")
56 __xlated("10: r6 = *(u64 *)(r1 +0)")
57 __xlated("11: r6 += 10000")
58 __xlated("12: *(u64 *)(r1 +0) = r6")
59 __xlated("13: r0 = r6")
60 __xlated("14: r0 *= 2")
62 SEC("struct_ops/test_epilogue_goto_start")
63 __naked int test_epilogue_goto_start(void)
79 __xlated("0: r6 = *(u64 *)(r1 +0)")
80 __xlated("1: r7 = *(u64 *)(r6 +0)")
81 __xlated("2: r7 += 1000")
82 __xlated("3: *(u64 *)(r6 +0) = r7")
83 /* save __u64 *ctx to stack */
84 __xlated("4: *(u64 *)(r10 -8) = r1")
86 __xlated("5: if r1 == 0x0 goto pc+5")
87 __xlated("6: if r1 == 0x1 goto pc+2")
89 __xlated("8: goto pc-3")
91 __xlated("10: goto pc-6")
92 __xlated("11: r0 = 0")
94 __xlated("12: r1 = *(u64 *)(r10 -8)")
95 __xlated("13: r1 = *(u64 *)(r1 +0)")
96 __xlated("14: r6 = *(u64 *)(r1 +0)")
97 __xlated("15: r6 += 10000")
98 __xlated("16: *(u64 *)(r1 +0) = r6")
99 __xlated("17: r0 = r6")
100 __xlated("18: r0 *= 2")
102 SEC("struct_ops/test_pro_epilogue_goto_start")
103 __naked int test_pro_epilogue_goto_start(void)
106 "if r1 == 0 goto +5;"
107 "if r1 == 1 goto +2;"
117 SEC(".struct_ops.link")
118 struct bpf_testmod_st_ops epilogue_goto_start = {
119 .test_prologue = (void *)test_prologue_goto_start,
120 .test_epilogue = (void *)test_epilogue_goto_start,
121 .test_pro_epilogue = (void *)test_pro_epilogue_goto_start,
126 int syscall_prologue_goto_start(void *ctx)
128 struct st_ops_args args = {};
130 return bpf_kfunc_st_ops_test_prologue(&args);
134 __retval(20000) /* (EPILOGUE_A [10000]) * 2 */
135 int syscall_epilogue_goto_start(void *ctx)
137 struct st_ops_args args = {};
139 return bpf_kfunc_st_ops_test_epilogue(&args);
143 __retval(22000) /* (PROLOGUE_A [1000] + EPILOGUE_A [10000]) * 2 */
144 int syscall_pro_epilogue_goto_start(void *ctx)
146 struct st_ops_args args = {};
148 return bpf_kfunc_st_ops_test_pro_epilogue(&args);