Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: Access first syscall argument with CO-RE direct read on s390

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 <andrii@kernel.org>
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240831041934.1629216-2-pulehui@huaweicloud.com

authored by

Pu Lehui and committed by
Andrii Nakryiko
e4db2a82 eff5b5ff

+2 -2
+2 -2
tools/lib/bpf/bpf_tracing.h
··· 163 163 164 164 struct pt_regs___s390 { 165 165 unsigned long orig_gpr2; 166 - }; 166 + } __attribute__((preserve_access_index)); 167 167 168 168 /* s390 provides user_pt_regs instead of struct pt_regs to userspace */ 169 169 #define __PT_REGS_CAST(x) ((const user_pt_regs *)(x)) ··· 179 179 #define __PT_PARM4_SYSCALL_REG __PT_PARM4_REG 180 180 #define __PT_PARM5_SYSCALL_REG __PT_PARM5_REG 181 181 #define __PT_PARM6_SYSCALL_REG gprs[7] 182 - #define PT_REGS_PARM1_SYSCALL(x) PT_REGS_PARM1_CORE_SYSCALL(x) 182 + #define PT_REGS_PARM1_SYSCALL(x) (((const struct pt_regs___s390 *)(x))->__PT_PARM1_SYSCALL_REG) 183 183 #define PT_REGS_PARM1_CORE_SYSCALL(x) \ 184 184 BPF_CORE_READ((const struct pt_regs___s390 *)(x), __PT_PARM1_SYSCALL_REG) 185 185