diff mbox series

[bpf-next,2/2] arm64/bpf: Introduce struct user_pt_regs_v2

Message ID 20220206145350.2069779-3-iii@linux.ibm.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series Fix bpf_perf_event_data ABI breakage | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: andrii@kernel.org; 10 maintainers not CCed: andrii@kernel.org kpsingh@kernel.org linux-arm-kernel@lists.infradead.org john.fastabend@gmail.com kafai@fb.com songliubraving@fb.com yhs@fb.com oleg@redhat.com netdev@vger.kernel.org will@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR fail merge-conflict

Commit Message

Ilya Leoshkevich Feb. 6, 2022, 2:53 p.m. UTC
Extending struct user_pt_regs breaks struct bpf_perf_event_data ABI, so
instead of exposing orig_x0 through it, create its copy with orig_x0 at
the end and use it in libbpf.

The existing members are copy-pasted, so now there are 3 copies in
total. It might be tempting to add a user_pt_regs member to
user_pt_regs_v2 instead, however, there is no guarantee that then
user_pt_regs_v2.orig_x0 would be at the same offset as
pt_regs.orig_gpr2.

Fixes: d473f4062165 ("arm64/bpf: Add orig_x0 to user_pt_regs")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 arch/arm64/include/asm/ptrace.h      | 1 +
 arch/arm64/include/uapi/asm/ptrace.h | 7 +++++++
 tools/lib/bpf/bpf_tracing.h          | 6 ++++--
 3 files changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index 1be22f7870f8..c5e098af5b70 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -178,6 +178,7 @@  static inline unsigned long pstate_to_compat_psr(const unsigned long pstate)
 struct pt_regs {
 	union {
 		struct user_pt_regs user_regs;
+		struct user_pt_regs_v2 user_regs_v2;
 		struct {
 			u64 regs[31];
 			u64 sp;
diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h
index 3c118c5b0893..ab7a2f0cdca8 100644
--- a/arch/arm64/include/uapi/asm/ptrace.h
+++ b/arch/arm64/include/uapi/asm/ptrace.h
@@ -90,6 +90,13 @@  struct user_pt_regs {
 	__u64		sp;
 	__u64		pc;
 	__u64		pstate;
+};
+
+struct user_pt_regs_v2 {
+	__u64		regs[31];
+	__u64		sp;
+	__u64		pc;
+	__u64		pstate;
 	__u64		orig_x0;
 };
 
diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h
index 76abbc5ff2e8..284cc4d6954e 100644
--- a/tools/lib/bpf/bpf_tracing.h
+++ b/tools/lib/bpf/bpf_tracing.h
@@ -143,8 +143,10 @@ 
 
 #elif defined(bpf_target_arm64)
 
-/* arm64 provides struct user_pt_regs instead of struct pt_regs to userspace */
-#define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x))
+/*
+ * arm64 provides struct user_pt_regs_v2 instead of struct pt_regs to userspace
+ */
+#define __PT_REGS_CAST(x) ((const struct user_pt_regs_v2 *)(x))
 #define __PT_PARM1_REG regs[0]
 #define __PT_PARM1_REG_SYSCALL orig_x0
 #define __PT_PARM2_REG regs[1]