compel, x86_64: Fix sys_clone() definition

Submitted by Kirill Tkhai on June 27, 2017, 11:21 a.m.

Details

Message ID 149856248734.30851.3263628819948178471.stgit@localhost.localdomain
State Accepted
Series "compel, x86_64: Fix sys_clone() definition"
Commit bdba5d04993688328d43077e78328bacc2541de8
Headers show

Commit Message

Kirill Tkhai June 27, 2017, 11:21 a.m.
Commit 37e4c7bfc264 fixed arm, ppc, x86 (32bit),
while it made wrong definition of x86_64. Fix that.

Also, add commentary to raw fork() implementation.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 .../arch/x86/plugins/std/syscalls/syscall_64.tbl   |    2 +-
 criu/util.c                                        |    6 +++++-
 test/zdtm/lib/test.c                               |    6 +++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
index e1c198929..c414c63e3 100644
--- a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
@@ -37,7 +37,7 @@  __NR_shutdown			48		sys_shutdown		(int sockfd, int how)
 __NR_bind			49		sys_bind		(int sockfd, const struct sockaddr *addr, int addrlen)
 __NR_setsockopt			54		sys_setsockopt		(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
 __NR_getsockopt			55		sys_getsockopt		(int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
-__NR_clone			56		sys_clone		(unsigned long flags, void *child_stack, void *parent_tid, unsigned long newtls, void *child_tid)
+__NR_clone			56		sys_clone		(unsigned long flags, void *child_stack, void *parent_tid, void *child_tid, unsigned long new_tls)
 __NR_exit			60		sys_exit		(unsigned long error_code)
 __NR_wait4			61		sys_wait4		(int pid, int *status, int options, struct rusage *ru)
 __NR_kill			62		sys_kill		(long pid, int sig)
diff --git a/criu/util.c b/criu/util.c
index 224e66fb0..6c55b13c1 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -1428,5 +1428,9 @@  int getpid()
  */
 pid_t fork()
 {
-	return (pid_t)syscall(__NR_clone, SIGCHLD, 0, NULL, 0, NULL);
+	/*
+	 * Two last arguments are swapped on different archs,
+	 * but we don't care as they are zero anyway.
+	 */
+	return (pid_t)syscall(__NR_clone, SIGCHLD, 0, 0, 0, 0);
 }
diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
index 52ee86219..76357da01 100644
--- a/test/zdtm/lib/test.c
+++ b/test/zdtm/lib/test.c
@@ -288,7 +288,11 @@  void test_waitsig(void)
 
 pid_t fork()
 {
-	return (pid_t)syscall(__NR_clone, SIGCHLD, 0, NULL, 0, NULL);
+	/*
+	 * Two last arguments are swapped on different archs,
+	 * but we don't care as they are zero anyway.
+	 */
+	return (pid_t)syscall(__NR_clone, SIGCHLD, 0, 0, 0, 0);
 }
 
 int getpid()

Comments

Andrey Vagin June 27, 2017, 10:39 p.m.
Applied, thanks

On Tue, Jun 27, 2017 at 02:21:44PM +0300, Kirill Tkhai wrote:
> Commit 37e4c7bfc264 fixed arm, ppc, x86 (32bit),
> while it made wrong definition of x86_64. Fix that.
> 
> Also, add commentary to raw fork() implementation.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  .../arch/x86/plugins/std/syscalls/syscall_64.tbl   |    2 +-
>  criu/util.c                                        |    6 +++++-
>  test/zdtm/lib/test.c                               |    6 +++++-
>  3 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
> index e1c198929..c414c63e3 100644
> --- a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
> +++ b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
> @@ -37,7 +37,7 @@ __NR_shutdown			48		sys_shutdown		(int sockfd, int how)
>  __NR_bind			49		sys_bind		(int sockfd, const struct sockaddr *addr, int addrlen)
>  __NR_setsockopt			54		sys_setsockopt		(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
>  __NR_getsockopt			55		sys_getsockopt		(int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
> -__NR_clone			56		sys_clone		(unsigned long flags, void *child_stack, void *parent_tid, unsigned long newtls, void *child_tid)
> +__NR_clone			56		sys_clone		(unsigned long flags, void *child_stack, void *parent_tid, void *child_tid, unsigned long new_tls)
>  __NR_exit			60		sys_exit		(unsigned long error_code)
>  __NR_wait4			61		sys_wait4		(int pid, int *status, int options, struct rusage *ru)
>  __NR_kill			62		sys_kill		(long pid, int sig)
> diff --git a/criu/util.c b/criu/util.c
> index 224e66fb0..6c55b13c1 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -1428,5 +1428,9 @@ int getpid()
>   */
>  pid_t fork()
>  {
> -	return (pid_t)syscall(__NR_clone, SIGCHLD, 0, NULL, 0, NULL);
> +	/*
> +	 * Two last arguments are swapped on different archs,
> +	 * but we don't care as they are zero anyway.
> +	 */
> +	return (pid_t)syscall(__NR_clone, SIGCHLD, 0, 0, 0, 0);
>  }
> diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
> index 52ee86219..76357da01 100644
> --- a/test/zdtm/lib/test.c
> +++ b/test/zdtm/lib/test.c
> @@ -288,7 +288,11 @@ void test_waitsig(void)
>  
>  pid_t fork()
>  {
> -	return (pid_t)syscall(__NR_clone, SIGCHLD, 0, NULL, 0, NULL);
> +	/*
> +	 * Two last arguments are swapped on different archs,
> +	 * but we don't care as they are zero anyway.
> +	 */
> +	return (pid_t)syscall(__NR_clone, SIGCHLD, 0, 0, 0, 0);
>  }
>  
>  int getpid()
>