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

Configure Feed

Select the types of activity you want to include in your feed.

tools/nolibc: align sys_vfork() with sys_fork()

Currently the generic variants of sys_fork() and sys_vfork() differ in
both they precedence of used system calls and the usage of sys_clone()
vs sys_clone3(). While the interface of clone3() in sys_vfork() is more
consistent over different architectures, qemu-user does not support it,
making testing harder. We already handle the different clone()
interfaces for sys_fork() in the architecture-specific headers, and can
do so also for sys_vfork(). In fact SPARC already has such handling and
only s390 is currently missing.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260104-nolibc-vfork-v1-1-a63464b9e4e6@weissschuh.net

+13 -13
+8
tools/include/nolibc/arch-s390.h
··· 8 8 9 9 #include "types.h" 10 10 11 + #include <linux/sched.h> 11 12 #include <linux/signal.h> 12 13 #include <linux/unistd.h> 13 14 ··· 189 188 return my_syscall5(__NR_clone, 0, SIGCHLD, 0, 0, 0); 190 189 } 191 190 #define sys_fork sys_fork 191 + 192 + static __attribute__((unused)) 193 + pid_t sys_vfork(void) 194 + { 195 + return my_syscall5(__NR_clone, 0, CLONE_VM | CLONE_VFORK | SIGCHLD, 0, 0, 0); 196 + } 197 + #define sys_vfork sys_vfork 192 198 193 199 #endif /* _NOLIBC_ARCH_S390_H */
+5 -13
tools/include/nolibc/sys.h
··· 22 22 #include <linux/time.h> 23 23 #include <linux/auxvec.h> 24 24 #include <linux/fcntl.h> /* for O_* and AT_* */ 25 - #include <linux/sched.h> /* for clone_args */ 25 + #include <linux/sched.h> /* for CLONE_* */ 26 26 #include <linux/stat.h> /* for statx() */ 27 27 28 28 #include "errno.h" ··· 363 363 static __attribute__((unused)) 364 364 pid_t sys_vfork(void) 365 365 { 366 - #if defined(__NR_vfork) 366 + #if defined(__NR_clone) 367 + /* See the note in sys_fork(). */ 368 + return my_syscall5(__NR_clone, CLONE_VM | CLONE_VFORK | SIGCHLD, 0, 0, 0, 0); 369 + #elif defined(__NR_vfork) 367 370 return my_syscall0(__NR_vfork); 368 - #else 369 - /* 370 - * clone() could be used but has different argument orders per 371 - * architecture. 372 - */ 373 - struct clone_args args = { 374 - .flags = CLONE_VM | CLONE_VFORK, 375 - .exit_signal = SIGCHLD, 376 - }; 377 - 378 - return my_syscall2(__NR_clone3, &args, sizeof(args)); 379 371 #endif 380 372 } 381 373 #endif