Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests: riscv: Bypass libc in inactive vector ptrace test
@ 2026-07-07 15:38 Andrew Jones
  2026-07-08  7:16 ` Paul Walmsley
  2026-07-08  7:30 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Jones @ 2026-07-07 15:38 UTC (permalink / raw)
  To: linux-riscv, linux-kernel; +Cc: pjw, palmer, Andy Chiu

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>
---
 tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/riscv/vector/validate_v_ptrace.c b/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
index 74b6f6bcf067..b038e2175c80 100644
--- a/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
+++ b/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <sys/ptrace.h>
+#include <sys/syscall.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/uio.h>
@@ -25,9 +26,9 @@ TEST(ptrace_v_not_enabled)
 		SKIP(return, "Vector not supported");
 
 	chld_lock = 1;
-	pid = fork();
+	pid = (pid_t)syscall(SYS_clone, SIGCHLD, 0, NULL, 0, NULL);
 	ASSERT_LE(0, pid)
-		TH_LOG("fork: %m");
+		TH_LOG("clone: %m");
 
 	if (pid == 0) {
 		while (chld_lock == 1)
-- 
2.43.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests: riscv: Bypass libc in inactive vector ptrace test
  2026-07-07 15:38 [PATCH] selftests: riscv: Bypass libc in inactive vector ptrace test Andrew Jones
@ 2026-07-08  7:16 ` Paul Walmsley
  2026-07-08  7:30 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Walmsley @ 2026-07-08  7:16 UTC (permalink / raw)
  To: Andrew Jones; +Cc: linux-riscv, linux-kernel, pjw, palmer, Andy Chiu

On Tue, 7 Jul 2026, Andrew Jones wrote:

> 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>

Thanks, queued for v7.2-rc.

- Paul

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests: riscv: Bypass libc in inactive vector ptrace test
  2026-07-07 15:38 [PATCH] selftests: riscv: Bypass libc in inactive vector ptrace test Andrew Jones
  2026-07-08  7:16 ` Paul Walmsley
@ 2026-07-08  7:30 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-07-08  7:30 UTC (permalink / raw)
  To: Andrew Jones; +Cc: linux-riscv, linux-kernel, pjw, palmer, tchiu

Hello:

This patch was applied to riscv/linux.git (fixes)
by Paul Walmsley <pjw@kernel.org>:

On Tue,  7 Jul 2026 17:38:27 +0200 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - selftests: riscv: Bypass libc in inactive vector ptrace test
    https://git.kernel.org/riscv/c/70b439e46eff

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-08  7:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 15:38 [PATCH] selftests: riscv: Bypass libc in inactive vector ptrace test Andrew Jones
2026-07-08  7:16 ` Paul Walmsley
2026-07-08  7:30 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox