1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ 3 4 #include <vmlinux.h> 5 #include <bpf/bpf_tracing.h> 6 #include <bpf/bpf_helpers.h> 7 8 struct bpf_testmod_struct_arg_1 { 9 int a; 10 }; 11 struct bpf_testmod_struct_arg_2 { 12 long a; 13 long b; 14 }; 15 16 struct bpf_testmod_struct_arg_3 { 17 int a; 18 int b[]; 19 }; 20 21 struct bpf_testmod_struct_arg_4 { 22 u64 a; 23 int b; 24 }; 25 26 long t1_a_a, t1_a_b, t1_b, t1_c, t1_ret, t1_nregs; 27 __u64 t1_reg0, t1_reg1, t1_reg2, t1_reg3; 28 long t2_a, t2_b_a, t2_b_b, t2_c, t2_ret; 29 long t3_a, t3_b, t3_c_a, t3_c_b, t3_ret; 30 long t4_a_a, t4_b, t4_c, t4_d, t4_e_a, t4_e_b, t4_ret; 31 long t5_ret; 32 int t6; 33 long t7_a, t7_b, t7_c, t7_d, t7_e, t7_f_a, t7_f_b, t7_ret; 34 long t8_a, t8_b, t8_c, t8_d, t8_e, t8_f_a, t8_f_b, t8_g, t8_ret; 35 36 37 SEC("fentry/bpf_testmod_test_struct_arg_1") 38 int BPF_PROG2(test_struct_arg_1, struct bpf_testmod_struct_arg_2, a, int, b, int, c) 39 { 40 t1_a_a = a.a; 41 t1_a_b = a.b; 42 t1_b = b; 43 t1_c = c; 44 return 0; 45 } 46 47 SEC("fexit/bpf_testmod_test_struct_arg_1") 48 int BPF_PROG2(test_struct_arg_2, struct bpf_testmod_struct_arg_2, a, int, b, int, c, int, ret) 49 { 50 t1_nregs = bpf_get_func_arg_cnt(ctx); 51 /* a.a */ 52 bpf_get_func_arg(ctx, 0, &t1_reg0); 53 /* a.b */ 54 bpf_get_func_arg(ctx, 1, &t1_reg1); 55 /* b */ 56 bpf_get_func_arg(ctx, 2, &t1_reg2); 57 t1_reg2 = (int)t1_reg2; 58 /* c */ 59 bpf_get_func_arg(ctx, 3, &t1_reg3); 60 t1_reg3 = (int)t1_reg3; 61 62 t1_ret = ret; 63 return 0; 64 } 65 66 SEC("fentry/bpf_testmod_test_struct_arg_2") 67 int BPF_PROG2(test_struct_arg_3, int, a, struct bpf_testmod_struct_arg_2, b, int, c) 68 { 69 t2_a = a; 70 t2_b_a = b.a; 71 t2_b_b = b.b; 72 t2_c = c; 73 return 0; 74 } 75 76 SEC("fexit/bpf_testmod_test_struct_arg_2") 77 int BPF_PROG2(test_struct_arg_4, int, a, struct bpf_testmod_struct_arg_2, b, int, c, int, ret) 78 { 79 t2_ret = ret; 80 return 0; 81 } 82 83 SEC("fentry/bpf_testmod_test_struct_arg_3") 84 int BPF_PROG2(test_struct_arg_5, int, a, int, b, struct bpf_testmod_struct_arg_2, c) 85 { 86 t3_a = a; 87 t3_b = b; 88 t3_c_a = c.a; 89 t3_c_b = c.b; 90 return 0; 91 } 92 93 SEC("fexit/bpf_testmod_test_struct_arg_3") 94 int BPF_PROG2(test_struct_arg_6, int, a, int, b, struct bpf_testmod_struct_arg_2, c, int, ret) 95 { 96 t3_ret = ret; 97 return 0; 98 } 99 100 SEC("fentry/bpf_testmod_test_struct_arg_4") 101 int BPF_PROG2(test_struct_arg_7, struct bpf_testmod_struct_arg_1, a, int, b, 102 int, c, int, d, struct bpf_testmod_struct_arg_2, e) 103 { 104 t4_a_a = a.a; 105 t4_b = b; 106 t4_c = c; 107 t4_d = d; 108 t4_e_a = e.a; 109 t4_e_b = e.b; 110 return 0; 111 } 112 113 SEC("fexit/bpf_testmod_test_struct_arg_4") 114 int BPF_PROG2(test_struct_arg_8, struct bpf_testmod_struct_arg_1, a, int, b, 115 int, c, int, d, struct bpf_testmod_struct_arg_2, e, int, ret) 116 { 117 t4_ret = ret; 118 return 0; 119 } 120 121 SEC("fentry/bpf_testmod_test_struct_arg_5") 122 int BPF_PROG2(test_struct_arg_9) 123 { 124 return 0; 125 } 126 127 SEC("fexit/bpf_testmod_test_struct_arg_5") 128 int BPF_PROG2(test_struct_arg_10, int, ret) 129 { 130 t5_ret = ret; 131 return 0; 132 } 133 134 SEC("fentry/bpf_testmod_test_struct_arg_6") 135 int BPF_PROG2(test_struct_arg_11, struct bpf_testmod_struct_arg_3 *, a) 136 { 137 t6 = a->b[0]; 138 return 0; 139 } 140 141 SEC("fentry/bpf_testmod_test_struct_arg_7") 142 int BPF_PROG2(test_struct_arg_12, __u64, a, void *, b, short, c, int, d, 143 void *, e, struct bpf_testmod_struct_arg_4, f) 144 { 145 t7_a = a; 146 t7_b = (long)b; 147 t7_c = c; 148 t7_d = d; 149 t7_e = (long)e; 150 t7_f_a = f.a; 151 t7_f_b = f.b; 152 return 0; 153 } 154 155 SEC("fexit/bpf_testmod_test_struct_arg_7") 156 int BPF_PROG2(test_struct_arg_13, __u64, a, void *, b, short, c, int, d, 157 void *, e, struct bpf_testmod_struct_arg_4, f, int, ret) 158 { 159 t7_ret = ret; 160 return 0; 161 } 162 163 SEC("fentry/bpf_testmod_test_struct_arg_8") 164 int BPF_PROG2(test_struct_arg_14, __u64, a, void *, b, short, c, int, d, 165 void *, e, struct bpf_testmod_struct_arg_4, f, int, g) 166 { 167 t8_a = a; 168 t8_b = (long)b; 169 t8_c = c; 170 t8_d = d; 171 t8_e = (long)e; 172 t8_f_a = f.a; 173 t8_f_b = f.b; 174 t8_g = g; 175 return 0; 176 } 177 178 SEC("fexit/bpf_testmod_test_struct_arg_8") 179 int BPF_PROG2(test_struct_arg_15, __u64, a, void *, b, short, c, int, d, 180 void *, e, struct bpf_testmod_struct_arg_4, f, int, g, 181 int, ret) 182 { 183 t8_ret = ret; 184 return 0; 185 } 186 187 char _license[] SEC("license") = "GPL"; 188