Skip to content

Commit

Permalink
libbpf: Fix use of PT_REGS_PARM macros with vmlinux.h
Browse files Browse the repository at this point in the history
Add detection of vmlinux.h to bpf_tracing.h header for PT_REGS macro.
Currently, BPF applications have to define __KERNEL__ symbol to use correct
definition of struct pt_regs on x86 arch. This is due to different field names
under internal kernel vs UAPI conditions. To make this more transparent for
users, detect vmlinux.h by checking __VMLINUX_H__ symbol.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200229231112.1240137-3-andriin@fb.com
  • Loading branch information
Andrii Nakryiko authored and Alexei Starovoitov committed Mar 3, 2020
1 parent ca7dc27 commit fd56e00
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/lib/bpf/bpf_tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

#if defined(bpf_target_x86)

#ifdef __KERNEL__
#if defined(__KERNEL__) || defined(__VMLINUX_H__)
#define PT_REGS_PARM1(x) ((x)->di)
#define PT_REGS_PARM2(x) ((x)->si)
#define PT_REGS_PARM3(x) ((x)->dx)
Expand Down

0 comments on commit fd56e00

Please sign in to comment.