Linux Audio

Check our new training course

Loading...
v6.13.7
  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
  8struct bpf_testmod_struct_arg_1 {
  9	int a;
 10};
 11struct bpf_testmod_struct_arg_2 {
 12	long a;
 13	long b;
 14};
 15
 16struct bpf_testmod_struct_arg_3 {
 17	int a;
 18	int b[];
 19};
 20
 21long t1_a_a, t1_a_b, t1_b, t1_c, t1_ret, t1_nregs;
 22__u64 t1_reg0, t1_reg1, t1_reg2, t1_reg3;
 23long t2_a, t2_b_a, t2_b_b, t2_c, t2_ret;
 24long t3_a, t3_b, t3_c_a, t3_c_b, t3_ret;
 25long t4_a_a, t4_b, t4_c, t4_d, t4_e_a, t4_e_b, t4_ret;
 26long t5_ret;
 27int t6;
 28
 29SEC("fentry/bpf_testmod_test_struct_arg_1")
 30int BPF_PROG2(test_struct_arg_1, struct bpf_testmod_struct_arg_2, a, int, b, int, c)
 31{
 32	t1_a_a = a.a;
 33	t1_a_b = a.b;
 34	t1_b = b;
 35	t1_c = c;
 36	return 0;
 37}
 38
 39SEC("fexit/bpf_testmod_test_struct_arg_1")
 40int BPF_PROG2(test_struct_arg_2, struct bpf_testmod_struct_arg_2, a, int, b, int, c, int, ret)
 41{
 42	t1_nregs =  bpf_get_func_arg_cnt(ctx);
 43	/* a.a */
 44	bpf_get_func_arg(ctx, 0, &t1_reg0);
 45	/* a.b */
 46	bpf_get_func_arg(ctx, 1, &t1_reg1);
 47	/* b */
 48	bpf_get_func_arg(ctx, 2, &t1_reg2);
 49	t1_reg2 = (int)t1_reg2;
 50	/* c */
 51	bpf_get_func_arg(ctx, 3, &t1_reg3);
 52	t1_reg3 = (int)t1_reg3;
 53
 54	t1_ret = ret;
 55	return 0;
 56}
 57
 58SEC("fentry/bpf_testmod_test_struct_arg_2")
 59int BPF_PROG2(test_struct_arg_3, int, a, struct bpf_testmod_struct_arg_2, b, int, c)
 60{
 61	t2_a = a;
 62	t2_b_a = b.a;
 63	t2_b_b = b.b;
 64	t2_c = c;
 65	return 0;
 66}
 67
 68SEC("fexit/bpf_testmod_test_struct_arg_2")
 69int BPF_PROG2(test_struct_arg_4, int, a, struct bpf_testmod_struct_arg_2, b, int, c, int, ret)
 70{
 71	t2_ret = ret;
 72	return 0;
 73}
 74
 75SEC("fentry/bpf_testmod_test_struct_arg_3")
 76int BPF_PROG2(test_struct_arg_5, int, a, int, b, struct bpf_testmod_struct_arg_2, c)
 77{
 78	t3_a = a;
 79	t3_b = b;
 80	t3_c_a = c.a;
 81	t3_c_b = c.b;
 82	return 0;
 83}
 84
 85SEC("fexit/bpf_testmod_test_struct_arg_3")
 86int BPF_PROG2(test_struct_arg_6, int, a, int, b, struct bpf_testmod_struct_arg_2, c, int, ret)
 87{
 88	t3_ret = ret;
 89	return 0;
 90}
 91
 92SEC("fentry/bpf_testmod_test_struct_arg_4")
 93int BPF_PROG2(test_struct_arg_7, struct bpf_testmod_struct_arg_1, a, int, b,
 94	     int, c, int, d, struct bpf_testmod_struct_arg_2, e)
 95{
 96	t4_a_a = a.a;
 97	t4_b = b;
 98	t4_c = c;
 99	t4_d = d;
100	t4_e_a = e.a;
101	t4_e_b = e.b;
102	return 0;
103}
104
105SEC("fexit/bpf_testmod_test_struct_arg_4")
106int BPF_PROG2(test_struct_arg_8, struct bpf_testmod_struct_arg_1, a, int, b,
107	     int, c, int, d, struct bpf_testmod_struct_arg_2, e, int, ret)
108{
109	t4_ret = ret;
110	return 0;
111}
112
113SEC("fentry/bpf_testmod_test_struct_arg_5")
114int BPF_PROG2(test_struct_arg_9)
115{
116	return 0;
117}
118
119SEC("fexit/bpf_testmod_test_struct_arg_5")
120int BPF_PROG2(test_struct_arg_10, int, ret)
121{
122	t5_ret = ret;
123	return 0;
124}
125
126SEC("fentry/bpf_testmod_test_struct_arg_6")
127int BPF_PROG2(test_struct_arg_11, struct bpf_testmod_struct_arg_3 *, a)
128{
129	t6 = a->b[0];
130	return 0;
131}
132
133char _license[] SEC("license") = "GPL";
v6.2
  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
  8struct bpf_testmod_struct_arg_1 {
  9	int a;
 10};
 11struct bpf_testmod_struct_arg_2 {
 12	long a;
 13	long b;
 14};
 15
 
 
 
 
 
 16long t1_a_a, t1_a_b, t1_b, t1_c, t1_ret, t1_nregs;
 17__u64 t1_reg0, t1_reg1, t1_reg2, t1_reg3;
 18long t2_a, t2_b_a, t2_b_b, t2_c, t2_ret;
 19long t3_a, t3_b, t3_c_a, t3_c_b, t3_ret;
 20long t4_a_a, t4_b, t4_c, t4_d, t4_e_a, t4_e_b, t4_ret;
 21long t5_ret;
 
 22
 23SEC("fentry/bpf_testmod_test_struct_arg_1")
 24int BPF_PROG2(test_struct_arg_1, struct bpf_testmod_struct_arg_2, a, int, b, int, c)
 25{
 26	t1_a_a = a.a;
 27	t1_a_b = a.b;
 28	t1_b = b;
 29	t1_c = c;
 30	return 0;
 31}
 32
 33SEC("fexit/bpf_testmod_test_struct_arg_1")
 34int BPF_PROG2(test_struct_arg_2, struct bpf_testmod_struct_arg_2, a, int, b, int, c, int, ret)
 35{
 36	t1_nregs =  bpf_get_func_arg_cnt(ctx);
 37	/* a.a */
 38	bpf_get_func_arg(ctx, 0, &t1_reg0);
 39	/* a.b */
 40	bpf_get_func_arg(ctx, 1, &t1_reg1);
 41	/* b */
 42	bpf_get_func_arg(ctx, 2, &t1_reg2);
 43	t1_reg2 = (int)t1_reg2;
 44	/* c */
 45	bpf_get_func_arg(ctx, 3, &t1_reg3);
 46	t1_reg3 = (int)t1_reg3;
 47
 48	t1_ret = ret;
 49	return 0;
 50}
 51
 52SEC("fentry/bpf_testmod_test_struct_arg_2")
 53int BPF_PROG2(test_struct_arg_3, int, a, struct bpf_testmod_struct_arg_2, b, int, c)
 54{
 55	t2_a = a;
 56	t2_b_a = b.a;
 57	t2_b_b = b.b;
 58	t2_c = c;
 59	return 0;
 60}
 61
 62SEC("fexit/bpf_testmod_test_struct_arg_2")
 63int BPF_PROG2(test_struct_arg_4, int, a, struct bpf_testmod_struct_arg_2, b, int, c, int, ret)
 64{
 65	t2_ret = ret;
 66	return 0;
 67}
 68
 69SEC("fentry/bpf_testmod_test_struct_arg_3")
 70int BPF_PROG2(test_struct_arg_5, int, a, int, b, struct bpf_testmod_struct_arg_2, c)
 71{
 72	t3_a = a;
 73	t3_b = b;
 74	t3_c_a = c.a;
 75	t3_c_b = c.b;
 76	return 0;
 77}
 78
 79SEC("fexit/bpf_testmod_test_struct_arg_3")
 80int BPF_PROG2(test_struct_arg_6, int, a, int, b, struct bpf_testmod_struct_arg_2, c, int, ret)
 81{
 82	t3_ret = ret;
 83	return 0;
 84}
 85
 86SEC("fentry/bpf_testmod_test_struct_arg_4")
 87int BPF_PROG2(test_struct_arg_7, struct bpf_testmod_struct_arg_1, a, int, b,
 88	     int, c, int, d, struct bpf_testmod_struct_arg_2, e)
 89{
 90	t4_a_a = a.a;
 91	t4_b = b;
 92	t4_c = c;
 93	t4_d = d;
 94	t4_e_a = e.a;
 95	t4_e_b = e.b;
 96	return 0;
 97}
 98
 99SEC("fexit/bpf_testmod_test_struct_arg_4")
100int BPF_PROG2(test_struct_arg_8, struct bpf_testmod_struct_arg_1, a, int, b,
101	     int, c, int, d, struct bpf_testmod_struct_arg_2, e, int, ret)
102{
103	t4_ret = ret;
104	return 0;
105}
106
107SEC("fentry/bpf_testmod_test_struct_arg_5")
108int BPF_PROG2(test_struct_arg_9)
109{
110	return 0;
111}
112
113SEC("fexit/bpf_testmod_test_struct_arg_5")
114int BPF_PROG2(test_struct_arg_10, int, ret)
115{
116	t5_ret = ret;
 
 
 
 
 
 
 
117	return 0;
118}
119
120char _license[] SEC("license") = "GPL";