1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef _CLONE3_SELFTESTS_H
4 #define _CLONE3_SELFTESTS_H
8 #include <linux/sched.h>
9 #include <linux/types.h>
14 #include "../kselftest.h"
16 #define ptr_to_u64(ptr) ((__u64)((uintptr_t)(ptr)))
19 #define __NR_clone3 -1
25 __aligned_u64 child_tid
;
26 __aligned_u64 parent_tid
;
27 __aligned_u64 exit_signal
;
29 __aligned_u64 stack_size
;
31 __aligned_u64 set_tid
;
32 __aligned_u64 set_tid_size
;
36 static pid_t
sys_clone3(struct __clone_args
*args
, size_t size
)
40 return syscall(__NR_clone3
, args
, size
);
43 static inline void test_clone3_supported(void)
46 struct __clone_args args
= {};
49 ksft_exit_skip("clone3() syscall is not supported\n");
51 /* Set to something that will always cause EINVAL. */
52 args
.exit_signal
= -1;
53 pid
= sys_clone3(&args
, sizeof(args
));
60 "Managed to create child process with invalid exit_signal\n");
64 ksft_exit_skip("clone3() syscall is not supported\n");
66 ksft_print_msg("clone3() syscall supported\n");
69 #endif /* _CLONE3_SELFTESTS_H */