mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 14:55:39 +00:00
aarch64: use clone3() if possible
This adds the parasite clone3() with set_tid wrapper for aarch64. Tested on Fedora 31 with 5.5.0-rc6. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
committed by
Andrei Vagin
parent
3dabd38a82
commit
f991f23506
@@ -42,12 +42,67 @@
|
|||||||
"r"(&thread_args[i]) \
|
"r"(&thread_args[i]) \
|
||||||
: "x0", "x1", "x2", "x3", "x8", "memory")
|
: "x0", "x1", "x2", "x3", "x8", "memory")
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Based on sysdeps/unix/sysv/linux/aarch64/clone.S
|
||||||
|
*
|
||||||
|
* int clone(int (*fn)(void *arg), x0
|
||||||
|
* void *child_stack, x1
|
||||||
|
* int flags, x2
|
||||||
|
* void *arg, x3
|
||||||
|
* pid_t *ptid, x4
|
||||||
|
* struct user_desc *tls, x5
|
||||||
|
* pid_t *ctid); x6
|
||||||
|
*
|
||||||
|
* int clone3(struct clone_args *args, x0
|
||||||
|
* size_t size); x1
|
||||||
|
*
|
||||||
|
* Always consult the CLONE3 wrappers for other architectures
|
||||||
|
* for additional details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#define RUN_CLONE3_RESTORE_FN(ret, clone_args, size, args, \
|
#define RUN_CLONE3_RESTORE_FN(ret, clone_args, size, args, \
|
||||||
clone_restore_fn) do { \
|
clone_restore_fn) \
|
||||||
pr_err("This architecture does not support clone3() with set_tid, yet!\n"); \
|
asm volatile( \
|
||||||
pr_err("Not creating a process with PID: %d\n", ((pid_t *)u64_to_ptr(clone_args.set_tid))[0]); \
|
/* In contrast to the clone() wrapper above this does not put
|
||||||
ret = -1; \
|
* the thread function and its arguments on the child stack,
|
||||||
} while (0)
|
* but uses registers to pass these parameters to the child process.
|
||||||
|
* Based on the glibc clone() wrapper at
|
||||||
|
* sysdeps/unix/sysv/linux/aarch64/clone.S.
|
||||||
|
*/ \
|
||||||
|
"clone3_emul: \n" \
|
||||||
|
/*
|
||||||
|
* Based on the glibc clone() wrapper, which uses x10 and x11
|
||||||
|
* to save the arguments for the child process, this does the same.
|
||||||
|
* x10 for the thread function and x11 for the thread arguments.
|
||||||
|
*/ \
|
||||||
|
"mov x10, %3 /* clone_restore_fn */ \n" \
|
||||||
|
"mov x11, %4 /* args */ \n" \
|
||||||
|
"mov x0, %1 /* &clone_args */ \n" \
|
||||||
|
"mov x1, %2 /* size */ \n" \
|
||||||
|
/* Load syscall number */ \
|
||||||
|
"mov x8, #"__stringify(__NR_clone3)" \n" \
|
||||||
|
/* Do the syscall */ \
|
||||||
|
"svc #0 \n" \
|
||||||
|
\
|
||||||
|
"cbz x0, clone3_thread_run \n" \
|
||||||
|
\
|
||||||
|
"mov %0, x0 \n" \
|
||||||
|
"b clone3_end \n" \
|
||||||
|
\
|
||||||
|
"clone3_thread_run: \n" \
|
||||||
|
/* Move args to x0 */ \
|
||||||
|
"mov x0, x11 \n" \
|
||||||
|
/* Jump to clone_restore_fn */ \
|
||||||
|
"br x10 \n" \
|
||||||
|
\
|
||||||
|
"clone3_end: \n" \
|
||||||
|
: "=r"(ret) \
|
||||||
|
: "r"(&clone_args), \
|
||||||
|
"r"(size), \
|
||||||
|
"r"(clone_restore_fn), \
|
||||||
|
"r"(args) \
|
||||||
|
: "x0", "x1", "x8", "x10", "x11", "memory")
|
||||||
|
|
||||||
#define ARCH_FAIL_CORE_RESTORE \
|
#define ARCH_FAIL_CORE_RESTORE \
|
||||||
asm volatile( \
|
asm volatile( \
|
||||||
|
@@ -992,10 +992,10 @@ static bool kerndat_has_clone3_set_tid(void)
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
struct _clone_args args = {};
|
struct _clone_args args = {};
|
||||||
|
|
||||||
#if !defined(CONFIG_X86_64) && !defined(CONFIG_S390) && !defined(CONFIG_PPC64)
|
#if !defined(CONFIG_X86_64) && !defined(CONFIG_S390) && !defined(CONFIG_PPC64) && !defined(CONFIG_AARCH64)
|
||||||
/*
|
/*
|
||||||
* Currently the CRIU PIE assembler clone3() wrapper is
|
* Currently the CRIU PIE assembler clone3() wrapper is
|
||||||
* only implemented for X86_64, S390X and PPC64LE.
|
* only implemented for X86_64, S390X, AARCH64 and PPC64LE.
|
||||||
*/
|
*/
|
||||||
kdat.has_clone3_set_tid = false;
|
kdat.has_clone3_set_tid = false;
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user