xref: /linux/tools/testing/selftests/bpf/progs/trace_dummy_st_ops.c (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bpf.h>
3 #include <bpf/bpf_helpers.h>
4 #include <bpf/bpf_tracing.h>
5 
6 int val = 0;
7 
8 SEC("fentry/test_1")
9 int BPF_PROG(fentry_test_1, __u64 *st_ops_ctx)
10 {
11 	__u64 state;
12 
13 	/* Read the traced st_ops arg1 which is a pointer */
14 	bpf_probe_read_kernel(&state, sizeof(__u64), (void *)st_ops_ctx);
15 	/* Read state->val */
16 	bpf_probe_read_kernel(&val, sizeof(__u32), (void *)state);
17 
18 	return 0;
19 }
20 
21 char _license[] SEC("license") = "GPL";
22