162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#include <vmlinux.h> 562306a36Sopenharmony_ci#include <bpf/bpf_tracing.h> 662306a36Sopenharmony_ci#include <bpf/bpf_helpers.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_cistruct bpf_testmod_struct_arg_1 { 962306a36Sopenharmony_ci int a; 1062306a36Sopenharmony_ci}; 1162306a36Sopenharmony_cistruct bpf_testmod_struct_arg_2 { 1262306a36Sopenharmony_ci long a; 1362306a36Sopenharmony_ci long b; 1462306a36Sopenharmony_ci}; 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_cistruct bpf_testmod_struct_arg_3 { 1762306a36Sopenharmony_ci int a; 1862306a36Sopenharmony_ci int b[]; 1962306a36Sopenharmony_ci}; 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_cistruct bpf_testmod_struct_arg_4 { 2262306a36Sopenharmony_ci u64 a; 2362306a36Sopenharmony_ci int b; 2462306a36Sopenharmony_ci}; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cilong t1_a_a, t1_a_b, t1_b, t1_c, t1_ret, t1_nregs; 2762306a36Sopenharmony_ci__u64 t1_reg0, t1_reg1, t1_reg2, t1_reg3; 2862306a36Sopenharmony_cilong t2_a, t2_b_a, t2_b_b, t2_c, t2_ret; 2962306a36Sopenharmony_cilong t3_a, t3_b, t3_c_a, t3_c_b, t3_ret; 3062306a36Sopenharmony_cilong t4_a_a, t4_b, t4_c, t4_d, t4_e_a, t4_e_b, t4_ret; 3162306a36Sopenharmony_cilong t5_ret; 3262306a36Sopenharmony_ciint t6; 3362306a36Sopenharmony_cilong t7_a, t7_b, t7_c, t7_d, t7_e, t7_f_a, t7_f_b, t7_ret; 3462306a36Sopenharmony_cilong t8_a, t8_b, t8_c, t8_d, t8_e, t8_f_a, t8_f_b, t8_g, t8_ret; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ciSEC("fentry/bpf_testmod_test_struct_arg_1") 3862306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_1, struct bpf_testmod_struct_arg_2, a, int, b, int, c) 3962306a36Sopenharmony_ci{ 4062306a36Sopenharmony_ci t1_a_a = a.a; 4162306a36Sopenharmony_ci t1_a_b = a.b; 4262306a36Sopenharmony_ci t1_b = b; 4362306a36Sopenharmony_ci t1_c = c; 4462306a36Sopenharmony_ci return 0; 4562306a36Sopenharmony_ci} 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ciSEC("fexit/bpf_testmod_test_struct_arg_1") 4862306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_2, struct bpf_testmod_struct_arg_2, a, int, b, int, c, int, ret) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci t1_nregs = bpf_get_func_arg_cnt(ctx); 5162306a36Sopenharmony_ci /* a.a */ 5262306a36Sopenharmony_ci bpf_get_func_arg(ctx, 0, &t1_reg0); 5362306a36Sopenharmony_ci /* a.b */ 5462306a36Sopenharmony_ci bpf_get_func_arg(ctx, 1, &t1_reg1); 5562306a36Sopenharmony_ci /* b */ 5662306a36Sopenharmony_ci bpf_get_func_arg(ctx, 2, &t1_reg2); 5762306a36Sopenharmony_ci t1_reg2 = (int)t1_reg2; 5862306a36Sopenharmony_ci /* c */ 5962306a36Sopenharmony_ci bpf_get_func_arg(ctx, 3, &t1_reg3); 6062306a36Sopenharmony_ci t1_reg3 = (int)t1_reg3; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci t1_ret = ret; 6362306a36Sopenharmony_ci return 0; 6462306a36Sopenharmony_ci} 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ciSEC("fentry/bpf_testmod_test_struct_arg_2") 6762306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_3, int, a, struct bpf_testmod_struct_arg_2, b, int, c) 6862306a36Sopenharmony_ci{ 6962306a36Sopenharmony_ci t2_a = a; 7062306a36Sopenharmony_ci t2_b_a = b.a; 7162306a36Sopenharmony_ci t2_b_b = b.b; 7262306a36Sopenharmony_ci t2_c = c; 7362306a36Sopenharmony_ci return 0; 7462306a36Sopenharmony_ci} 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ciSEC("fexit/bpf_testmod_test_struct_arg_2") 7762306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_4, int, a, struct bpf_testmod_struct_arg_2, b, int, c, int, ret) 7862306a36Sopenharmony_ci{ 7962306a36Sopenharmony_ci t2_ret = ret; 8062306a36Sopenharmony_ci return 0; 8162306a36Sopenharmony_ci} 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ciSEC("fentry/bpf_testmod_test_struct_arg_3") 8462306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_5, int, a, int, b, struct bpf_testmod_struct_arg_2, c) 8562306a36Sopenharmony_ci{ 8662306a36Sopenharmony_ci t3_a = a; 8762306a36Sopenharmony_ci t3_b = b; 8862306a36Sopenharmony_ci t3_c_a = c.a; 8962306a36Sopenharmony_ci t3_c_b = c.b; 9062306a36Sopenharmony_ci return 0; 9162306a36Sopenharmony_ci} 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ciSEC("fexit/bpf_testmod_test_struct_arg_3") 9462306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_6, int, a, int, b, struct bpf_testmod_struct_arg_2, c, int, ret) 9562306a36Sopenharmony_ci{ 9662306a36Sopenharmony_ci t3_ret = ret; 9762306a36Sopenharmony_ci return 0; 9862306a36Sopenharmony_ci} 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ciSEC("fentry/bpf_testmod_test_struct_arg_4") 10162306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_7, struct bpf_testmod_struct_arg_1, a, int, b, 10262306a36Sopenharmony_ci int, c, int, d, struct bpf_testmod_struct_arg_2, e) 10362306a36Sopenharmony_ci{ 10462306a36Sopenharmony_ci t4_a_a = a.a; 10562306a36Sopenharmony_ci t4_b = b; 10662306a36Sopenharmony_ci t4_c = c; 10762306a36Sopenharmony_ci t4_d = d; 10862306a36Sopenharmony_ci t4_e_a = e.a; 10962306a36Sopenharmony_ci t4_e_b = e.b; 11062306a36Sopenharmony_ci return 0; 11162306a36Sopenharmony_ci} 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ciSEC("fexit/bpf_testmod_test_struct_arg_4") 11462306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_8, struct bpf_testmod_struct_arg_1, a, int, b, 11562306a36Sopenharmony_ci int, c, int, d, struct bpf_testmod_struct_arg_2, e, int, ret) 11662306a36Sopenharmony_ci{ 11762306a36Sopenharmony_ci t4_ret = ret; 11862306a36Sopenharmony_ci return 0; 11962306a36Sopenharmony_ci} 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ciSEC("fentry/bpf_testmod_test_struct_arg_5") 12262306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_9) 12362306a36Sopenharmony_ci{ 12462306a36Sopenharmony_ci return 0; 12562306a36Sopenharmony_ci} 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ciSEC("fexit/bpf_testmod_test_struct_arg_5") 12862306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_10, int, ret) 12962306a36Sopenharmony_ci{ 13062306a36Sopenharmony_ci t5_ret = ret; 13162306a36Sopenharmony_ci return 0; 13262306a36Sopenharmony_ci} 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ciSEC("fentry/bpf_testmod_test_struct_arg_6") 13562306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_11, struct bpf_testmod_struct_arg_3 *, a) 13662306a36Sopenharmony_ci{ 13762306a36Sopenharmony_ci t6 = a->b[0]; 13862306a36Sopenharmony_ci return 0; 13962306a36Sopenharmony_ci} 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ciSEC("fentry/bpf_testmod_test_struct_arg_7") 14262306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_12, __u64, a, void *, b, short, c, int, d, 14362306a36Sopenharmony_ci void *, e, struct bpf_testmod_struct_arg_4, f) 14462306a36Sopenharmony_ci{ 14562306a36Sopenharmony_ci t7_a = a; 14662306a36Sopenharmony_ci t7_b = (long)b; 14762306a36Sopenharmony_ci t7_c = c; 14862306a36Sopenharmony_ci t7_d = d; 14962306a36Sopenharmony_ci t7_e = (long)e; 15062306a36Sopenharmony_ci t7_f_a = f.a; 15162306a36Sopenharmony_ci t7_f_b = f.b; 15262306a36Sopenharmony_ci return 0; 15362306a36Sopenharmony_ci} 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ciSEC("fexit/bpf_testmod_test_struct_arg_7") 15662306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_13, __u64, a, void *, b, short, c, int, d, 15762306a36Sopenharmony_ci void *, e, struct bpf_testmod_struct_arg_4, f, int, ret) 15862306a36Sopenharmony_ci{ 15962306a36Sopenharmony_ci t7_ret = ret; 16062306a36Sopenharmony_ci return 0; 16162306a36Sopenharmony_ci} 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ciSEC("fentry/bpf_testmod_test_struct_arg_8") 16462306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_14, __u64, a, void *, b, short, c, int, d, 16562306a36Sopenharmony_ci void *, e, struct bpf_testmod_struct_arg_4, f, int, g) 16662306a36Sopenharmony_ci{ 16762306a36Sopenharmony_ci t8_a = a; 16862306a36Sopenharmony_ci t8_b = (long)b; 16962306a36Sopenharmony_ci t8_c = c; 17062306a36Sopenharmony_ci t8_d = d; 17162306a36Sopenharmony_ci t8_e = (long)e; 17262306a36Sopenharmony_ci t8_f_a = f.a; 17362306a36Sopenharmony_ci t8_f_b = f.b; 17462306a36Sopenharmony_ci t8_g = g; 17562306a36Sopenharmony_ci return 0; 17662306a36Sopenharmony_ci} 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ciSEC("fexit/bpf_testmod_test_struct_arg_8") 17962306a36Sopenharmony_ciint BPF_PROG2(test_struct_arg_15, __u64, a, void *, b, short, c, int, d, 18062306a36Sopenharmony_ci void *, e, struct bpf_testmod_struct_arg_4, f, int, g, 18162306a36Sopenharmony_ci int, ret) 18262306a36Sopenharmony_ci{ 18362306a36Sopenharmony_ci t8_ret = ret; 18462306a36Sopenharmony_ci return 0; 18562306a36Sopenharmony_ci} 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_cichar _license[] SEC("license") = "GPL"; 188