summaryrefslogtreecommitdiff
path: root/tools/lib/bpf/bpf_tracing.h
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2022-02-09 05:17:37 +0300
committerAndrii Nakryiko <andrii@kernel.org>2022-02-09 08:16:14 +0300
commitc5a1ffa0da76da02afc20a0946b594830488b324 (patch)
tree92f410beeca2af25708edf40a41051fb2c0031d3 /tools/lib/bpf/bpf_tracing.h
parent4fc49b51ab9d58e830f9df37ea775625ea966d50 (diff)
downloadlinux-c5a1ffa0da76da02afc20a0946b594830488b324.tar.xz
libbpf: Add PT_REGS_SYSCALL_REGS macro
Architectures that select ARCH_HAS_SYSCALL_WRAPPER pass a pointer to struct pt_regs to syscall handlers, others unpack it into individual function parameters. Introduce a macro to describe what a particular arch does. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220209021745.2215452-3-iii@linux.ibm.com
Diffstat (limited to 'tools/lib/bpf/bpf_tracing.h')
-rw-r--r--tools/lib/bpf/bpf_tracing.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 032ba809f3e5..a5e92656bfba 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -326,6 +326,16 @@ struct pt_regs;
#endif /* defined(bpf_target_defined) */
+/*
+ * When invoked from a syscall handler kprobe, returns a pointer to a
+ * struct pt_regs containing syscall arguments and suitable for passing to
+ * PT_REGS_PARMn_SYSCALL() and PT_REGS_PARMn_CORE_SYSCALL().
+ */
+#ifndef PT_REGS_SYSCALL_REGS
+/* By default, assume that the arch selects ARCH_HAS_SYSCALL_WRAPPER. */
+#define PT_REGS_SYSCALL_REGS(ctx) ((struct pt_regs *)PT_REGS_PARM1(ctx))
+#endif
+
#ifndef ___bpf_concat
#define ___bpf_concat(a, b) a ## b
#endif