From: Saket Kumar Bhaskar <skb99@linux.ibm.com>
To: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: ast@kernel.org, hbathini@linux.ibm.com, andrii@kernel.org,
daniel@iogearbox.net, martin.lau@linux.dev, eddyz87@gmail.com,
song@kernel.org, yonghong.song@linux.dev,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, shuah@kernel.org,
mykolal@fb.com
Subject: [PATCH 1/3] libbpf: Fix accessing the syscall argument on powerpc
Date: Mon, 4 Nov 2024 10:30:05 +0530 [thread overview]
Message-ID: <20241104050007.13812-2-skb99@linux.ibm.com> (raw)
In-Reply-To: <20241104050007.13812-1-skb99@linux.ibm.com>
Since commit 7e92e01b7245 ("powerpc: Provide syscall wrapper"), powerpc
selects ARCH_HAS_SYSCALL_WRAPPER so let's use the generic implementation
of PT_REGS_SYSCALL_REGS().
Also, allow overriding PT_REGS_PARM1{_CORE}_SYSCALL for powerpc as
powerpc needs orig_gpr3, similar to s390 and arm64.
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
---
tools/lib/bpf/bpf_tracing.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index a8f6cd4841b0..933e1dab6c8f 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -287,6 +287,10 @@ struct pt_regs___arm64 {
* section "Function Calling Sequence")
*/
+struct pt_regs___powerpc {
+ unsigned long orig_gpr3;
+} __attribute__((preserve_access_index));
+
#define __PT_PARM1_REG gpr[3]
#define __PT_PARM2_REG gpr[4]
#define __PT_PARM3_REG gpr[5]
@@ -296,8 +300,6 @@ struct pt_regs___arm64 {
#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
@@ -307,6 +309,9 @@ struct pt_regs___arm64 {
#if !defined(__arch64__)
#define __PT_PARM7_SYSCALL_REG __PT_PARM7_REG /* only powerpc (not powerpc64) */
#endif
+#define PT_REGS_PARM1_SYSCALL(x) (((const struct pt_regs___powerpc *)(x))->orig_gpr3)
+#define PT_REGS_PARM1_CORE_SYSCALL(x) \
+ BPF_CORE_READ((const struct pt_regs___powerpc *)(x), __PT_PARM1_SYSCALL_REG)
#define __PT_RET_REG regs[31]
#define __PT_FP_REG __unsupported__
--
2.43.5
next prev parent reply other threads:[~2024-11-04 5:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 5:00 [PATCH 0/3] Fix test_bpf_syscall_macro selftest on powerpc Saket Kumar Bhaskar
2024-11-04 5:00 ` Saket Kumar Bhaskar [this message]
2024-11-04 5:00 ` [PATCH 2/3] libbpf: Remove powerpc prefix from syscall function names Saket Kumar Bhaskar
2024-11-08 18:43 ` Andrii Nakryiko
2024-11-20 14:52 ` Saket Kumar Bhaskar
2024-11-22 0:00 ` Andrii Nakryiko
2025-01-10 10:49 ` Saket Kumar Bhaskar
2025-01-10 22:29 ` Andrii Nakryiko
2025-01-11 19:53 ` Saket Kumar Bhaskar
2025-01-14 22:40 ` Andrii Nakryiko
2025-01-15 14:15 ` Saket Kumar Bhaskar
2025-01-16 23:19 ` Andrii Nakryiko
2024-11-04 5:00 ` [PATCH 3/3] selftests/bpf: Define SYS_PREFIX for powerpc Saket Kumar Bhaskar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241104050007.13812-2-skb99@linux.ibm.com \
--to=skb99@linux.ibm.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=hbathini@linux.ibm.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox