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@xxxxxxxxxxxxx> --- 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 --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] -- 2.34.1