From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>
Cc: bpf@vger.kernel.org, Ilya Leoshkevich <iii@linux.ibm.com>,
Andrii Nakryiko <andrii@kernel.org>
Subject: [PATCH bpf-next v5 10/10] libbpf: Fix accessing the first syscall argument on s390
Date: Wed, 9 Feb 2022 03:17:45 +0100 [thread overview]
Message-ID: <20220209021745.2215452-11-iii@linux.ibm.com> (raw)
In-Reply-To: <20220209021745.2215452-1-iii@linux.ibm.com>
On s390, the first syscall argument should be accessed via orig_gpr2
(see arch/s390/include/asm/syscall.h). Currently gpr[2] is used
instead, leading to bpf_syscall_macro test failure.
orig_gpr2 cannot be added to user_pt_regs, since its layout is a part
of the ABI. Therefore provide access to it only through
PT_REGS_PARM1_CORE_SYSCALL() by using a struct pt_regs flavor.
Reported-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
tools/lib/bpf/bpf_tracing.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 928f85f7961c..0e0414801457 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -114,9 +114,19 @@
#elif defined(bpf_target_s390)
+struct pt_regs___s390 {
+ unsigned long orig_gpr2;
+} __attribute__((preserve_access_index));
+
/* s390 provides user_pt_regs instead of struct pt_regs to userspace */
#define __PT_REGS_CAST(x) ((const user_pt_regs *)(x))
#define __PT_PARM1_REG gprs[2]
+#define PT_REGS_PARM1_SYSCALL(x) ({ \
+ _Pragma("GCC error \"PT_REGS_PARM1_SYSCALL() is not supported on s390, use PT_REGS_PARM1_CORE_SYSCALL() instead\""); \
+ 0l; \
+})
+#define PT_REGS_PARM1_CORE_SYSCALL(x) \
+ BPF_CORE_READ((const struct pt_regs___s390 *)(x), orig_gpr2)
#define __PT_PARM2_REG gprs[3]
#define __PT_PARM3_REG gprs[4]
#define __PT_PARM4_REG gprs[5]
--
2.34.1
next prev parent reply other threads:[~2022-02-09 2:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 2:17 [PATCH bpf-next v5 00/10] Fix accessing syscall arguments Ilya Leoshkevich
2022-02-09 2:17 ` [PATCH bpf-next v5 01/10] selftests/bpf: Fix an endianness issue in bpf_syscall_macro test Ilya Leoshkevich
2022-02-09 2:17 ` [PATCH bpf-next v5 02/10] libbpf: Add PT_REGS_SYSCALL_REGS macro Ilya Leoshkevich
2022-02-09 2:17 ` [PATCH bpf-next v5 03/10] selftests/bpf: Use PT_REGS_SYSCALL_REGS in bpf_syscall_macro Ilya Leoshkevich
2022-02-09 2:17 ` [PATCH bpf-next v5 04/10] libbpf: Fix accessing syscall arguments on powerpc Ilya Leoshkevich
2022-02-09 2:17 ` [PATCH bpf-next v5 05/10] libbpf: Fix riscv register names Ilya Leoshkevich
2022-02-09 2:17 ` [PATCH bpf-next v5 06/10] libbpf: Fix accessing syscall arguments on riscv Ilya Leoshkevich
2022-02-09 2:17 ` [PATCH bpf-next v5 07/10] selftests/bpf: Skip test_bpf_syscall_macro:syscall_arg1 on arm64 and s390 Ilya Leoshkevich
2022-02-09 2:17 ` [PATCH bpf-next v5 08/10] libbpf: Allow overriding PT_REGS_PARM1{_CORE}_SYSCALL Ilya Leoshkevich
2022-02-09 5:39 ` Andrii Nakryiko
2022-02-09 2:17 ` [PATCH bpf-next v5 09/10] libbpf: Fix accessing the first syscall argument on arm64 Ilya Leoshkevich
2022-02-09 5:39 ` Andrii Nakryiko
2022-02-09 2:17 ` Ilya Leoshkevich [this message]
2022-02-09 5:39 ` [PATCH bpf-next v5 10/10] libbpf: Fix accessing the first syscall argument on s390 Andrii Nakryiko
2022-02-09 5:39 ` [PATCH bpf-next v5 00/10] Fix accessing syscall arguments Andrii Nakryiko
2022-02-09 5:40 ` patchwork-bot+netdevbpf
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=20220209021745.2215452-11-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=borntraeger@linux.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).