@@ -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;
@@ -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;
};
@@ -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]
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(-)