xref: /linux/tools/testing/selftests/bpf/progs/tracing_struct_int128.c (revision b68782116bfdcdd05949a662c14d5fa644d10ab8)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
3 #include <vmlinux.h>
4 #include <bpf/bpf_tracing.h>
5 #include <bpf/bpf_helpers.h>
6 
7 long t_b, t_c, t_ret;
8 
9 SEC("fexit/bpf_testmod_test_int128_arg")
10 int test_int128_arg_fexit(unsigned long long *ctx)
11 {
12 	t_b = (int)ctx[2];
13 	t_c = (long)ctx[3];
14 	t_ret = (long)ctx[4];
15 	return 0;
16 }
17 
18 /*
19  * The arguments come packed in the BPF convention whatever holes the
20  * kernel convention left between them: an eightbyte each, and two for the
21  * struct holding an __int128.
22  */
23 long s_g, s_h_lo, s_h_hi, s_i, s_ret;
24 
25 SEC("fentry/bpf_testmod_test_int128_stack")
26 int test_int128_stack_fentry(unsigned long long *ctx)
27 {
28 	s_g = ctx[6];
29 	s_h_lo = ctx[7];
30 	s_h_hi = ctx[8];
31 	s_i = ctx[9];
32 	return 0;
33 }
34 
35 SEC("fexit/bpf_testmod_test_int128_stack")
36 int test_int128_stack_fexit(unsigned long long *ctx)
37 {
38 	s_ret = ctx[10];
39 	return 0;
40 }
41 
42 long b_f_a, b_f_b, b_g, b_h, b_i_lo, b_i_hi, b_ret;
43 
44 SEC("fentry/bpf_testmod_test_int128_backfill")
45 int test_int128_backfill_fentry(unsigned long long *ctx)
46 {
47 	b_f_a = ctx[5];
48 	b_f_b = ctx[6];
49 	b_g = ctx[7];
50 	b_h = ctx[8];
51 	b_i_lo = ctx[9];
52 	b_i_hi = ctx[10];
53 	return 0;
54 }
55 
56 SEC("fexit/bpf_testmod_test_int128_backfill")
57 int test_int128_backfill_fexit(unsigned long long *ctx)
58 {
59 	b_ret = ctx[11];
60 	return 0;
61 }
62 
63 char _license[] SEC("license") = "GPL";
64