diff mbox series

[bpf-next,v4,07/14] selftests/bpf: Use PT_REGS_SYSCALL_REGS in bpf_syscall_macro

Message ID 20220208051635.2160304-8-iii@linux.ibm.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series Fix accessing syscall arguments | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail PR summary
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 10 maintainers not CCed: andrii@kernel.org Kenta.Tada@sony.com linux-kselftest@vger.kernel.org kpsingh@kernel.org john.fastabend@gmail.com kafai@fb.com shuah@kernel.org songliubraving@fb.com yhs@fb.com netdev@vger.kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next fail VM_Test

Commit Message

Ilya Leoshkevich Feb. 8, 2022, 5:16 a.m. UTC
Ensure that PT_REGS_SYSCALL_REGS works correctly, and also remove some
duplication.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tools/testing/selftests/bpf/progs/bpf_misc.h              | 4 ----
 .../selftests/bpf/progs/bpf_syscall_macro_common.h        | 2 +-
 tools/testing/selftests/bpf/progs/test_probe_user.c       | 8 +-------
 3 files changed, 2 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
index 5bb11fe595a4..9f2937b5e819 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -3,16 +3,12 @@ 
 #define __BPF_MISC_H__
 
 #if defined(__TARGET_ARCH_x86)
-#define SYSCALL_WRAPPER 1
 #define SYS_PREFIX "__x64_"
 #elif defined(__TARGET_ARCH_s390)
-#define SYSCALL_WRAPPER 1
 #define SYS_PREFIX "__s390x_"
 #elif defined(__TARGET_ARCH_arm64)
-#define SYSCALL_WRAPPER 1
 #define SYS_PREFIX "__arm64_"
 #else
-#define SYSCALL_WRAPPER 0
 #define SYS_PREFIX "__se_"
 #endif
 
diff --git a/tools/testing/selftests/bpf/progs/bpf_syscall_macro_common.h b/tools/testing/selftests/bpf/progs/bpf_syscall_macro_common.h
index 8717605358d3..95c2f1904f81 100644
--- a/tools/testing/selftests/bpf/progs/bpf_syscall_macro_common.h
+++ b/tools/testing/selftests/bpf/progs/bpf_syscall_macro_common.h
@@ -31,7 +31,7 @@  int BPF_KPROBE(handle_sys_prctl)
 	if (pid != filter_pid)
 		return 0;
 
-	real_regs = (struct pt_regs *)PT_REGS_PARM1(ctx);
+	real_regs = PT_REGS_SYSCALL_REGS(ctx);
 
 	/* test for PT_REGS_PARM */
 
diff --git a/tools/testing/selftests/bpf/progs/test_probe_user.c b/tools/testing/selftests/bpf/progs/test_probe_user.c
index 702578a5e496..b2531f587c87 100644
--- a/tools/testing/selftests/bpf/progs/test_probe_user.c
+++ b/tools/testing/selftests/bpf/progs/test_probe_user.c
@@ -14,18 +14,12 @@  static struct sockaddr_in old;
 SEC("kprobe/" SYS_PREFIX "sys_connect")
 int BPF_KPROBE(handle_sys_connect)
 {
-#if SYSCALL_WRAPPER == 1
 	struct pt_regs *real_regs;
-#endif
 	struct sockaddr_in new;
 	void *ptr;
 
-#if SYSCALL_WRAPPER == 0
-	ptr = (void *)PT_REGS_PARM2(ctx);
-#else
-	real_regs = (struct pt_regs *)PT_REGS_PARM1(ctx);
+	real_regs = PT_REGS_SYSCALL_REGS(ctx);
 	bpf_probe_read_kernel(&ptr, sizeof(ptr), &PT_REGS_PARM2(real_regs));
-#endif
 
 	bpf_probe_read_user(&old, sizeof(old), ptr);
 	__builtin_memset(&new, 0xab, sizeof(new));