xref: /linux/tools/testing/selftests/bpf/progs/kprobe_write_ctx.c (revision 5ea5880764cbb164afb17a62e76ca75dc371409d)
1 // SPDX-License-Identifier: GPL-2.0
2 #include "vmlinux.h"
3 #include <bpf/bpf_helpers.h>
4 #include <bpf/bpf_tracing.h>
5 
6 char _license[] SEC("license") = "GPL";
7 
8 #if defined(__TARGET_ARCH_x86)
9 SEC("kprobe")
10 int kprobe_write_ctx(struct pt_regs *ctx)
11 {
12 	ctx->ax = 0;
13 	return 0;
14 }
15 
16 SEC("kprobe.multi")
17 int kprobe_multi_write_ctx(struct pt_regs *ctx)
18 {
19 	ctx->ax = 0;
20 	return 0;
21 }
22 
23 SEC("?kprobe")
24 int kprobe_dummy(struct pt_regs *regs)
25 {
26 	return 0;
27 }
28 
29 SEC("?freplace")
30 int freplace_kprobe(struct pt_regs *regs)
31 {
32 	regs->di = 0;
33 	return 0;
34 }
35 
36 SEC("?fentry/bpf_fentry_test1")
37 int BPF_PROG(fentry)
38 {
39 	return 0;
40 }
41 #endif
42