Skip to content

Commit 70b439e

Browse files
jones-drewPaul Walmsley
authored andcommitted
selftests: riscv: Bypass libc in inactive vector ptrace test
The ptrace_v_not_enabled test expects the child to reach its ebreak before it has used the vector extension. That is not guaranteed when using fork(), because libc may run child atfork handlers before returning to the test code. In those cases PTRACE_GETREGSET for NT_RISCV_VECTOR then succeeds instead of returning ENODATA for inactive vector state. Use the raw clone syscall with SIGCHLD to keep fork-like semantics while bypassing libc's fork wrapper and atfork handler chain. Cc: Andy Chiu <tchiu@tenstorrent.com> Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Andrew Jones <andrew.jones@oss.qualcomm.com> Link: https://patch.msgid.link/20260707153827.175245-1-andrew.jones@oss.qualcomm.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent 81bbcff commit 70b439e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

tools/testing/selftests/riscv/vector/validate_v_ptrace.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
#include <sys/ptrace.h>
3+
#include <sys/syscall.h>
34
#include <sys/types.h>
45
#include <sys/wait.h>
56
#include <sys/uio.h>
@@ -25,9 +26,9 @@ TEST(ptrace_v_not_enabled)
2526
SKIP(return, "Vector not supported");
2627

2728
chld_lock = 1;
28-
pid = fork();
29+
pid = (pid_t)syscall(SYS_clone, SIGCHLD, 0, NULL, 0, NULL);
2930
ASSERT_LE(0, pid)
30-
TH_LOG("fork: %m");
31+
TH_LOG("clone: %m");
3132

3233
if (pid == 0) {
3334
while (chld_lock == 1)

0 commit comments

Comments
 (0)