Skip to content

Commit 9ab9407

Browse files
Pu Lehuianakryiko
authored andcommitted
libbpf: Access first syscall argument with CO-RE direct read on arm64
Currently PT_REGS_PARM1 SYSCALL(x) is consistent with PT_REGS_PARM1_CORE SYSCALL(x), which will introduce the overhead of BPF_CORE_READ(), taking into account the read pt_regs comes directly from the context, let's use CO-RE direct read to access the first system call argument. Suggested-by: Andrii Nakryiko <[email protected]> Signed-off-by: Pu Lehui <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Xu Kuohai <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent e4db2a8 commit 9ab9407

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/lib/bpf/bpf_tracing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ struct pt_regs___s390 {
222222

223223
struct pt_regs___arm64 {
224224
unsigned long orig_x0;
225-
};
225+
} __attribute__((preserve_access_index));
226226

227227
/* arm64 provides struct user_pt_regs instead of struct pt_regs to userspace */
228228
#define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x))
@@ -241,7 +241,7 @@ struct pt_regs___arm64 {
241241
#define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG
242242
#define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG
243243
#define __PT_PARM6_SYSCALL_REG __PT_PARM6_REG
244-
#define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1_CORE_SYSCALL(x)
244+
#define PT_REGS_PARM1_SYSCALL(x) (((const struct pt_regs___arm64 *)(x))->__PT_PARM1_SYSCALL_REG)
245245
#define PT_REGS_PARM1_CORE_SYSCALL(x) \
246246
BPF_CORE_READ((const struct pt_regs___arm64 *)(x), __PT_PARM1_SYSCALL_REG)
247247

0 commit comments

Comments
 (0)