Andrii says: "... with CO-RE and vmlinux.h it would be more reliable and straightforward to just stick to kernel-internal struct pt_regs everywhere ...". Actually, if vmlinux.h is available, then it's ok to do so for both CO-RE and non-CO-RE cases, since the beginning of struct pt_regs must match (struct) user_pt_regs, which must never change. Implement this by not defining __PT_REGS_CAST if the user included vmlinux.h. Signed-off-by: Ilya Leoshkevich <iii@xxxxxxxxxxxxx> --- tools/lib/bpf/bpf_tracing.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index 7a015ee8fb11..07e291d77e83 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -118,8 +118,11 @@ #define __BPF_ARCH_HAS_SYSCALL_WRAPPER +#if !defined(__KERNEL__) && !defined(__VMLINUX_H__) /* s390 provides user_pt_regs instead of struct pt_regs to userspace */ #define __PT_REGS_CAST(x) ((const user_pt_regs *)(x)) +#endif + #define __PT_PARM1_REG gprs[2] #define __PT_PARM2_REG gprs[3] #define __PT_PARM3_REG gprs[4] @@ -148,8 +151,11 @@ #define __BPF_ARCH_HAS_SYSCALL_WRAPPER +#if !defined(__KERNEL__) && !defined(__VMLINUX_H__) /* arm64 provides struct user_pt_regs instead of struct pt_regs to userspace */ #define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x)) +#endif + #define __PT_PARM1_REG regs[0] #define __PT_PARM2_REG regs[1] #define __PT_PARM3_REG regs[2] @@ -207,7 +213,10 @@ #elif defined(bpf_target_riscv) +#if !defined(__KERNEL__) && !defined(__VMLINUX_H__) #define __PT_REGS_CAST(x) ((const struct user_regs_struct *)(x)) +#endif + #define __PT_PARM1_REG a0 #define __PT_PARM2_REG a1 #define __PT_PARM3_REG a2 -- 2.34.1