diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2013-07-16 18:44:57 +0100 |
---|---|---|
committer | Riku Voipio <riku.voipio@linaro.org> | 2013-07-22 21:54:36 +0300 |
commit | 4ce6243dc6216e35b5b691078ffa856463bfa8db (patch) | |
tree | 766e18e8257a50fa1aead446fe6178be9b9c4f56 /linux-user/syscall.c | |
parent | d312bbe1051fa563b557de625ca57a466772abe5 (diff) | |
download | qemu-4ce6243dc6216e35b5b691078ffa856463bfa8db.zip qemu-4ce6243dc6216e35b5b691078ffa856463bfa8db.tar.gz qemu-4ce6243dc6216e35b5b691078ffa856463bfa8db.tar.bz2 |
linux-user: Clean up handling of clone() argument order
Linux manages to have three separate orderings of the arguments to
the clone() syscall on different architectures. In the kernel these
are selected via CONFIG_CLONE_BACKWARDS and CONFIG_CLONE_BACKWARDS2.
Clean up our implementation of this to use similar #define names
rather than a TARGET_* ifdef ladder.
This includes behaviour changes fixing bugs on cris, x86-64, m68k,
openrisc and unicore32. cris had explicit but wrong handling; the
others were just incorrectly using QEMU's default, which happened
to be the equivalent of CONFIG_CLONE_BACKWARDS. (unicore32 appears
to be broken in the mainline kernel in that it tries to use arg3 for
both parent_tidptr and newtls simultaneously -- we don't attempt
to emulate this bug...)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r-- | linux-user/syscall.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 642d0a3..b167d7f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6956,16 +6956,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(fsync(arg1)); break; case TARGET_NR_clone: -#if defined(TARGET_SH4) || defined(TARGET_ALPHA) - ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); -#elif defined(TARGET_CRIS) - ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5)); -#elif defined(TARGET_MICROBLAZE) + /* Linux manages to have three different orderings for its + * arguments to clone(); the BACKWARDS and BACKWARDS2 defines + * match the kernel's CONFIG_CLONE_* settings. + * Microblaze is further special in that it uses a sixth + * implicit argument to clone for the TLS pointer. + */ +#if defined(TARGET_MICROBLAZE) ret = get_errno(do_fork(cpu_env, arg1, arg2, arg4, arg6, arg5)); -#elif defined(TARGET_S390X) +#elif defined(TARGET_CLONE_BACKWARDS) + ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5)); +#elif defined(TARGET_CLONE_BACKWARDS2) ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg5, arg4)); #else - ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5)); + ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); #endif break; #ifdef __NR_exit_group |