mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +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]) \
|
||||
: "x0", "x1", "x2", "x3", "x8", "memory")
|
||||
|
||||
#define RUN_CLONE3_RESTORE_FN(ret, clone_args, size, args, \
|
||||
clone_restore_fn) do { \
|
||||
pr_err("This architecture does not support clone3() with set_tid, yet!\n"); \
|
||||
pr_err("Not creating a process with PID: %d\n", ((pid_t *)u64_to_ptr(clone_args.set_tid))[0]); \
|
||||
ret = -1; \
|
||||
} while (0)
|
||||
/*
|
||||
* 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, \
|
||||
clone_restore_fn) \
|
||||
asm volatile( \
|
||||
/* In contrast to the clone() wrapper above this does not put
|
||||
* the thread function and its arguments on the child stack,
|
||||
* 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 \
|
||||
asm volatile( \
|
||||
|
@@ -992,10 +992,10 @@ static bool kerndat_has_clone3_set_tid(void)
|
||||
pid_t pid;
|
||||
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
|
||||
* only implemented for X86_64, S390X and PPC64LE.
|
||||
* only implemented for X86_64, S390X, AARCH64 and PPC64LE.
|
||||
*/
|
||||
kdat.has_clone3_set_tid = false;
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user