* [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support
@ 2023-01-20 20:08 Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 01/25] libbpf: add support for fetching up to 8 arguments in kprobes Andrii Nakryiko
` (25 more replies)
0 siblings, 26 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
This patch set fixes and extends libbpf's bpf_tracing.h support for tracing
arguments of kprobes/uprobes, and syscall as a special case.
Depending on the architecture, anywhere between 3 and 8 arguments can be
passed to a function in registers (so relevant to kprobes and uprobes), but
before this patch set libbpf's macros in bpf_tracing.h only supported up to
5 arguments, which is limiting in practice. This patch set extends
bpf_tracing.h to support up to 8 arguments, if architecture allows. This
includes explicit PT_REGS_PARMx() macro family, as well as BPF_KPROBE() macro.
Now, with tracing syscall arguments situation is sometimes quite different.
For a lot of architectures syscall argument passing through registers differs
from function call sequence at least a little. For i386 it differs *a lot*.
This patch set addresses this issue across all currently supported
architectures and hopefully fixes existing issues. syscall(2) manpage defines
that either 6 or 7 arguments can be supported, depending on architecture, so
libbpf defines 6 or 7 registers per architecture to be used to fetch syscall
arguments.
Also, BPF_UPROBE and BPF_URETPROBE are introduced as part of this patch set.
They are aliases for BPF_KPROBE and BPF_KRETPROBE (as mechanics of argument
fetching of kernel functions and user-space functions are identical), but it
allows BPF users to have less confusing BPF-side code when working with
uprobes.
For both sets of changes selftests are extended to test these new register
definitions to architecture-defined limits. Unfortunately I don't have ability
to test it on all architectures, and BPF CI only tests 3 architecture (x86-64,
arm64, and s390x), so it would be greatly appreciated if people with access to
architectures other than above 3 helped review and test changes.
v1->v2:
- switched from mmap() to splice() syscall (Ilya);
- updated ABI spec link for s390x (Ilya);
- added a bunch of Tested-by and acks tags, thank you;
- dropped direct CCs because vger/patchworks blocked v1 patches, probably
due to too long CC list.
Andrii Nakryiko (25):
libbpf: add support for fetching up to 8 arguments in kprobes
libbpf: add 6th argument support for x86-64 in bpf_tracing.h
libbpf: fix arm and arm64 specs in bpf_tracing.h
libbpf: complete mips spec in bpf_tracing.h
libbpf: complete powerpc spec in bpf_tracing.h
libbpf: complete sparc spec in bpf_tracing.h
libbpf: complete riscv arch spec in bpf_tracing.h
libbpf: fix and complete ARC spec in bpf_tracing.h
libbpf: complete LoongArch (loongarch) spec in bpf_tracing.h
libbpf: add BPF_UPROBE and BPF_URETPROBE macro aliases
selftests/bpf: validate arch-specific argument registers limits
libbpf: improve syscall tracing support in bpf_tracing.h
libbpf: define x86-64 syscall regs spec in bpf_tracing.h
libbpf: define i386 syscall regs spec in bpf_tracing.h
libbpf: define s390x syscall regs spec in bpf_tracing.h
libbpf: define arm syscall regs spec in bpf_tracing.h
libbpf: define arm64 syscall regs spec in bpf_tracing.h
libbpf: define mips syscall regs spec in bpf_tracing.h
libbpf: define powerpc syscall regs spec in bpf_tracing.h
libbpf: define sparc syscall regs spec in bpf_tracing.h
libbpf: define riscv syscall regs spec in bpf_tracing.h
libbpf: define arc syscall regs spec in bpf_tracing.h
libbpf: define loongarch syscall regs spec in bpf_tracing.h
selftests/bpf: add 6-argument syscall tracing test
libbpf: clean up now not needed __PT_PARM{1-6}_SYSCALL_REG defaults
tools/lib/bpf/bpf_tracing.h | 303 +++++++++++++++---
.../bpf/prog_tests/test_bpf_syscall_macro.c | 17 +
.../bpf/prog_tests/uprobe_autoattach.c | 33 +-
tools/testing/selftests/bpf/progs/bpf_misc.h | 25 ++
.../selftests/bpf/progs/bpf_syscall_macro.c | 26 ++
.../bpf/progs/test_uprobe_autoattach.c | 48 ++-
6 files changed, 407 insertions(+), 45 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 01/25] libbpf: add support for fetching up to 8 arguments in kprobes
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 02/25] libbpf: add 6th argument support for x86-64 in bpf_tracing.h Andrii Nakryiko
` (24 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Alan Maguire, Ilya Leoshkevich
Add BPF_KPROBE() and PT_REGS_PARMx() support for up to 8 arguments, if
target architecture supports this. Currently all architectures are
limited to only 5 register-placed arguments, which is limiting even on
x86-64.
This patch adds generic macro machinery to support up to 8 arguments
both when explicitly fetching it from pt_regs through PT_REGS_PARMx()
macros, as well as more ergonomic access in BPF_KPROBE().
Also, for i386 architecture we now don't have to define fake PARM4 and
PARM5 definitions, they will be generically substituted, just like for
PARM6 through PARM8.
Subsequent patches will fill out architecture-specific definitions,
where appropriate.
Tested-by: Alan Maguire <alan.maguire@oracle.com> # arm64
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> # s390x
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 41 +++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index bdb0f6b5be84..ef17d8fdd9d6 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -98,12 +98,10 @@
#ifdef __i386__
+/* i386 kernel is built with -mregparm=3 */
#define __PT_PARM1_REG eax
#define __PT_PARM2_REG edx
#define __PT_PARM3_REG ecx
-/* i386 kernel is built with -mregparm=3 */
-#define __PT_PARM4_REG __unsupported__
-#define __PT_PARM5_REG __unsupported__
#define __PT_RET_REG esp
#define __PT_FP_REG ebp
#define __PT_RC_REG eax
@@ -287,16 +285,39 @@ struct pt_regs___arm64 {
struct pt_regs;
-/* allow some architecutres to override `struct pt_regs` */
+/* allow some architectures to override `struct pt_regs` */
#ifndef __PT_REGS_CAST
#define __PT_REGS_CAST(x) (x)
#endif
+/*
+ * Different architectures support different number of arguments passed
+ * through registers. i386 supports just 3, some arches support up to 8.
+ */
+#ifndef __PT_PARM4_REG
+#define __PT_PARM4_REG __unsupported__
+#endif
+#ifndef __PT_PARM5_REG
+#define __PT_PARM5_REG __unsupported__
+#endif
+#ifndef __PT_PARM6_REG
+#define __PT_PARM6_REG __unsupported__
+#endif
+#ifndef __PT_PARM7_REG
+#define __PT_PARM7_REG __unsupported__
+#endif
+#ifndef __PT_PARM8_REG
+#define __PT_PARM8_REG __unsupported__
+#endif
+
#define PT_REGS_PARM1(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG)
#define PT_REGS_PARM2(x) (__PT_REGS_CAST(x)->__PT_PARM2_REG)
#define PT_REGS_PARM3(x) (__PT_REGS_CAST(x)->__PT_PARM3_REG)
#define PT_REGS_PARM4(x) (__PT_REGS_CAST(x)->__PT_PARM4_REG)
#define PT_REGS_PARM5(x) (__PT_REGS_CAST(x)->__PT_PARM5_REG)
+#define PT_REGS_PARM6(x) (__PT_REGS_CAST(x)->__PT_PARM6_REG)
+#define PT_REGS_PARM7(x) (__PT_REGS_CAST(x)->__PT_PARM7_REG)
+#define PT_REGS_PARM8(x) (__PT_REGS_CAST(x)->__PT_PARM8_REG)
#define PT_REGS_RET(x) (__PT_REGS_CAST(x)->__PT_RET_REG)
#define PT_REGS_FP(x) (__PT_REGS_CAST(x)->__PT_FP_REG)
#define PT_REGS_RC(x) (__PT_REGS_CAST(x)->__PT_RC_REG)
@@ -308,6 +329,9 @@ struct pt_regs;
#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM3_REG)
#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM4_REG)
#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM5_REG)
+#define PT_REGS_PARM6_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM6_REG)
+#define PT_REGS_PARM7_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM7_REG)
+#define PT_REGS_PARM8_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM8_REG)
#define PT_REGS_RET_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_RET_REG)
#define PT_REGS_FP_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_FP_REG)
#define PT_REGS_RC_CORE(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_RC_REG)
@@ -360,6 +384,9 @@ struct pt_regs;
#define PT_REGS_PARM3(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM4(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM5(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM6(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM7(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM8(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_RET(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_FP(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_RC(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
@@ -371,6 +398,9 @@ struct pt_regs;
#define PT_REGS_PARM3_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM4_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM5_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM6_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM7_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM8_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_RET_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_FP_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_RC_CORE(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
@@ -576,6 +606,9 @@ struct pt_regs;
#define ___bpf_kprobe_args3(x, args...) ___bpf_kprobe_args2(args), (void *)PT_REGS_PARM3(ctx)
#define ___bpf_kprobe_args4(x, args...) ___bpf_kprobe_args3(args), (void *)PT_REGS_PARM4(ctx)
#define ___bpf_kprobe_args5(x, args...) ___bpf_kprobe_args4(args), (void *)PT_REGS_PARM5(ctx)
+#define ___bpf_kprobe_args6(x, args...) ___bpf_kprobe_args5(args), (void *)PT_REGS_PARM6(ctx)
+#define ___bpf_kprobe_args7(x, args...) ___bpf_kprobe_args6(args), (void *)PT_REGS_PARM7(ctx)
+#define ___bpf_kprobe_args8(x, args...) ___bpf_kprobe_args7(args), (void *)PT_REGS_PARM8(ctx)
#define ___bpf_kprobe_args(args...) ___bpf_apply(___bpf_kprobe_args, ___bpf_narg(args))(args)
/*
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 02/25] libbpf: add 6th argument support for x86-64 in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 01/25] libbpf: add support for fetching up to 8 arguments in kprobes Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 03/25] libbpf: fix arm and arm64 specs " Andrii Nakryiko
` (23 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Add r9 as register containing 6th argument on x86-64 architecture, as
per its ABI. Add also a link to a page describing ABI for easier future
reference.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index ef17d8fdd9d6..a47504c2f3cb 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -78,6 +78,10 @@
#if defined(bpf_target_x86)
+/*
+ * https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI
+ */
+
#if defined(__KERNEL__) || defined(__VMLINUX_H__)
#define __PT_PARM1_REG di
@@ -85,6 +89,7 @@
#define __PT_PARM3_REG dx
#define __PT_PARM4_REG cx
#define __PT_PARM5_REG r8
+#define __PT_PARM6_REG r9
#define __PT_RET_REG sp
#define __PT_FP_REG bp
#define __PT_RC_REG ax
@@ -115,6 +120,7 @@
#define __PT_PARM3_REG rdx
#define __PT_PARM4_REG rcx
#define __PT_PARM5_REG r8
+#define __PT_PARM6_REG r9
#define __PT_RET_REG rsp
#define __PT_FP_REG rbp
#define __PT_RC_REG rax
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 03/25] libbpf: fix arm and arm64 specs in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 01/25] libbpf: add support for fetching up to 8 arguments in kprobes Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 02/25] libbpf: add 6th argument support for x86-64 in bpf_tracing.h Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 04/25] libbpf: complete mips spec " Andrii Nakryiko
` (22 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Alan Maguire
Remove invalid support for PARM5 on 32-bit arm, as per ABI. Add three
more argument registers for arm64. Also leave links to ABI specs for
future reference.
Tested-by: Alan Maguire <alan.maguire@oracle.com> # arm64
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index a47504c2f3cb..a263f600e309 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -157,11 +157,14 @@ struct pt_regs___s390 {
#elif defined(bpf_target_arm)
+/*
+ * https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#machine-registers
+ */
+
#define __PT_PARM1_REG uregs[0]
#define __PT_PARM2_REG uregs[1]
#define __PT_PARM3_REG uregs[2]
#define __PT_PARM4_REG uregs[3]
-#define __PT_PARM5_REG uregs[4]
#define __PT_RET_REG uregs[14]
#define __PT_FP_REG uregs[11] /* Works only with CONFIG_FRAME_POINTER */
#define __PT_RC_REG uregs[0]
@@ -170,6 +173,10 @@ struct pt_regs___s390 {
#elif defined(bpf_target_arm64)
+/*
+ * https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#machine-registers
+ */
+
struct pt_regs___arm64 {
unsigned long orig_x0;
};
@@ -181,6 +188,9 @@ struct pt_regs___arm64 {
#define __PT_PARM3_REG regs[2]
#define __PT_PARM4_REG regs[3]
#define __PT_PARM5_REG regs[4]
+#define __PT_PARM6_REG regs[5]
+#define __PT_PARM7_REG regs[6]
+#define __PT_PARM8_REG regs[7]
#define __PT_RET_REG regs[30]
#define __PT_FP_REG regs[29] /* Works only with CONFIG_FRAME_POINTER */
#define __PT_RC_REG regs[0]
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 04/25] libbpf: complete mips spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (2 preceding siblings ...)
2023-01-20 20:08 ` [PATCH v2 bpf-next 03/25] libbpf: fix arm and arm64 specs " Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 05/25] libbpf: complete powerpc " Andrii Nakryiko
` (21 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Add registers for PARM6 through PARM8. Add a link to an ABI. We don't
distinguish between O32, N32, and N64, so document that we assume N64
right now.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index a263f600e309..f356955b059a 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -201,11 +201,19 @@ struct pt_regs___arm64 {
#elif defined(bpf_target_mips)
+/*
+ * N64 ABI is assumed right now.
+ * https://en.wikipedia.org/wiki/MIPS_architecture#Calling_conventions
+ */
+
#define __PT_PARM1_REG regs[4]
#define __PT_PARM2_REG regs[5]
#define __PT_PARM3_REG regs[6]
#define __PT_PARM4_REG regs[7]
#define __PT_PARM5_REG regs[8]
+#define __PT_PARM6_REG regs[9]
+#define __PT_PARM7_REG regs[10]
+#define __PT_PARM8_REG regs[11]
#define __PT_RET_REG regs[31]
#define __PT_FP_REG regs[30] /* Works only with CONFIG_FRAME_POINTER */
#define __PT_RC_REG regs[2]
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 05/25] libbpf: complete powerpc spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (3 preceding siblings ...)
2023-01-20 20:08 ` [PATCH v2 bpf-next 04/25] libbpf: complete mips spec " Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 06/25] libbpf: complete sparc " Andrii Nakryiko
` (20 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Add definitions of PARM6 through PARM8 for powerpc architecture. Add
also a link to a functiona call sequence documentation for future reference.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index f356955b059a..1b9447f847b0 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -222,11 +222,19 @@ struct pt_regs___arm64 {
#elif defined(bpf_target_powerpc)
+/*
+ * http://refspecs.linux-foundation.org/elf/elfspec_ppc.pdf (page 3-14,
+ * section "Function Calling Sequence")
+ */
+
#define __PT_PARM1_REG gpr[3]
#define __PT_PARM2_REG gpr[4]
#define __PT_PARM3_REG gpr[5]
#define __PT_PARM4_REG gpr[6]
#define __PT_PARM5_REG gpr[7]
+#define __PT_PARM6_REG gpr[8]
+#define __PT_PARM7_REG gpr[9]
+#define __PT_PARM8_REG gpr[10]
#define __PT_RET_REG regs[31]
#define __PT_FP_REG __unsupported__
#define __PT_RC_REG gpr[3]
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 06/25] libbpf: complete sparc spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (4 preceding siblings ...)
2023-01-20 20:08 ` [PATCH v2 bpf-next 05/25] libbpf: complete powerpc " Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 07/25] libbpf: complete riscv arch " Andrii Nakryiko
` (19 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Add PARM6 definition for sparc architecture. Leave a link to calling
convention documentation.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 1b9447f847b0..0f9640ddbe1c 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -245,11 +245,16 @@ struct pt_regs___arm64 {
#elif defined(bpf_target_sparc)
+/*
+ * https://en.wikipedia.org/wiki/Calling_convention#SPARC
+ */
+
#define __PT_PARM1_REG u_regs[UREG_I0]
#define __PT_PARM2_REG u_regs[UREG_I1]
#define __PT_PARM3_REG u_regs[UREG_I2]
#define __PT_PARM4_REG u_regs[UREG_I3]
#define __PT_PARM5_REG u_regs[UREG_I4]
+#define __PT_PARM6_REG u_regs[UREG_I5]
#define __PT_RET_REG u_regs[UREG_I7]
#define __PT_FP_REG __unsupported__
#define __PT_RC_REG u_regs[UREG_I0]
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 07/25] libbpf: complete riscv arch spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (5 preceding siblings ...)
2023-01-20 20:08 ` [PATCH v2 bpf-next 06/25] libbpf: complete sparc " Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 08/25] libbpf: fix and complete ARC " Andrii Nakryiko
` (18 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Pu Lehui
Add PARM6 through PARM8 definitions for RISC V (riscv) arch. Leave the
link for ABI doc for future reference.
Tested-by: Pu Lehui <pulehui@huawei.com> # RISC-V
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 0f9640ddbe1c..579e2f830532 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -268,12 +268,19 @@ struct pt_regs___arm64 {
#elif defined(bpf_target_riscv)
+/*
+ * https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#risc-v-calling-conventions
+ */
+
#define __PT_REGS_CAST(x) ((const struct user_regs_struct *)(x))
#define __PT_PARM1_REG a0
#define __PT_PARM2_REG a1
#define __PT_PARM3_REG a2
#define __PT_PARM4_REG a3
#define __PT_PARM5_REG a4
+#define __PT_PARM6_REG a5
+#define __PT_PARM7_REG a6
+#define __PT_PARM8_REG a7
#define __PT_RET_REG ra
#define __PT_FP_REG s0
#define __PT_RC_REG a0
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 08/25] libbpf: fix and complete ARC spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (6 preceding siblings ...)
2023-01-20 20:08 ` [PATCH v2 bpf-next 07/25] libbpf: complete riscv arch " Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 09/25] libbpf: complete LoongArch (loongarch) " Andrii Nakryiko
` (17 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Add PARM6 through PARM8 definitions. Also fix frame pointer (FP)
register definition. Also leave a link to where to find ABI spec.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 579e2f830532..815c50ccedf4 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -291,6 +291,11 @@ struct pt_regs___arm64 {
#elif defined(bpf_target_arc)
+/*
+ * Section "Function Calling Sequence" (page 24):
+ * https://raw.githubusercontent.com/wiki/foss-for-synopsys-dwc-arc-processors/toolchain/files/ARCv2_ABI.pdf
+ */
+
/* arc provides struct user_pt_regs instead of struct pt_regs to userspace */
#define __PT_REGS_CAST(x) ((const struct user_regs_struct *)(x))
#define __PT_PARM1_REG scratch.r0
@@ -298,8 +303,11 @@ struct pt_regs___arm64 {
#define __PT_PARM3_REG scratch.r2
#define __PT_PARM4_REG scratch.r3
#define __PT_PARM5_REG scratch.r4
+#define __PT_PARM6_REG scratch.r5
+#define __PT_PARM7_REG scratch.r6
+#define __PT_PARM8_REG scratch.r7
#define __PT_RET_REG scratch.blink
-#define __PT_FP_REG __unsupported__
+#define __PT_FP_REG scratch.fp
#define __PT_RC_REG scratch.r0
#define __PT_SP_REG scratch.sp
#define __PT_IP_REG scratch.ret
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 09/25] libbpf: complete LoongArch (loongarch) spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (7 preceding siblings ...)
2023-01-20 20:08 ` [PATCH v2 bpf-next 08/25] libbpf: fix and complete ARC " Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 10/25] libbpf: add BPF_UPROBE and BPF_URETPROBE macro aliases Andrii Nakryiko
` (16 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Add PARM6 through PARM8 definitions. Add kernel docs link describing ABI
for LoongArch.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 815c50ccedf4..510df96ff19d 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -316,13 +316,19 @@ struct pt_regs___arm64 {
#elif defined(bpf_target_loongarch)
-/* https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html */
+/*
+ * https://docs.kernel.org/loongarch/introduction.html
+ * https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
+ */
#define __PT_PARM1_REG regs[4]
#define __PT_PARM2_REG regs[5]
#define __PT_PARM3_REG regs[6]
#define __PT_PARM4_REG regs[7]
#define __PT_PARM5_REG regs[8]
+#define __PT_PARM6_REG regs[9]
+#define __PT_PARM7_REG regs[10]
+#define __PT_PARM8_REG regs[11]
#define __PT_RET_REG regs[1]
#define __PT_FP_REG regs[22]
#define __PT_RC_REG regs[4]
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 10/25] libbpf: add BPF_UPROBE and BPF_URETPROBE macro aliases
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (8 preceding siblings ...)
2023-01-20 20:08 ` [PATCH v2 bpf-next 09/25] libbpf: complete LoongArch (loongarch) " Andrii Nakryiko
@ 2023-01-20 20:08 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 11/25] selftests/bpf: validate arch-specific argument registers limits Andrii Nakryiko
` (15 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:08 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Add BPF_UPROBE and BPF_URETPROBE macros, aliased to BPF_KPROBE and
BPF_KRETPROBE, respectively. This makes uprobe-based BPF program code
much less confusing, especially to people new to tracing, at no cost in
terms of maintainability. We'll use this macro in selftests in
subsequent patch.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 510df96ff19d..9c4246fe8799 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -781,4 +781,11 @@ ____##name(struct pt_regs *ctx, ##args)
#define BPF_KPROBE_SYSCALL BPF_KSYSCALL
+/* BPF_UPROBE and BPF_URETPROBE are identical to BPF_KPROBE and BPF_KRETPROBE,
+ * but are named way less confusingly for SEC("uprobe") and SEC("uretprobe")
+ * use cases.
+ */
+#define BPF_UPROBE(name, args...) BPF_KPROBE(name, ##args)
+#define BPF_URETPROBE(name, args...) BPF_KRETPROBE(name, ##args)
+
#endif
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 11/25] selftests/bpf: validate arch-specific argument registers limits
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (9 preceding siblings ...)
2023-01-20 20:08 ` [PATCH v2 bpf-next 10/25] libbpf: add BPF_UPROBE and BPF_URETPROBE macro aliases Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 12/25] libbpf: improve syscall tracing support in bpf_tracing.h Andrii Nakryiko
` (14 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Alan Maguire, Ilya Leoshkevich
Update uprobe_autoattach selftest to validate architecture-specific
argument passing through registers. Use new BPF_UPROBE and
BPF_URETPROBE, and construct both BPF-side and user-space side in such
a way that for different architectures we are fetching and checking
different number of arguments, matching architecture-specific limit of
how many registers are available for argument passing.
Tested-by: Alan Maguire <alan.maguire@oracle.com> # arm64
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> # s390x
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
.../bpf/prog_tests/uprobe_autoattach.c | 33 +++++++++++--
tools/testing/selftests/bpf/progs/bpf_misc.h | 25 ++++++++++
.../bpf/progs/test_uprobe_autoattach.c | 48 ++++++++++++++++++-
3 files changed, 99 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c b/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c
index 35b87c7ba5be..82807def0d24 100644
--- a/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c
+++ b/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c
@@ -3,18 +3,21 @@
#include <test_progs.h>
#include "test_uprobe_autoattach.skel.h"
+#include "progs/bpf_misc.h"
/* uprobe attach point */
-static noinline int autoattach_trigger_func(int arg)
+static noinline int autoattach_trigger_func(int arg1, int arg2, int arg3,
+ int arg4, int arg5, int arg6,
+ int arg7, int arg8)
{
asm volatile ("");
- return arg + 1;
+ return arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + 1;
}
void test_uprobe_autoattach(void)
{
struct test_uprobe_autoattach *skel;
- int trigger_val = 100, trigger_ret;
+ int trigger_ret;
size_t malloc_sz = 1;
char *mem;
@@ -28,22 +31,42 @@ void test_uprobe_autoattach(void)
skel->bss->test_pid = getpid();
/* trigger & validate uprobe & uretprobe */
- trigger_ret = autoattach_trigger_func(trigger_val);
+ trigger_ret = autoattach_trigger_func(1, 2, 3, 4, 5, 6, 7, 8);
skel->bss->test_pid = getpid();
/* trigger & validate shared library u[ret]probes attached by name */
mem = malloc(malloc_sz);
- ASSERT_EQ(skel->bss->uprobe_byname_parm1, trigger_val, "check_uprobe_byname_parm1");
+ ASSERT_EQ(skel->bss->uprobe_byname_parm1, 1, "check_uprobe_byname_parm1");
ASSERT_EQ(skel->bss->uprobe_byname_ran, 1, "check_uprobe_byname_ran");
ASSERT_EQ(skel->bss->uretprobe_byname_rc, trigger_ret, "check_uretprobe_byname_rc");
+ ASSERT_EQ(skel->bss->uretprobe_byname_ret, trigger_ret, "check_uretprobe_byname_ret");
ASSERT_EQ(skel->bss->uretprobe_byname_ran, 2, "check_uretprobe_byname_ran");
ASSERT_EQ(skel->bss->uprobe_byname2_parm1, malloc_sz, "check_uprobe_byname2_parm1");
ASSERT_EQ(skel->bss->uprobe_byname2_ran, 3, "check_uprobe_byname2_ran");
ASSERT_EQ(skel->bss->uretprobe_byname2_rc, mem, "check_uretprobe_byname2_rc");
ASSERT_EQ(skel->bss->uretprobe_byname2_ran, 4, "check_uretprobe_byname2_ran");
+ ASSERT_EQ(skel->bss->a[0], 1, "arg1");
+ ASSERT_EQ(skel->bss->a[1], 2, "arg2");
+ ASSERT_EQ(skel->bss->a[2], 3, "arg3");
+#if FUNC_REG_ARG_CNT > 3
+ ASSERT_EQ(skel->bss->a[3], 4, "arg4");
+#endif
+#if FUNC_REG_ARG_CNT > 4
+ ASSERT_EQ(skel->bss->a[4], 5, "arg5");
+#endif
+#if FUNC_REG_ARG_CNT > 5
+ ASSERT_EQ(skel->bss->a[5], 6, "arg6");
+#endif
+#if FUNC_REG_ARG_CNT > 6
+ ASSERT_EQ(skel->bss->a[6], 7, "arg7");
+#endif
+#if FUNC_REG_ARG_CNT > 7
+ ASSERT_EQ(skel->bss->a[7], 8, "arg8");
+#endif
+
free(mem);
cleanup:
test_uprobe_autoattach__destroy(skel);
diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
index 4a01ea9113bf..ecce51404f57 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -21,4 +21,29 @@
#define SYS_PREFIX "__se_"
#endif
+/* How many arguments are passed to function in register */
+#if defined(__TARGET_ARCH_x86) || defined(__x86_64__)
+#define FUNC_REG_ARG_CNT 6
+#elif defined(__i386__)
+#define FUNC_REG_ARG_CNT 3
+#elif defined(__TARGET_ARCH_s390) || defined(__s390x__)
+#define FUNC_REG_ARG_CNT 5
+#elif defined(__TARGET_ARCH_arm) || defined(__arm__)
+#define FUNC_REG_ARG_CNT 4
+#elif defined(__TARGET_ARCH_arm64) || defined(__aarch64__)
+#define FUNC_REG_ARG_CNT 8
+#elif defined(__TARGET_ARCH_mips) || defined(__mips__)
+#define FUNC_REG_ARG_CNT 8
+#elif defined(__TARGET_ARCH_powerpc) || defined(__powerpc__) || defined(__powerpc64__)
+#define FUNC_REG_ARG_CNT 8
+#elif defined(__TARGET_ARCH_sparc) || defined(__sparc__)
+#define FUNC_REG_ARG_CNT 6
+#elif defined(__TARGET_ARCH_riscv) || defined(__riscv__)
+#define FUNC_REG_ARG_CNT 8
+#else
+/* default to 5 for others */
+#define FUNC_REG_ARG_CNT 5
+#endif
+
+
#endif
diff --git a/tools/testing/selftests/bpf/progs/test_uprobe_autoattach.c b/tools/testing/selftests/bpf/progs/test_uprobe_autoattach.c
index ab75522e2eeb..774ddeb45898 100644
--- a/tools/testing/selftests/bpf/progs/test_uprobe_autoattach.c
+++ b/tools/testing/selftests/bpf/progs/test_uprobe_autoattach.c
@@ -6,10 +6,12 @@
#include <bpf/bpf_core_read.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
+#include "bpf_misc.h"
int uprobe_byname_parm1 = 0;
int uprobe_byname_ran = 0;
int uretprobe_byname_rc = 0;
+int uretprobe_byname_ret = 0;
int uretprobe_byname_ran = 0;
size_t uprobe_byname2_parm1 = 0;
int uprobe_byname2_ran = 0;
@@ -18,6 +20,8 @@ int uretprobe_byname2_ran = 0;
int test_pid;
+int a[8];
+
/* This program cannot auto-attach, but that should not stop other
* programs from attaching.
*/
@@ -28,18 +32,58 @@ int handle_uprobe_noautoattach(struct pt_regs *ctx)
}
SEC("uprobe//proc/self/exe:autoattach_trigger_func")
-int handle_uprobe_byname(struct pt_regs *ctx)
+int BPF_UPROBE(handle_uprobe_byname
+ , int arg1
+ , int arg2
+ , int arg3
+#if FUNC_REG_ARG_CNT > 3
+ , int arg4
+#endif
+#if FUNC_REG_ARG_CNT > 4
+ , int arg5
+#endif
+#if FUNC_REG_ARG_CNT > 5
+ , int arg6
+#endif
+#if FUNC_REG_ARG_CNT > 6
+ , int arg7
+#endif
+#if FUNC_REG_ARG_CNT > 7
+ , int arg8
+#endif
+)
{
uprobe_byname_parm1 = PT_REGS_PARM1_CORE(ctx);
uprobe_byname_ran = 1;
+
+ a[0] = arg1;
+ a[1] = arg2;
+ a[2] = arg3;
+#if FUNC_REG_ARG_CNT > 3
+ a[3] = arg4;
+#endif
+#if FUNC_REG_ARG_CNT > 4
+ a[4] = arg5;
+#endif
+#if FUNC_REG_ARG_CNT > 5
+ a[5] = arg6;
+#endif
+#if FUNC_REG_ARG_CNT > 6
+ a[6] = arg7;
+#endif
+#if FUNC_REG_ARG_CNT > 7
+ a[7] = arg8;
+#endif
return 0;
}
SEC("uretprobe//proc/self/exe:autoattach_trigger_func")
-int handle_uretprobe_byname(struct pt_regs *ctx)
+int BPF_URETPROBE(handle_uretprobe_byname, int ret)
{
uretprobe_byname_rc = PT_REGS_RC_CORE(ctx);
+ uretprobe_byname_ret = ret;
uretprobe_byname_ran = 2;
+
return 0;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 12/25] libbpf: improve syscall tracing support in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (10 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 11/25] selftests/bpf: validate arch-specific argument registers limits Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 13/25] libbpf: define x86-64 syscall regs spec " Andrii Nakryiko
` (13 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Alan Maguire
Set up generic support in bpf_tracing.h for up to 7 syscall arguments
tracing with BPF_KSYSCALL, which seems to be the limit according to
syscall(2) manpage. Also change the way that syscall convention is
specified to be more explicit. Subsequent patches will adjust and define
proper per-architecture syscall conventions.
__PT_PARM1_SYSCALL_REG through __PT_PARM6_SYSCALL_REG is added
temporarily to keep everything working before each architecture has
syscall reg tables defined. They will be removed afterwards.
Tested-by: Alan Maguire <alan.maguire@oracle.com> # arm64
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 71 ++++++++++++++++++++++++++++++-------
1 file changed, 58 insertions(+), 13 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 9c4246fe8799..e3bf510e1e55 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -367,6 +367,34 @@ struct pt_regs;
#ifndef __PT_PARM8_REG
#define __PT_PARM8_REG __unsupported__
#endif
+/*
+ * Similarly, syscall-specific conventions might differ between function call
+ * conventions within each architecutre. All supported architectures pass
+ * either 6 or 7 syscall arguments in registers.
+ *
+ * See syscall(2) manpage for succinct table with information on each arch.
+ */
+#ifndef __PT_PARM1_SYSCALL_REG
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#endif
+#ifndef __PT_PARM2_SYSCALL_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#endif
+#ifndef __PT_PARM3_SYSCALL_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#endif
+#ifndef __PT_PARM4_SYSCALL_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#endif
+#ifndef __PT_PARM5_SYSCALL_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#endif
+#ifndef __PT_PARM6_SYSCALL_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+#endif
+#ifndef __PT_PARM7_SYSCALL_REG
+#define __PT_PARM7_SYSCALL_REG __unsupported__
+#endif
#define PT_REGS_PARM1(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG)
#define PT_REGS_PARM2(x) (__PT_REGS_CAST(x)->__PT_PARM2_REG)
@@ -416,24 +444,33 @@ struct pt_regs;
#endif
#ifndef PT_REGS_PARM1_SYSCALL
-#define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1(x)
+#define PT_REGS_PARM1_SYSCALL(x) (__PT_REGS_CAST(x)->__PT_PARM1_SYSCALL_REG)
+#define PT_REGS_PARM1_CORE_SYSCALL(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM1_SYSCALL_REG)
+#endif
+#ifndef PT_REGS_PARM2_SYSCALL
+#define PT_REGS_PARM2_SYSCALL(x) (__PT_REGS_CAST(x)->__PT_PARM2_SYSCALL_REG)
+#define PT_REGS_PARM2_CORE_SYSCALL(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM2_SYSCALL_REG)
+#endif
+#ifndef PT_REGS_PARM3_SYSCALL
+#define PT_REGS_PARM3_SYSCALL(x) (__PT_REGS_CAST(x)->__PT_PARM3_SYSCALL_REG)
+#define PT_REGS_PARM3_CORE_SYSCALL(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM3_SYSCALL_REG)
#endif
-#define PT_REGS_PARM2_SYSCALL(x) PT_REGS_PARM2(x)
-#define PT_REGS_PARM3_SYSCALL(x) PT_REGS_PARM3(x)
#ifndef PT_REGS_PARM4_SYSCALL
-#define PT_REGS_PARM4_SYSCALL(x) PT_REGS_PARM4(x)
+#define PT_REGS_PARM4_SYSCALL(x) (__PT_REGS_CAST(x)->__PT_PARM4_SYSCALL_REG)
+#define PT_REGS_PARM4_CORE_SYSCALL(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM4_SYSCALL_REG)
#endif
-#define PT_REGS_PARM5_SYSCALL(x) PT_REGS_PARM5(x)
-
-#ifndef PT_REGS_PARM1_CORE_SYSCALL
-#define PT_REGS_PARM1_CORE_SYSCALL(x) PT_REGS_PARM1_CORE(x)
+#ifndef PT_REGS_PARM5_SYSCALL
+#define PT_REGS_PARM5_SYSCALL(x) (__PT_REGS_CAST(x)->__PT_PARM5_SYSCALL_REG)
+#define PT_REGS_PARM5_CORE_SYSCALL(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM5_SYSCALL_REG)
+#endif
+#ifndef PT_REGS_PARM6_SYSCALL
+#define PT_REGS_PARM6_SYSCALL(x) (__PT_REGS_CAST(x)->__PT_PARM6_SYSCALL_REG)
+#define PT_REGS_PARM6_CORE_SYSCALL(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM6_SYSCALL_REG)
#endif
-#define PT_REGS_PARM2_CORE_SYSCALL(x) PT_REGS_PARM2_CORE(x)
-#define PT_REGS_PARM3_CORE_SYSCALL(x) PT_REGS_PARM3_CORE(x)
-#ifndef PT_REGS_PARM4_CORE_SYSCALL
-#define PT_REGS_PARM4_CORE_SYSCALL(x) PT_REGS_PARM4_CORE(x)
+#ifndef PT_REGS_PARM7_SYSCALL
+#define PT_REGS_PARM7_SYSCALL(x) (__PT_REGS_CAST(x)->__PT_PARM7_SYSCALL_REG)
+#define PT_REGS_PARM7_CORE_SYSCALL(x) BPF_CORE_READ(__PT_REGS_CAST(x), __PT_PARM7_SYSCALL_REG)
#endif
-#define PT_REGS_PARM5_CORE_SYSCALL(x) PT_REGS_PARM5_CORE(x)
#else /* defined(bpf_target_defined) */
@@ -473,12 +510,16 @@ struct pt_regs;
#define PT_REGS_PARM3_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM4_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM5_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM6_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM7_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM1_CORE_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM2_CORE_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM3_CORE_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM4_CORE_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#define PT_REGS_PARM5_CORE_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM6_CORE_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
+#define PT_REGS_PARM7_CORE_SYSCALL(x) ({ _Pragma(__BPF_TARGET_MISSING); 0l; })
#endif /* defined(bpf_target_defined) */
@@ -723,6 +764,8 @@ static __always_inline typeof(name(0)) ____##name(struct pt_regs *ctx, ##args)
#define ___bpf_syscall_args3(x, args...) ___bpf_syscall_args2(args), (void *)PT_REGS_PARM3_SYSCALL(regs)
#define ___bpf_syscall_args4(x, args...) ___bpf_syscall_args3(args), (void *)PT_REGS_PARM4_SYSCALL(regs)
#define ___bpf_syscall_args5(x, args...) ___bpf_syscall_args4(args), (void *)PT_REGS_PARM5_SYSCALL(regs)
+#define ___bpf_syscall_args6(x, args...) ___bpf_syscall_args5(args), (void *)PT_REGS_PARM6_SYSCALL(regs)
+#define ___bpf_syscall_args7(x, args...) ___bpf_syscall_args6(args), (void *)PT_REGS_PARM7_SYSCALL(regs)
#define ___bpf_syscall_args(args...) ___bpf_apply(___bpf_syscall_args, ___bpf_narg(args))(args)
/* If kernel doesn't have CONFIG_ARCH_HAS_SYSCALL_WRAPPER, we have to BPF_CORE_READ from pt_regs */
@@ -732,6 +775,8 @@ static __always_inline typeof(name(0)) ____##name(struct pt_regs *ctx, ##args)
#define ___bpf_syswrap_args3(x, args...) ___bpf_syswrap_args2(args), (void *)PT_REGS_PARM3_CORE_SYSCALL(regs)
#define ___bpf_syswrap_args4(x, args...) ___bpf_syswrap_args3(args), (void *)PT_REGS_PARM4_CORE_SYSCALL(regs)
#define ___bpf_syswrap_args5(x, args...) ___bpf_syswrap_args4(args), (void *)PT_REGS_PARM5_CORE_SYSCALL(regs)
+#define ___bpf_syswrap_args6(x, args...) ___bpf_syswrap_args5(args), (void *)PT_REGS_PARM6_CORE_SYSCALL(regs)
+#define ___bpf_syswrap_args7(x, args...) ___bpf_syswrap_args6(args), (void *)PT_REGS_PARM7_CORE_SYSCALL(regs)
#define ___bpf_syswrap_args(args...) ___bpf_apply(___bpf_syswrap_args, ___bpf_narg(args))(args)
/*
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 13/25] libbpf: define x86-64 syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (11 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 12/25] libbpf: improve syscall tracing support in bpf_tracing.h Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 14/25] libbpf: define i386 " Andrii Nakryiko
` (12 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Define explicit table of registers used for syscall argument passing.
Remove now unnecessary overrides of PT_REGS_PARM5_[CORE_]SYSCALL macros.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index e3bf510e1e55..5fd498821c29 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -90,14 +90,22 @@
#define __PT_PARM4_REG cx
#define __PT_PARM5_REG r8
#define __PT_PARM6_REG r9
+/*
+ * Syscall uses r10 for PARM4. See arch/x86/entry/entry_64.S:entry_SYSCALL_64
+ * comments in Linux sources. And refer to syscall(2) manpage.
+ */
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG r10
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+
#define __PT_RET_REG sp
#define __PT_FP_REG bp
#define __PT_RC_REG ax
#define __PT_SP_REG sp
#define __PT_IP_REG ip
-/* syscall uses r10 for PARM4 */
-#define PT_REGS_PARM4_SYSCALL(x) ((x)->r10)
-#define PT_REGS_PARM4_CORE_SYSCALL(x) BPF_CORE_READ(x, r10)
#else
@@ -121,14 +129,19 @@
#define __PT_PARM4_REG rcx
#define __PT_PARM5_REG r8
#define __PT_PARM6_REG r9
+
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG r10
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+
#define __PT_RET_REG rsp
#define __PT_FP_REG rbp
#define __PT_RC_REG rax
#define __PT_SP_REG rsp
#define __PT_IP_REG rip
-/* syscall uses r10 for PARM4 */
-#define PT_REGS_PARM4_SYSCALL(x) ((x)->r10)
-#define PT_REGS_PARM4_CORE_SYSCALL(x) BPF_CORE_READ(x, r10)
#endif /* __i386__ */
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 14/25] libbpf: define i386 syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (12 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 13/25] libbpf: define x86-64 syscall regs spec " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 15/25] libbpf: define s390x " Andrii Nakryiko
` (11 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Define explicit table of registers used for syscall argument passing.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 5fd498821c29..4d04c63fda27 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -115,6 +115,14 @@
#define __PT_PARM1_REG eax
#define __PT_PARM2_REG edx
#define __PT_PARM3_REG ecx
+/* i386 syscall ABI is very different, refer to syscall(2) manpage */
+#define __PT_PARM1_SYSCALL_REG ebx
+#define __PT_PARM2_SYSCALL_REG ecx
+#define __PT_PARM3_SYSCALL_REG edx
+#define __PT_PARM4_SYSCALL_REG esi
+#define __PT_PARM5_SYSCALL_REG edi
+#define __PT_PARM6_SYSCALL_REG ebp
+
#define __PT_RET_REG esp
#define __PT_FP_REG ebp
#define __PT_RC_REG eax
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 15/25] libbpf: define s390x syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (13 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 14/25] libbpf: define i386 " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 16/25] libbpf: define arm " Andrii Nakryiko
` (10 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Ilya Leoshkevich
Define explicit table of registers used for syscall argument passing.
Note that we need custom overrides for PT_REGS_PARM1_[CORE_]SYSCALL
macros due to the need to use BPF CO-RE and custom local pt_regs
definitions to fetch orig_gpr2, storing 1st argument.
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> # s390x
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 4d04c63fda27..b63d538eb5f5 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -157,6 +157,10 @@
#elif defined(bpf_target_s390)
+/*
+ * https://github.com/IBM/s390x-abi/releases/download/v1.6/lzsabi_s390x.pdf
+ */
+
struct pt_regs___s390 {
unsigned long orig_gpr2;
};
@@ -168,13 +172,22 @@ struct pt_regs___s390 {
#define __PT_PARM3_REG gprs[4]
#define __PT_PARM4_REG gprs[5]
#define __PT_PARM5_REG gprs[6]
+
+#define __PT_PARM1_SYSCALL_REG orig_gpr2
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG gprs[7]
+#define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1_CORE_SYSCALL(x)
+#define PT_REGS_PARM1_CORE_SYSCALL(x) \
+ BPF_CORE_READ((const struct pt_regs___s390 *)(x), __PT_PARM1_SYSCALL_REG)
+
#define __PT_RET_REG gprs[14]
#define __PT_FP_REG gprs[11] /* Works only with CONFIG_FRAME_POINTER */
#define __PT_RC_REG gprs[2]
#define __PT_SP_REG gprs[15]
#define __PT_IP_REG psw.addr
-#define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1_CORE_SYSCALL(x)
-#define PT_REGS_PARM1_CORE_SYSCALL(x) BPF_CORE_READ((const struct pt_regs___s390 *)(x), orig_gpr2)
#elif defined(bpf_target_arm)
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 16/25] libbpf: define arm syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (14 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 15/25] libbpf: define s390x " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 17/25] libbpf: define arm64 " Andrii Nakryiko
` (9 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Define explicit table of registers used for syscall argument passing.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index b63d538eb5f5..edd85a0ab612 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -199,6 +199,14 @@ struct pt_regs___s390 {
#define __PT_PARM2_REG uregs[1]
#define __PT_PARM3_REG uregs[2]
#define __PT_PARM4_REG uregs[3]
+
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM6_SYSCALL_REG uregs[5]
+#define __PT_PARM7_SYSCALL_REG uregs[6]
+
#define __PT_RET_REG uregs[14]
#define __PT_FP_REG uregs[11] /* Works only with CONFIG_FRAME_POINTER */
#define __PT_RC_REG uregs[0]
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 17/25] libbpf: define arm64 syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (15 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 16/25] libbpf: define arm " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 18/25] libbpf: define mips " Andrii Nakryiko
` (8 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Alan Maguire
Define explicit table of registers used for syscall argument passing.
We need PT_REGS_PARM1_[CORE_]SYSCALL macros overrides, similarly to
s390x, due to orig_x0 not being present in UAPI's pt_regs, so we need to
utilize BPF CO-RE and custom pt_regs___arm64 definition.
Tested-by: Alan Maguire <alan.maguire@oracle.com> # arm64
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index edd85a0ab612..f753346e9be6 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -233,13 +233,22 @@ struct pt_regs___arm64 {
#define __PT_PARM6_REG regs[5]
#define __PT_PARM7_REG regs[6]
#define __PT_PARM8_REG regs[7]
+
+#define __PT_PARM1_SYSCALL_REG orig_x0
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+#define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1_CORE_SYSCALL(x)
+#define PT_REGS_PARM1_CORE_SYSCALL(x) \
+ BPF_CORE_READ((const struct pt_regs___arm64 *)(x), __PT_PARM1_SYSCALL_REG)
+
#define __PT_RET_REG regs[30]
#define __PT_FP_REG regs[29] /* Works only with CONFIG_FRAME_POINTER */
#define __PT_RC_REG regs[0]
#define __PT_SP_REG sp
#define __PT_IP_REG pc
-#define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1_CORE_SYSCALL(x)
-#define PT_REGS_PARM1_CORE_SYSCALL(x) BPF_CORE_READ((const struct pt_regs___arm64 *)(x), orig_x0)
#elif defined(bpf_target_mips)
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 18/25] libbpf: define mips syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (16 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 17/25] libbpf: define arm64 " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 19/25] libbpf: define powerpc " Andrii Nakryiko
` (7 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Define explicit table of registers used for syscall argument passing.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index f753346e9be6..a3da63b74b0b 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -265,6 +265,14 @@ struct pt_regs___arm64 {
#define __PT_PARM6_REG regs[9]
#define __PT_PARM7_REG regs[10]
#define __PT_PARM8_REG regs[11]
+
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG /* only N32/N64 */
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG /* only N32/N64 */
+
#define __PT_RET_REG regs[31]
#define __PT_FP_REG regs[30] /* Works only with CONFIG_FRAME_POINTER */
#define __PT_RC_REG regs[2]
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 19/25] libbpf: define powerpc syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (17 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 18/25] libbpf: define mips " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 20/25] libbpf: define sparc " Andrii Nakryiko
` (6 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Define explicit table of registers used for syscall argument passing.
Note that 7th arg is supported on 32-bit powerpc architecture, by not on
powerpc64.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index a3da63b74b0b..b3647c4a6c0c 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -294,13 +294,24 @@ struct pt_regs___arm64 {
#define __PT_PARM6_REG gpr[8]
#define __PT_PARM7_REG gpr[9]
#define __PT_PARM8_REG gpr[10]
+
+/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER. */
+#define PT_REGS_SYSCALL_REGS(ctx) ctx
+#define __PT_PARM1_SYSCALL_REG orig_gpr3
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+#if !defined(__arch64__)
+#define __PT_PARM7_SYSCALL_REG __PT_PARM7_REG /* only powerpc (not powerpc64) */
+#endif
+
#define __PT_RET_REG regs[31]
#define __PT_FP_REG __unsupported__
#define __PT_RC_REG gpr[3]
#define __PT_SP_REG sp
#define __PT_IP_REG nip
-/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER. */
-#define PT_REGS_SYSCALL_REGS(ctx) ctx
#elif defined(bpf_target_sparc)
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 20/25] libbpf: define sparc syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (18 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 19/25] libbpf: define powerpc " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 21/25] libbpf: define riscv " Andrii Nakryiko
` (5 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Define explicit table of registers used for syscall argument passing.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index b3647c4a6c0c..a2db267a6bce 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -325,6 +325,14 @@ struct pt_regs___arm64 {
#define __PT_PARM4_REG u_regs[UREG_I3]
#define __PT_PARM5_REG u_regs[UREG_I4]
#define __PT_PARM6_REG u_regs[UREG_I5]
+
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+
#define __PT_RET_REG u_regs[UREG_I7]
#define __PT_FP_REG __unsupported__
#define __PT_RC_REG u_regs[UREG_I0]
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 21/25] libbpf: define riscv syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (19 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 20/25] libbpf: define sparc " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 22/25] libbpf: define arc " Andrii Nakryiko
` (4 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Pu Lehui
Define explicit table of registers used for syscall argument passing.
Tested-by: Pu Lehui <pulehui@huawei.com> # RISC-V
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index a2db267a6bce..047dc84c7cc9 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -359,13 +359,21 @@ struct pt_regs___arm64 {
#define __PT_PARM6_REG a5
#define __PT_PARM7_REG a6
#define __PT_PARM8_REG a7
+
+/* riscv does not select ARCH_HAS_SYSCALL_WRAPPER. */
+#define PT_REGS_SYSCALL_REGS(ctx) ctx
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+
#define __PT_RET_REG ra
#define __PT_FP_REG s0
#define __PT_RC_REG a0
#define __PT_SP_REG sp
#define __PT_IP_REG pc
-/* riscv does not select ARCH_HAS_SYSCALL_WRAPPER. */
-#define PT_REGS_SYSCALL_REGS(ctx) ctx
#elif defined(bpf_target_arc)
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 22/25] libbpf: define arc syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (20 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 21/25] libbpf: define riscv " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 23/25] libbpf: define loongarch " Andrii Nakryiko
` (3 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Define explicit table of registers used for syscall argument passing.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 047dc84c7cc9..87fd2c774e73 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -392,13 +392,21 @@ struct pt_regs___arm64 {
#define __PT_PARM6_REG scratch.r5
#define __PT_PARM7_REG scratch.r6
#define __PT_PARM8_REG scratch.r7
+
+/* arc does not select ARCH_HAS_SYSCALL_WRAPPER. */
+#define PT_REGS_SYSCALL_REGS(ctx) ctx
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+
#define __PT_RET_REG scratch.blink
#define __PT_FP_REG scratch.fp
#define __PT_RC_REG scratch.r0
#define __PT_SP_REG scratch.sp
#define __PT_IP_REG scratch.ret
-/* arc does not select ARCH_HAS_SYSCALL_WRAPPER. */
-#define PT_REGS_SYSCALL_REGS(ctx) ctx
#elif defined(bpf_target_loongarch)
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 23/25] libbpf: define loongarch syscall regs spec in bpf_tracing.h
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (21 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 22/25] libbpf: define arc " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 24/25] selftests/bpf: add 6-argument syscall tracing test Andrii Nakryiko
` (2 subsequent siblings)
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Define explicit table of registers used for syscall argument passing.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 87fd2c774e73..b37d3c78b19a 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -423,13 +423,21 @@ struct pt_regs___arm64 {
#define __PT_PARM6_REG regs[9]
#define __PT_PARM7_REG regs[10]
#define __PT_PARM8_REG regs[11]
+
+/* loongarch does not select ARCH_HAS_SYSCALL_WRAPPER. */
+#define PT_REGS_SYSCALL_REGS(ctx) ctx
+#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
+#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
+#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
+#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
+#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
+#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
+
#define __PT_RET_REG regs[1]
#define __PT_FP_REG regs[22]
#define __PT_RC_REG regs[4]
#define __PT_SP_REG regs[3]
#define __PT_IP_REG csr_era
-/* loongarch does not select ARCH_HAS_SYSCALL_WRAPPER. */
-#define PT_REGS_SYSCALL_REGS(ctx) ctx
#endif
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 24/25] selftests/bpf: add 6-argument syscall tracing test
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (22 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 23/25] libbpf: define loongarch " Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 25/25] libbpf: clean up now not needed __PT_PARM{1-6}_SYSCALL_REG defaults Andrii Nakryiko
2023-01-23 20:10 ` [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support patchwork-bot+netdevbpf
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team, Alan Maguire, Ilya Leoshkevich
Turns out splice() is one of the syscalls that's using current maximum
number of arguments (six). This is perfect for testing, so extend
bpf_syscall_macro selftest to also trace splice() syscall, using
BPF_KSYSCALL() macro. This makes sure all the syscall argument register
definitions are correct.
Tested-by: Alan Maguire <alan.maguire@oracle.com> # arm64
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> # s390x
Suggested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
.../bpf/prog_tests/test_bpf_syscall_macro.c | 17 ++++++++++++
.../selftests/bpf/progs/bpf_syscall_macro.c | 26 +++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/test_bpf_syscall_macro.c b/tools/testing/selftests/bpf/prog_tests/test_bpf_syscall_macro.c
index c381faaae741..2900c5e9a016 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_bpf_syscall_macro.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_bpf_syscall_macro.c
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright 2022 Sony Group Corporation */
+#define _GNU_SOURCE
+#include <fcntl.h>
#include <sys/prctl.h>
#include <test_progs.h>
#include "bpf_syscall_macro.skel.h"
@@ -13,6 +15,8 @@ void test_bpf_syscall_macro(void)
unsigned long exp_arg3 = 13;
unsigned long exp_arg4 = 14;
unsigned long exp_arg5 = 15;
+ loff_t off_in, off_out;
+ ssize_t r;
/* check whether it can open program */
skel = bpf_syscall_macro__open();
@@ -33,6 +37,7 @@ void test_bpf_syscall_macro(void)
/* check whether args of syscall are copied correctly */
prctl(exp_arg1, exp_arg2, exp_arg3, exp_arg4, exp_arg5);
+
#if defined(__aarch64__) || defined(__s390__)
ASSERT_NEQ(skel->bss->arg1, exp_arg1, "syscall_arg1");
#else
@@ -68,6 +73,18 @@ void test_bpf_syscall_macro(void)
ASSERT_EQ(skel->bss->arg4_syscall, exp_arg4, "BPF_KPROBE_SYSCALL_arg4");
ASSERT_EQ(skel->bss->arg5_syscall, exp_arg5, "BPF_KPROBE_SYSCALL_arg5");
+ r = splice(-42, &off_in, 42, &off_out, 0x12340000, SPLICE_F_NONBLOCK);
+ err = -errno;
+ ASSERT_EQ(r, -1, "splice_res");
+ ASSERT_EQ(err, -EBADF, "splice_err");
+
+ ASSERT_EQ(skel->bss->splice_fd_in, -42, "splice_arg1");
+ ASSERT_EQ(skel->bss->splice_off_in, (__u64)&off_in, "splice_arg2");
+ ASSERT_EQ(skel->bss->splice_fd_out, 42, "splice_arg3");
+ ASSERT_EQ(skel->bss->splice_off_out, (__u64)&off_out, "splice_arg4");
+ ASSERT_EQ(skel->bss->splice_len, 0x12340000, "splice_arg5");
+ ASSERT_EQ(skel->bss->splice_flags, SPLICE_F_NONBLOCK, "splice_arg6");
+
cleanup:
bpf_syscall_macro__destroy(skel);
}
diff --git a/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c b/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c
index e1e11897e99b..1a476d8ed354 100644
--- a/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c
+++ b/tools/testing/selftests/bpf/progs/bpf_syscall_macro.c
@@ -81,4 +81,30 @@ int BPF_KSYSCALL(prctl_enter, int option, unsigned long arg2,
return 0;
}
+__u64 splice_fd_in;
+__u64 splice_off_in;
+__u64 splice_fd_out;
+__u64 splice_off_out;
+__u64 splice_len;
+__u64 splice_flags;
+
+SEC("ksyscall/splice")
+int BPF_KSYSCALL(splice_enter, int fd_in, loff_t *off_in, int fd_out,
+ loff_t *off_out, size_t len, unsigned int flags)
+{
+ pid_t pid = bpf_get_current_pid_tgid() >> 32;
+
+ if (pid != filter_pid)
+ return 0;
+
+ splice_fd_in = fd_in;
+ splice_off_in = (__u64)off_in;
+ splice_fd_out = fd_out;
+ splice_off_out = (__u64)off_out;
+ splice_len = len;
+ splice_flags = flags;
+
+ return 0;
+}
+
char _license[] SEC("license") = "GPL";
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 bpf-next 25/25] libbpf: clean up now not needed __PT_PARM{1-6}_SYSCALL_REG defaults
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (23 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 24/25] selftests/bpf: add 6-argument syscall tracing test Andrii Nakryiko
@ 2023-01-20 20:09 ` Andrii Nakryiko
2023-01-23 20:10 ` [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support patchwork-bot+netdevbpf
25 siblings, 0 replies; 27+ messages in thread
From: Andrii Nakryiko @ 2023-01-20 20:09 UTC (permalink / raw)
To: bpf, ast, daniel; +Cc: andrii, kernel-team
Each architecture supports at least 6 syscall argument registers, so now
that specs for each architecture is defined in bpf_tracing.h, remove
unnecessary macro overrides, which previously were required to keep
existing BPF_KSYSCALL() uses compiling and working.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/bpf_tracing.h | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index b37d3c78b19a..6db88f41fa0d 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -476,24 +476,6 @@ struct pt_regs;
*
* See syscall(2) manpage for succinct table with information on each arch.
*/
-#ifndef __PT_PARM1_SYSCALL_REG
-#define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
-#endif
-#ifndef __PT_PARM2_SYSCALL_REG
-#define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
-#endif
-#ifndef __PT_PARM3_SYSCALL_REG
-#define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
-#endif
-#ifndef __PT_PARM4_SYSCALL_REG
-#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
-#endif
-#ifndef __PT_PARM5_SYSCALL_REG
-#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
-#endif
-#ifndef __PT_PARM6_SYSCALL_REG
-#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
-#endif
#ifndef __PT_PARM7_SYSCALL_REG
#define __PT_PARM7_SYSCALL_REG __unsupported__
#endif
--
2.30.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
` (24 preceding siblings ...)
2023-01-20 20:09 ` [PATCH v2 bpf-next 25/25] libbpf: clean up now not needed __PT_PARM{1-6}_SYSCALL_REG defaults Andrii Nakryiko
@ 2023-01-23 20:10 ` patchwork-bot+netdevbpf
25 siblings, 0 replies; 27+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-23 20:10 UTC (permalink / raw)
To: Andrii Nakryiko; +Cc: bpf, ast, daniel, kernel-team
Hello:
This series was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Fri, 20 Jan 2023 12:08:49 -0800 you wrote:
> This patch set fixes and extends libbpf's bpf_tracing.h support for tracing
> arguments of kprobes/uprobes, and syscall as a special case.
>
> Depending on the architecture, anywhere between 3 and 8 arguments can be
> passed to a function in registers (so relevant to kprobes and uprobes), but
> before this patch set libbpf's macros in bpf_tracing.h only supported up to
> 5 arguments, which is limiting in practice. This patch set extends
> bpf_tracing.h to support up to 8 arguments, if architecture allows. This
> includes explicit PT_REGS_PARMx() macro family, as well as BPF_KPROBE() macro.
>
> [...]
Here is the summary with links:
- [v2,bpf-next,01/25] libbpf: add support for fetching up to 8 arguments in kprobes
https://git.kernel.org/bpf/bpf-next/c/3c59623d8294
- [v2,bpf-next,02/25] libbpf: add 6th argument support for x86-64 in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/013290329a07
- [v2,bpf-next,03/25] libbpf: fix arm and arm64 specs in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/1dac40ac8742
- [v2,bpf-next,04/25] libbpf: complete mips spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/1222445a5bf6
- [v2,bpf-next,05/25] libbpf: complete powerpc spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/2eb2be30b8da
- [v2,bpf-next,06/25] libbpf: complete sparc spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/7f60f5d85e29
- [v2,bpf-next,07/25] libbpf: complete riscv arch spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/b13ed8ca7fba
- [v2,bpf-next,08/25] libbpf: fix and complete ARC spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/0ac086567916
- [v2,bpf-next,09/25] libbpf: complete LoongArch (loongarch) spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/55ff00d5393b
- [v2,bpf-next,10/25] libbpf: add BPF_UPROBE and BPF_URETPROBE macro aliases
https://git.kernel.org/bpf/bpf-next/c/ac4afd6e6fa4
- [v2,bpf-next,11/25] selftests/bpf: validate arch-specific argument registers limits
https://git.kernel.org/bpf/bpf-next/c/bc72742bebec
- [v2,bpf-next,12/25] libbpf: improve syscall tracing support in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/8ccabeef9133
- [v2,bpf-next,13/25] libbpf: define x86-64 syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/d21fbceedd90
- [v2,bpf-next,14/25] libbpf: define i386 syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/ff00f9cbd2dd
- [v2,bpf-next,15/25] libbpf: define s390x syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/e82b96a3a99f
- [v2,bpf-next,16/25] libbpf: define arm syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/3a95c42d65d5
- [v2,bpf-next,17/25] libbpf: define arm64 syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/3488ea0584bb
- [v2,bpf-next,18/25] libbpf: define mips syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/cfd0bbe91536
- [v2,bpf-next,19/25] libbpf: define powerpc syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/c1cc01a2d1d1
- [v2,bpf-next,20/25] libbpf: define sparc syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/377c15b1a2cd
- [v2,bpf-next,21/25] libbpf: define riscv syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/a0426216a320
- [v2,bpf-next,22/25] libbpf: define arc syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/2cf802737fb9
- [v2,bpf-next,23/25] libbpf: define loongarch syscall regs spec in bpf_tracing.h
https://git.kernel.org/bpf/bpf-next/c/12a299f0b5c7
- [v2,bpf-next,24/25] selftests/bpf: add 6-argument syscall tracing test
https://git.kernel.org/bpf/bpf-next/c/92dc5cdfc113
- [v2,bpf-next,25/25] libbpf: clean up now not needed __PT_PARM{1-6}_SYSCALL_REG defaults
https://git.kernel.org/bpf/bpf-next/c/a4d325ae461c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2023-01-23 20:10 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-20 20:08 [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 01/25] libbpf: add support for fetching up to 8 arguments in kprobes Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 02/25] libbpf: add 6th argument support for x86-64 in bpf_tracing.h Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 03/25] libbpf: fix arm and arm64 specs " Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 04/25] libbpf: complete mips spec " Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 05/25] libbpf: complete powerpc " Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 06/25] libbpf: complete sparc " Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 07/25] libbpf: complete riscv arch " Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 08/25] libbpf: fix and complete ARC " Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 09/25] libbpf: complete LoongArch (loongarch) " Andrii Nakryiko
2023-01-20 20:08 ` [PATCH v2 bpf-next 10/25] libbpf: add BPF_UPROBE and BPF_URETPROBE macro aliases Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 11/25] selftests/bpf: validate arch-specific argument registers limits Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 12/25] libbpf: improve syscall tracing support in bpf_tracing.h Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 13/25] libbpf: define x86-64 syscall regs spec " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 14/25] libbpf: define i386 " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 15/25] libbpf: define s390x " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 16/25] libbpf: define arm " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 17/25] libbpf: define arm64 " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 18/25] libbpf: define mips " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 19/25] libbpf: define powerpc " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 20/25] libbpf: define sparc " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 21/25] libbpf: define riscv " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 22/25] libbpf: define arc " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 23/25] libbpf: define loongarch " Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 24/25] selftests/bpf: add 6-argument syscall tracing test Andrii Nakryiko
2023-01-20 20:09 ` [PATCH v2 bpf-next 25/25] libbpf: clean up now not needed __PT_PARM{1-6}_SYSCALL_REG defaults Andrii Nakryiko
2023-01-23 20:10 ` [PATCH v2 bpf-next 00/25] libbpf: extend [ku]probe and syscall argument tracing support patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox