1 // SPDX-License-Identifier: GPL-2.0
3 #include <bpf/bpf_helpers.h>
4 #include <bpf/bpf_tracing.h>
6 char _license[] SEC("license") = "GPL";
8 extern const void bpf_fentry_test1 __ksym;
9 extern const void bpf_fentry_test2 __ksym;
10 extern const void bpf_fentry_test3 __ksym;
11 extern const void bpf_fentry_test4 __ksym;
12 extern const void bpf_modify_return_test __ksym;
13 extern const void bpf_fentry_test6 __ksym;
14 extern const void bpf_fentry_test7 __ksym;
16 extern bool CONFIG_X86_KERNEL_IBT __kconfig __weak;
18 /* This function is here to have CONFIG_X86_KERNEL_IBT
19 * used and added to object BTF.
23 return CONFIG_X86_KERNEL_IBT ? 0 : 1;
26 __u64 test1_result = 0;
27 SEC("fentry/bpf_fentry_test1")
28 int BPF_PROG(test1, int a)
30 __u64 addr = bpf_get_func_ip(ctx);
32 test1_result = (const void *) addr == &bpf_fentry_test1;
36 __u64 test2_result = 0;
37 SEC("fexit/bpf_fentry_test2")
38 int BPF_PROG(test2, int a)
40 __u64 addr = bpf_get_func_ip(ctx);
42 test2_result = (const void *) addr == &bpf_fentry_test2;
46 __u64 test3_result = 0;
47 SEC("kprobe/bpf_fentry_test3")
48 int test3(struct pt_regs *ctx)
50 __u64 addr = bpf_get_func_ip(ctx);
52 test3_result = (const void *) addr == &bpf_fentry_test3;
56 __u64 test4_result = 0;
57 SEC("kretprobe/bpf_fentry_test4")
58 int BPF_KRETPROBE(test4)
60 __u64 addr = bpf_get_func_ip(ctx);
62 test4_result = (const void *) addr == &bpf_fentry_test4;
66 __u64 test5_result = 0;
67 SEC("fmod_ret/bpf_modify_return_test")
68 int BPF_PROG(test5, int a, int *b, int ret)
70 __u64 addr = bpf_get_func_ip(ctx);
72 test5_result = (const void *) addr == &bpf_modify_return_test;
76 __u64 test6_result = 0;
78 int test6(struct pt_regs *ctx)
80 __u64 addr = bpf_get_func_ip(ctx);
82 test6_result = (const void *) addr == 0;
86 unsigned long uprobe_trigger;
88 __u64 test7_result = 0;
89 SEC("uprobe//proc/self/exe:uprobe_trigger")
92 __u64 addr = bpf_get_func_ip(ctx);
94 test7_result = (const void *) addr == (const void *) uprobe_trigger;
98 __u64 test8_result = 0;
99 SEC("uretprobe//proc/self/exe:uprobe_trigger")
100 int BPF_URETPROBE(test8, int ret)
102 __u64 addr = bpf_get_func_ip(ctx);
104 test8_result = (const void *) addr == (const void *) uprobe_trigger;