]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - tools/testing/selftests/bpf/progs/test_task_pt_regs.c
1 // SPDX-License-Identifier: GPL-2.0
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
7 #define PT_REGS_SIZE sizeof(struct pt_regs)
10 * The kernel struct pt_regs isn't exported in its entirety to userspace.
11 * Pass it as an array to task_pt_regs.c
13 char current_regs
[PT_REGS_SIZE
] = {};
14 char ctx_regs
[PT_REGS_SIZE
] = {};
17 SEC("uprobe/trigger_func")
18 int handle_uprobe(struct pt_regs
*ctx
)
20 struct task_struct
*current
;
23 current
= bpf_get_current_task_btf();
24 regs
= (struct pt_regs
*) bpf_task_pt_regs(current
);
25 if (bpf_probe_read_kernel(current_regs
, PT_REGS_SIZE
, regs
))
27 if (bpf_probe_read_kernel(ctx_regs
, PT_REGS_SIZE
, ctx
))
30 /* Prove that uprobe was run */
36 char _license
[] SEC("license") = "GPL";