Skip to contentSkip to conversation

libbpf/selftests syscall wrapper fixes for RISC-V

PATCH Applied Björn Töpel 3 participants 6 messages Oct 4, 2023

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover libbpf/selftests syscall wrapper fixes for RISC-V

From: Björn Töpel <[email protected]>

Commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers") introduced some regressions in libbpf, and the kselftests BPF suite, which are fixed with these three patches.

Note that there's an outstanding fix [1] for ftrace syscall tracing which is also a fallout from the commit above.

Björn

[1] https://lore.kernel.org/linux-riscv/[email protected]/

Alexandre Ghiti (1):
libbpf: Fix syscall access arguments on riscv

Björn Töpel (2):
selftests/bpf: Define SYS_PREFIX for riscv selftests/bpf: Define SYS_NANOSLEEP_KPROBE_NAME for riscv

 tools/lib/bpf/bpf_tracing.h                  | 2 --
 tools/testing/selftests/bpf/progs/bpf_misc.h | 3 +++
 tools/testing/selftests/bpf/test_progs.h     | 2 ++
 3 files changed, 5 insertions(+), 2 deletions(-)

base-commit: 9077fc228f09c9f975c498c55f5d2e882cd0da59

Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/3 libbpf: Fix syscall access arguments on riscv

From: Alexandre Ghiti <[email protected]>

Since commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers"), riscv selects ARCH_HAS_SYSCALL_WRAPPER so let's use the generic implementation of PT_REGS_SYSCALL_REGS().

Fixes 08d0ce30e0e4 ("riscv: Implement syscall wrappers")
---
 tools/lib/bpf/bpf_tracing.h | 2 --
 1 file changed, 2 deletions(-)
tools/lib/bpf/bpf_tracing.h +0 -2
index 3803479dbe10..1c13f8e88833 100644
@@ -362,8 +362,6 @@ struct pt_regs___arm64 {
 #define __PT_PARM7_REG a6
 #define __PT_PARM8_REG a7
 
-/* riscv does not select ARCH_HAS_SYSCALL_WRAPPER. */
-#define PT_REGS_SYSCALL_REGS(ctx) ctx
 #define __PT_PARM1_SYSCALL_REG __PT_PARM1_REG
 #define __PT_PARM2_SYSCALL_REG __PT_PARM2_REG
 #define __PT_PARM3_SYSCALL_REG __PT_PARM3_REG
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/3 selftests/bpf: Define SYS_PREFIX for riscv

In reply to Björn Töpel

From: Björn Töpel <[email protected]>

SYS_PREFIX was missing for a RISC-V, which made a couple of kprobe tests fail.

Add missing SYS_PREFIX for RISC-V.

Fixes 08d0ce30e0e4 ("riscv: Implement syscall wrappers")
---
 tools/testing/selftests/bpf/progs/bpf_misc.h | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/bpf/progs/bpf_misc.h +3 -0
index 38a57a2e70db..799fff4995d8 100644
@@ -99,6 +99,9 @@
 #elif defined(__TARGET_ARCH_arm64)
 #define SYSCALL_WRAPPER 1
 #define SYS_PREFIX "__arm64_"
+#elif defined(__TARGET_ARCH_riscv)
+#define SYSCALL_WRAPPER 1
+#define SYS_PREFIX "__riscv_"
 #else
 #define SYSCALL_WRAPPER 0
 #define SYS_PREFIX "__se_"
Signature · 1 line
2.39.2
#3 lore raw

PATCH 3/3 selftests/bpf: Define SYS_NANOSLEEP_KPROBE_NAME for riscv

In reply to Björn Töpel

From: Björn Töpel <[email protected]>

Add missing sys_nanosleep name for RISC-V, which is used by some tests (e.g. attach_probe).

Fixes 08d0ce30e0e4 ("riscv: Implement syscall wrappers")
---
 tools/testing/selftests/bpf/test_progs.h | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/bpf/test_progs.h +2 -0
index 77bd492c6024..2f9f6f250f17 100644
@@ -417,6 +417,8 @@ int get_bpf_max_tramp_links(void);
 #define SYS_NANOSLEEP_KPROBE_NAME "__s390x_sys_nanosleep"
 #elif defined(__aarch64__)
 #define SYS_NANOSLEEP_KPROBE_NAME "__arm64_sys_nanosleep"
+#elif defined(__riscv)
+#define SYS_NANOSLEEP_KPROBE_NAME "__riscv_sys_nanosleep"
 #else
 #define SYS_NANOSLEEP_KPROBE_NAME "sys_nanosleep"
 #endif
Signature · 1 line
2.39.2
#5 lore raw
In reply to Björn Töpel
This series was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This series was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 10 lines · On Wed, 4 Oct 2023 13:09:02 +0200 you wrote:

From: Björn Töpel <[email protected]>

Commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers") introduced some regressions in libbpf, and the kselftests BPF suite, which are fixed with these three patches.

Note that there's an outstanding fix [1] for ftrace syscall tracing which is also a fallout from the commit above.

[...]

Here is the summary with links:
- [bpf,1/3] libbpf: Fix syscall access arguments on riscv

    https://git.kernel.org/bpf/bpf-next/c/8a412c5c1cd6
  - [bpf,2/3] selftests/bpf: Define SYS_PREFIX for riscv
    https://git.kernel.org/bpf/bpf-next/c/0f2692ee4324
  - [bpf,3/3] selftests/bpf: Define SYS_NANOSLEEP_KPROBE_NAME for riscv
    https://git.kernel.org/bpf/bpf-next/c/b55b775f0316

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html