Hi Mark, On 2025-06-09 16:08:56+0100, Mark Brown wrote: > To allow testing of vfork() support in the arm64 basic-gcs test provide an > implementation for nolibc, using the vfork() syscall if one is available > and otherwise clone3(). We implement in terms of clone3() since the order > of the arguments for clone() varies between architectures.
Thanks for the patch! Do you want to take this series through your tree? > Signed-off-by: Mark Brown <broo...@kernel.org> > --- > tools/include/nolibc/sys.h | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h > index 9556c69a6ae1..e056da010f64 100644 > --- a/tools/include/nolibc/sys.h > +++ b/tools/include/nolibc/sys.h > @@ -22,6 +22,7 @@ > #include <linux/time.h> > #include <linux/auxvec.h> > #include <linux/fcntl.h> /* for O_* and AT_* */ > +#include <linux/sched.h> /* for clone_args */ > #include <linux/stat.h> /* for statx() */ > > #include "errno.h" > @@ -340,6 +341,34 @@ pid_t fork(void) > return __sysret(sys_fork()); > } > > +#ifndef sys_vfork > +static __attribute__((unused)) > +pid_t sys_vfork(void) > +{ > +#ifdef __NR_vfork > + return my_syscall0(__NR_vfork); > +#elif defined(__NR_clone3) > + /* > + * clone() could be used but has different argument orders per > + * architecture. > + */ > + struct clone_args args = { > + .flags = CLONE_VM | CLONE_VFORK, > + .exit_signal = SIGCHLD, > + }; > + > + return my_syscall2(__NR_clone3, &args, sizeof(args)); > +#else > + return __nolibc_enosys(__func__); > +#endif > +} > +#endif > + > +static __attribute__((unused)) > +pid_t vfork(void) > +{ > + return __sysret(sys_vfork()); > +} Could you also add a test to nolibc-test.c? Maybe extend test_fork() with a flag to use either fork() or vfork(). And maybe change the exit() in the test to _exit(); not that it would make a difference for nolibc (yet). > > /* > * int fsync(int fd); > > -- > 2.39.5 >