Skip to contentSkip to conversation

user-cr: update to eclone API; add nsexeccwp

PATCH In review Nathan Lynch 3 participants 16 messages Nov 18, 2009 – Nov 25, 2009 6 messages not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

cover user-cr: update to eclone API; add nsexeccwp

The following series adds support for eclone to the arch code, introduces the nsexeccwp utility which allows for isolated testing of eclone's pid-choosing capability, switches the restart utility to eclone, and finally phases out the clone_with_pids support code.

I've verified that nsexeccwp works correctly on x86 and powerpc with a mainline kernel with eclone support (but not checkpoint/restart); s390 needs to be built and tested (Serge?).

Based on ckpt-v19-rc1.

Nathan Lynch (8):
user-cr: add eclone/clone_args header
user-cr: x86_32 eclone wrapper
user-cr: s390 eclone wrapper
user-cr: ppc32 eclone wrapper
user-cr: use eclone API for restart
user-cr: remove x86_32 clone_with_pids
user-cr: remove s390 clone_with_pids
user-cr: remove powerpc clone_with_pids

Serge E. Hallyn (1):
user-cr: add nsexeccwp to test eclone

 Makefile       |    5 +-
 clone.h        |   54 +++++++++
 clone_ppc.c    |   58 ++++++-----
 clone_ppc_.S   |   52 +++++-----
 clone_s390x.c  |   97 ++++++++++-------
 clone_x86_32.c |   87 ++++++++-------
 eclone.h       |   25 +++++
 nsexeccwp.c    |  329 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 restart.c      |   46 +++------
 9 files changed, 588 insertions(+), 165 deletions(-)
 create mode 100644 clone.h
 create mode 100644 eclone.h
 create mode 100644 nsexeccwp.c
#2 lore raw

PATCH 1/9 user-cr: add eclone/clone_args header

In reply to a message not in the archive

Declare these interfaces which will replace clone_with_pids.

---
 eclone.h |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 eclone.h
eclone.h new file +25 -0
new file mode 100644
index 0000000..601a621
@@ -0,0 +1,25 @@
+#ifndef _ECLONE_H_
+#define _ECLONE_H_
+
+#include <stdint.h>
+
+struct clone_args {
+	uint64_t clone_flags_high;
+	uint64_t child_stack;
+	uint64_t child_stack_size;
+	uint64_t parent_tid_ptr;
+	uint64_t child_tid_ptr;
+
+	uint32_t nr_pids;
+
+	uint32_t reserved0;
+	uint64_t reserved1;
+};
+
+/* arch-dependent code implements this interface */
+extern int eclone(int (*fn)(void *), void *fn_arg,
+		  int clone_flags_low,
+		  struct clone_args *clone_args,
+		  pid_t *pids);
+
+#endif
Signature · 1 line
1.6.2.5
#3 lore raw

PATCH 2/9 user-cr: x86_32 eclone wrapper

In reply to a message not in the archive
---
 clone_x86_32.c |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)
clone_x86_32.c +65 -0
index 8ab3c3e..61b593c 100644
@@ -81,3 +81,68 @@ int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
 }
 
 #endif
+
+#include "eclone.h"
+
+#ifndef __NR_eclone
+#define __NR_eclone 337
+#endif
+
+int eclone(int (*fn)(void *), void *fn_arg, int clone_flags_low,
+	   struct clone_args *clone_args, pid_t *pids)
+{
+	struct clone_args my_args;
+	long retval;
+	void **newstack;
+
+	if (clone_args->child_stack) {
+		/*
+		 * Set up the stack for child:
+		 *  - fn_arg will be the argument for the child function
+		 *  - the fn pointer will be loaded into ebx after the clone
+		 */
+		newstack = (void **)(unsigned long)(clone_args->child_stack +
+					    clone_args->child_stack_size);
+		*--newstack = fn_arg;
+		*--newstack = fn;
+	} else
+		newstack = (void **)0;
+
+	my_args = *clone_args;
+	my_args.child_stack = (unsigned long)newstack;
+	my_args.child_stack_size = 0;
+
+	__asm__	 __volatile__(
+		"movl %0, %%ebx\n\t"	       /* flags -> 1st (ebx) */
+		"movl %1, %%ecx\n\t"	       /* clone_args -> 2nd (ecx) */
+		"movl %2, %%edx\n\t"	       /* args_size -> 3rd (edx) */
+		"movl %3, %%edi\n\t"	       /* pids -> 4th (edi) */
+		"pushl %%ebp\n\t"	       /* save value of ebp */
+		:
+		:"b" (clone_flags_low),
+		 "c" (&my_args),
+		 "d" (sizeof(my_args)),
+		 "D" (pids)
+		);
+
+	__asm__ __volatile__(
+		"int $0x80\n\t"	       /* Linux/i386 system call */
+		"testl %0,%0\n\t"      /* check return value */
+		"jne 1f\n\t"	       /* jump if parent */
+		"popl %%ebx\n\t"       /* get subthread function */
+		"call *%%ebx\n\t"      /* start subthread function */
+		"movl %2,%0\n\t"
+		"int $0x80\n"	       /* exit system call: exit subthread */
+		"1:\n\t"
+		"popl %%ebp\t"	       /* restore parent's ebp */
+		:"=a" (retval)
+		:"0" (__NR_eclone), "i" (__NR_exit)
+		:"ebx", "ecx"
+		);
+
+	if (retval < 0) {
+		errno = -retval;
+		retval = -1;
+	}
+	return retval;
+}
Signature · 1 line
1.6.2.5
#4 lore raw

PATCH 3/9 user-cr: s390 eclone wrapper

In reply to a message not in the archive

Based on original work from Serge Hallyn.

---
 clone_s390x.c |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
clone_s390x.c +62 -0
index dada822..5ed6f15 100644
@@ -70,3 +70,65 @@ int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
 }
 
 #endif  /* !defined(__NR_clone_with_pids) */
+
+#include "eclone.h"
+
+#ifndef __NR_eclone
+#define __NR_eclone 332
+#endif
+
+typedef unsigned long long u64;
+
+#define do_eclone(flags, pids, args, sz) \
+( { \
+  register unsigned long int __r1 asm ("1") = (unsigned long int)(__NR_eclone); 
+  register unsigned long int __r2 asm ("2") = (unsigned long int)(flags); \
+  register unsigned long int __r3 asm ("3") = (unsigned long int)(args); \
+  register unsigned long int __r4 asm ("4") = (unsigned long int)(sz); \
+  register unsigned long int __r5 asm ("5") = (unsigned long int)(pids); \
+  register long int __result asm ("2"); \
+  __asm__ __volatile__( \
+	  " svc 0\n" /* do __NR_eclone syscall */ \
+	  " ltgr %%r2,%%r2\n" /* returned 0? */ \
+	  " jnz 1f\n" /* if not goto label 1 */ \
+	  " lg %%r3,0(%%r15)\n"	  /* get fnarg off stack into arg 1 */ \
+	  " lg %%r2,8(%%r15)\n"	  /* get fn off stack int r3 basr*/ \
+	  " lgr %%r1,%%r15\n" /* tmp store old stack pointer */ \
+	  " aghi %%r15,-160\n" /* move the stack */ \
+	  " stg %%r1,0(%%r15)\n" /* and save old stack pointer */ \
+	  " basr %%r14,%%r3\n" /* call fn(arg) */ \
+	  " svc 1\n"  /* call exit */ \
+	  " 1:\n" \
+	  : "=d" (__result) \
+	  : "d" (__r1), "0" (__r2), "d" (__r3), "d" (__r4), "d" (__r5) \
+	  : "memory"); \
+	__result; \
+} )
+
+int eclone(int (*fn)(void *), void *fn_arg, int clone_flags_low,
+	   struct clone_args *clone_args, pid_t *pids)
+{
+	struct clone_args my_args;
+	u64 *child_sp;
+	int rc;
+
+	if (clone_args->child_stack) {
+		child_sp = (void *)(clone_args->child_stack +
+				    clone_args->child_stack_size);
+		*--child_sp = (u64)fn_arg;
+		*--child_sp = (u64)fn;
+	} else
+		child_sp = (u64 *)0;
+
+	my_args = *clone_args;
+	my_args.child_stack = (unsigned long)child_sp;
+	my_args.child_stack_size = 0;
+
+	rc = do_eclone(flags, pids, &my_args, sizeof(struct clone_args));
+	if (rc < 0) {
+		errno = rc;
+		rc = -1;
+	}
+
+	return rc;
+}
Signature · 1 line
1.6.2.5
#13 lore raw

PATCH 4/9 user-cr: ppc32 eclone wrapper

In reply to a message not in the archive
---
 clone_ppc.c  |   43 ++++++++++++++++++++++++++++++++
 clone_ppc_.S |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 120 insertions(+), 0 deletions(-)
clone_ppc.c +43 -0
index 49797fd..c9eee8b 100644
@@ -56,3 +56,46 @@ int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
 }
 
 #endif
+
+#include "eclone.h"
+
+extern int __eclone(int (*fn)(void *arg),
+		    void *child_sp,
+		    int flags,
+		    void *fn_arg,
+		    struct clone_args *args,
+		    size_t args_size,
+		    pid_t *pids);
+
+int eclone(int (*fn)(void *), void *fn_arg, int clone_flags_low,
+	   struct clone_args *clone_args, pid_t *pids)
+{
+	struct clone_args my_args;
+	unsigned long child_sp;
+	int newpid;
+
+	if (clone_args->child_stack)
+		child_sp = clone_args->child_stack +
+			clone_args->child_stack_size - 1;
+	else
+		child_sp = 0;
+
+	my_args = *clone_args;
+	my_args.child_stack = child_sp;
+	my_args.child_stack_size = 0;
+
+	newpid = __eclone(fn,
+			  (void *)child_sp,
+			  clone_flags_low,
+			  fn_arg,
+			  &my_args,
+			  sizeof(my_args),
+			  pids);
+
+	if (newpid < 0) {
+		errno = -newpid;
+		newpid = -1;
+	}
+
+	return newpid;
+}
clone_ppc_.S +77 -0

80 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#16 lore raw

PATCH 5/9 user-cr: add nsexeccwp to test eclone

In reply to a message not in the archive

From: Serge E. Hallyn <serue-r/[email protected]>

One of the concerns with eclone is whether the stack handling is all correct and robust enough to withstand real usage. Little testcases playing with pid values are also necessary, but can't replace really using clone-with-pids to start a shell from which to keep working.

This patch tweaks the old ns_exec.c namespace manipulation program to add a -z option to specify a pid. So you can:

    nsexeccwp -cmp /bin/bash # start a shell in a new pidns+mntns
    mount -t proc proc /proc # mount private /proc
    echo $$
                1
    nsexeccwp -z /bin/bash   #  start a shell with pid 999
    echo $$
            999

[ ntl - minor updates to original version to use clone_args/eclone() ]

---
 Makefile    |    5 +-
 clone.h     |   54 ++++++++++
 nsexeccwp.c |  329 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 387 insertions(+), 1 deletions(-)
 create mode 100644 clone.h
 create mode 100644 nsexeccwp.c
Makefile +4 -1
index 181cc1c..32a6893 100644
@@ -20,7 +20,7 @@ CFLAGS += -g $(WARNS) $(CKPT_INCLUDE) $(DEBUG)
 # install dir
 INSTALL_DIR = /bin
 
-PROGS =	checkpoint restart ckptinfo
+PROGS =	checkpoint restart ckptinfo nsexeccwp
 
 # other cleanup
 OTHER = ckptinfo_types.c
@@ -39,11 +39,14 @@ restart: CFLAGS += -D__REENTRANT -pthread
 ifneq ($(SUBARCH),)
 restart: clone_$(SUBARCH).o
 restart: CFLAGS += -DARCH_HAS_CLONE_WITH_PID
+nsexeccwp: clone_$(SUBARCH).o
+nsexeccwp: CFLAGS += -DARCH_HAS_CLONE_WITH_PID
 endif
 
 # on powerpc, need also assembly file
 ifeq ($(SUBARCH),ppc)
 restart: clone_$(SUBARCH)_.o
+nsexeccwp: clone_$(SUBARCH)_.o
 endif
 
 # ckptinfo dependencies
clone.h new file +54 -0

54 lines not on this page · raw message

nsexeccwp.c new file +329 -0

329 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#17 lore raw

PATCH 6/9 user-cr: use eclone API for restart

In reply to a message not in the archive

Replace use of clone_with_pids with clone_args/eclone. After this the clone_with_pids support code can go away.

---
 restart.c |   46 +++++++++++++++-------------------------------
 1 files changed, 15 insertions(+), 31 deletions(-)
restart.c +15 -31
index d5d069a..258cda9 100644
@@ -34,25 +34,7 @@
 #include <linux/checkpoint.h>
 #include <linux/checkpoint_hdr.h>
 
-
-/* this really belongs to some kernel header ! */
-struct pid_set {
-	int num_pids;
-	pid_t *pids;
-};
-
-/* (until it's supported by libc) from clone_ARCH.c */
-#if defined(__NR_clone_with_pids) && defined(ARCH_HAS_CLONE_WITH_PID)
-extern int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
-			   struct pid_set *target_pids, void *arg);
-#else
-static int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
-			   struct pid_set *target_pids, void *arg)
-{
-	return clone(fn, child_stack, flags, arg);
-}
-#endif
-
+#include "eclone.h"
 
 static char usage_str[] =
 "usage: restart [opts]\n"
@@ -1852,23 +1834,20 @@ int ckpt_fork_stub(void *data)
 
 static pid_t ckpt_fork_child(struct ckpt_ctx *ctx, struct task *child)
 {
-	struct pid_set pid_set;
-	char *stack_region;
-	char *stack_start;
+	struct clone_args clone_args;
+	void *stack;
 	unsigned long flags = SIGCHLD;
+	size_t stack_sz = PTHREAD_STACK_MIN;
+	size_t nr_pids = 1;
 	pid_t pid = 0;
 
 	ckpt_dbg("forking child vpid %d flags %#x\n", child->pid, child->flags);
 
-	stack_region = malloc(PTHREAD_STACK_MIN);
-	if (!stack_region) {
+	stack = malloc(stack_sz);
+	if (!stack) {
 		perror("stack malloc");
 		return -1;
 	}
-	stack_start = stack_region + PTHREAD_STACK_MIN - 1;
-
-	pid_set.pids = &pid;
-	pid_set.num_pids = 1;
 
 	if (child->flags & TASK_THREAD) {
 		flags |= CLONE_THREAD | CLONE_SIGHAND | CLONE_VM;
@@ -1893,15 +1872,20 @@ static pid_t ckpt_fork_child(struct ckpt_ctx *ctx, struct task *child)
 	else
 		child->real_parent = _getpid();
 
-	pid = clone_with_pids(ckpt_fork_stub, stack_start, flags, &pid_set, child);
+	memset(&clone_args, 0, sizeof(clone_args));
+	clone_args.child_stack = (unsigned long)stack;
+	clone_args.child_stack_size = stack_sz;
+	clone_args.nr_pids = nr_pids;
+
+	pid = eclone(ckpt_fork_stub, child, flags, &clone_args, &pid);
 	if (pid < 0) {
 		perror("clone");
-		free(stack_region);
+		free(stack);
 		return -1;
 	}
 
 	if (!(child->flags & TASK_THREAD))
-		free(stack_region);
+		free(stack);
 
 	ckpt_dbg("forked child vpid %d (asked %d)\n", pid, child->pid);
 	return pid;
Signature · 1 line
1.6.2.5
#18 lore raw

PATCH 7/9 user-cr: remove x86_32 clone_with_pids

In reply to a message not in the archive

Remove support code for old clone_with_pids interface and update comments accordingly.

---
 clone_x86_32.c |   64 +------------------------------------------------------
 1 files changed, 2 insertions(+), 62 deletions(-)
clone_x86_32.c +2 -62
index 61b593c..6f1d891 100644
@@ -1,5 +1,5 @@
 /*
- *  clone_x86_32.c: support for clone_with_pid() on x86_32
+ *  clone_x86_32.c: support for eclone() on x86_32
  *
  *  Copyright (C) Oren Laadan <[email protected]>
  *
@@ -17,70 +17,10 @@
 #include <asm/unistd.h>
 
 /*
- * libc doesn't support clone_with_pid() yet...
+ * libc doesn't support eclone() yet...
  * below is arch-dependent code to use the syscall
  */
 #include <linux/checkpoint.h>
-#if defined(__NR_clone_with_pids)
-
-/* this really belongs to some kernel header ! */
-struct pid_set {
-	int num_pids;
-	pid_t *pids;
-};
-
-/* (see: http://lkml.indiana.edu/hypermail/linux/kernel/9604.3/0204.html) */
-int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
-		    struct pid_set *target_pids, void *arg)
-{
-	long retval;
-	void **newstack;
-
-	/*
-	 * Set up the stack for child:
-	 *  - the (void *) arg will be the argument for the child function
-	 *  - the fn pointer will be loaded into ebx after the clone
-	 */
-	newstack = (void **) child_stack;
-	*--newstack = arg;
-	*--newstack = fn;
-
-	__asm__  __volatile__(
-		 "movl %0, %%ebx\n\t"		/* flags -> 1st (ebx) */
-		 "movl %1, %%ecx\n\t"		/* newstack -> 2nd (ecx)*/
-		 "xorl %%edi, %%edi\n\t"	/* 0 -> 3rd (edi) */
-		 "xorl %%edx, %%edx\n\t"	/* 0 -> 4th (edx) */
-		 "pushl %%ebp\n\t"		/* save value of ebp */
-		 "movl %2, %%ebp\n\t"		/* flags -> 6th (ebp) */
-		:
-		:"b" (flags),
-		 "c" (newstack),
-		 "r" (target_pids)
-		);
-
-	__asm__ __volatile__(
-		 "int $0x80\n\t"	/* Linux/i386 system call */
-		 "testl %0,%0\n\t"	/* check return value */
-		 "jne 1f\n\t"		/* jump if parent */
-		 "popl %%ebx\n\t"	/* get subthread function */
-		 "call *%%ebx\n\t"	/* start subthread function */
-		 "movl %2,%0\n\t"
-		 "int $0x80\n"		/* exit system call: exit subthread */
-		 "1:\n\t"
-		 "popl %%ebp\t"		/* restore parent's ebp */
-		:"=a" (retval)
-		:"0" (__NR_clone_with_pids), "i" (__NR_exit)
-		:"ebx", "ecx"
-		);
-
-	if (retval < 0) {
-		errno = -retval;
-		retval = -1;
-	}
-	return retval;
-}
-
-#endif
 
 #include "eclone.h"
 
Signature · 1 line
1.6.2.5
#19 lore raw

PATCH 8/9 user-cr: remove s390 clone_with_pids

In reply to a message not in the archive

Remove support code for old clone_with_pids interface and update comments accordingly.

---
 clone_s390x.c |   51 ++-------------------------------------------------
 1 files changed, 2 insertions(+), 49 deletions(-)
clone_s390x.c +2 -49
index 5ed6f15..af3d41f 100644
@@ -1,5 +1,5 @@
 /*
- *  clone_s390.c: support for clone_with_pid() on s390x (64 bit)
+ *  clone_s390.c: support for eclone() on s390x (64 bit)
  *
  *  Copyright (C) IBM Corporation
  *
@@ -19,57 +19,10 @@
 #include <asm/unistd.h>
 
 /*
- * libc doesn't support clone_with_pid() yet...
+ * libc doesn't support eclone() yet...
  * below is arch-dependent code to use the syscall
  */
 #include <linux/checkpoint.h>
-#if defined(__NR_clone_with_pids)
-
-/* this really belongs to some kernel header ! */
-struct pid_set {
-	int num_pids;
-	pid_t *pids;
-};
-
-/* (see: http://lkml.indiana.edu/hypermail/linux/kernel/9604.3/0204.html) */
-
-#define do_clone_with_pids(stack, flags, ptid, ctid, setp) ({ \
-	register unsigned long int __r2 asm ("2") = (unsigned long int)(stack);\
-	register unsigned long int __r3 asm ("3") = (unsigned long int)(flags);\
-	register unsigned long int __r4 asm ("4") = (unsigned long int)(ptid); \
-	register unsigned long int __r5 asm ("5") = (unsigned long int)(ctid); \
-	register unsigned long int __r6 asm ("6") = (unsigned long int)(NULL); \
-	register unsigned long int __r7 asm ("7") = (unsigned long int)(setp); \
-	register unsigned long int __result asm ("2"); \
-	__asm__ __volatile__( \
-		" lghi %%r1,%7\n" \
-		" svc 0\n" \
-		: "=d" (__result) \
-		: "0" (__r2), "d" (__r3), \
-		  "d" (__r4), "d" (__r5), "d" (__r6), "d" (__r7), \
-		  "i" (__NR_clone_with_pids) \
-		: "1", "cc", "memory" \
-	); \
-		__result; \
-	})
-
-int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
-			struct pid_set *target_pids, void *arg)
-{
-	long retval;
-	retval = do_clone_with_pids(child_stack, flags, NULL, NULL,
-				    target_pids);
-
-	if (retval < 0) {
-		errno = -retval;
-		return -1;
-	} else if (retval == 0) {
-		return fn(arg);
-	} else
-		return retval;
-}
-
-#endif  /* !defined(__NR_clone_with_pids) */
 
 #include "eclone.h"
 
Signature · 1 line
1.6.2.5
#20 lore raw

PATCH 9/9 user-cr: remove powerpc clone_with_pids

In reply to a message not in the archive

Remove C and asm support code for old clone_with_pids interface and update comments accordingly.

---
 clone_ppc.c  |   37 +--------------------------
 clone_ppc_.S |   79 +---------------------------------------------------------
 2 files changed, 2 insertions(+), 114 deletions(-)
clone_ppc.c +1 -36
index c9eee8b..47b8290 100644
@@ -16,46 +16,11 @@
 #include <sys/syscall.h>
 #include <asm/unistd.h>
 
-struct target_pid_set;
-
-extern int __clone_with_pids(int (*fn)(void *arg),
-			     void *child_stack ,
-			     int flags,
-			     void *arg,
-			     void *parent_tid,
-			     void *tls,
-			     void *child_tid,
-			     struct target_pid_set *setp);
-
 /*
- * libc doesn't support clone_with_pid() yet...
+ * libc doesn't support eclone() yet...
  * below is arch-dependent code to use the syscall
  */
 #include <linux/checkpoint.h>
-#if defined(__NR_clone_with_pids)
-
-/* (see: http://lkml.indiana.edu/hypermail/linux/kernel/9604.3/0204.html) */
-
-int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
-			   struct target_pid_set *target_pids, void *arg)
-{
-	void *parent_tid = NULL;
-	void *tls = NULL;
-	void *child_tid = NULL;
-	pid_t newpid;
-
-	newpid = __clone_with_pids(fn, child_stack, flags, arg, parent_tid,
-				   tls, child_tid, target_pids);
-
-	if (newpid < 0) {
-		errno = -newpid;
-		return -1;
-	}
-
-	return newpid;
-}
-
-#endif
 
 #include "eclone.h"
 
clone_ppc_.S +1 -78

89 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#6 lore raw

Re: [PATCH 3/9] user-cr: s390 eclone wrapper

In reply to a message not in the archive
Quoted 1 line · Nathan Lynch

Based on original work from Serge Hallyn.

Needed the following patch on top of that. Otherwise the whole set looks good to me, thanks!

(Oh, one other note, the default #ifdef for NR_eclone actually is different depending on whether we're on a c/r kernel or not, unfortunately :(. I'm leaving it as the non-c/r kernel value for now.)

thanks,
-serge

From: "Serge E. Hallyn" <serue-r/[email protected]>
Subject: [PATCH 1/1] a few bugfixes for s390

---
 clone_s390x.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
clone_s390x.c +4 -3
index af3d41f..64d4436 100644
@@ -34,7 +34,7 @@ typedef unsigned long long u64;
 
 #define do_eclone(flags, pids, args, sz) \
 ( { \
-  register unsigned long int __r1 asm ("1") = (unsigned long int)(__NR_eclone); 
+  register unsigned long int __r1 asm ("1") = (unsigned long int)(__NR_eclone);  \
   register unsigned long int __r2 asm ("2") = (unsigned long int)(flags); \
   register unsigned long int __r3 asm ("3") = (unsigned long int)(args); \
   register unsigned long int __r4 asm ("4") = (unsigned long int)(sz); \
@@ -77,9 +77,10 @@ int eclone(int (*fn)(void *), void *fn_arg, int clone_flags_low,
 	my_args.child_stack = (unsigned long)child_sp;
 	my_args.child_stack_size = 0;
 
-	rc = do_eclone(flags, pids, &my_args, sizeof(struct clone_args));
+	rc = do_eclone(clone_flags_low, pids, &my_args,
+			sizeof(struct clone_args));
 	if (rc < 0) {
-		errno = rc;
+		errno = -rc;
 		rc = -1;
 	}
 
Signature · 1 line
1.6.1.1
#8 lore raw

Re: [PATCH 3/9] user-cr: s390 eclone wrapper

In reply to a message not in the archive
Quoted 5 lines · Serge E. Hallyn
Quoted 1 line · Nathan Lynch

Based on original work from Serge Hallyn.

Needed the following patch on top of that. Otherwise the whole set looks good to me, thanks!

Great, thanks for the fixups.

Quoted 4 lines

(Oh, one other note, the default #ifdef for NR_eclone actually is different depending on whether we're on a c/r kernel or not, unfortunately :(. I'm leaving it as the non-c/r kernel value for now.)

Right.. I was thinking that the syscall numbers for eclone should precede those for checkpoint and restart in the c/r patch set. Thoughts on that?

#10 lore raw

Re: [PATCH 3/9] user-cr: s390 eclone wrapper

In reply to a message not in the archive
Quoted 10 lines · Nathan Lynch
Quoted 5 lines · Serge E. Hallyn
Quoted 1 line · Nathan Lynch

Based on original work from Serge Hallyn.

Needed the following patch on top of that. Otherwise the whole set looks good to me, thanks!

Great, thanks for the fixups.

Quoted 8 lines
Quoted 4 lines

(Oh, one other note, the default #ifdef for NR_eclone actually is different depending on whether we're on a c/r kernel or not, unfortunately :(. I'm leaving it as the non-c/r kernel value for now.)

Right.. I was thinking that the syscall numbers for eclone should precede those for checkpoint and restart in the c/r patch set. Thoughts on that?

Yes, I was thinking the same thing.

-serge

#15 lore raw

Re: [PATCH 4/9] user-cr: ppc32 eclone wrapper

In reply to a message not in the archive

clone_ppc.c int clone_with_pids(int (*fn)(void *), void *child_stack, int flags, · line 79

Quoted 10 lines · Nathan Lynch
clone_ppc.c +10 -0
+int eclone(int (*fn)(void *), void *fn_arg, int clone_flags_low,
+	   struct clone_args *clone_args, pid_t *pids)
+{
+	struct clone_args my_args;
+	unsigned long child_sp;
+	int newpid;
+
+	if (clone_args->child_stack)
+		child_sp = clone_args->child_stack +
+			clone_args->child_stack_size - 1;

Should be

		child_sp = (clone_args->child_stack +
			clone_args->child_stack_size - 1) & ~0xf;

Otherwise the child starts with an unaligned sp, causing accesses outside of the stack region.

#12 lore raw

Re: [PATCH 3/9] user-cr: s390 eclone wrapper

In reply to a message not in the archive
Quoted 13 lines · Serge E. Hallyn
Quoted 12 lines · Nathan Lynch
Quoted 4 lines · Serge E. Hallyn
Quoted 1 line · Nathan Lynch

Based on original work from Serge Hallyn.

Needed the following patch on top of that. Otherwise the whole set looks good to me, thanks!

Great, thanks for the fixups.

Quoted 4 lines

(Oh, one other note, the default #ifdef for NR_eclone actually is different depending on whether we're on a c/r kernel or not, unfortunately :(. I'm leaving it as the non-c/r kernel value for now.)

Quoted 5 lines
Quoted 3 lines

Right.. I was thinking that the syscall numbers for eclone should precede those for checkpoint and restart in the c/r patch set. Thoughts on that?

Yes, I was thinking the same thing.

Good idea - will do in v19-rc2.

Oren.

#21 lore raw
In reply to a message not in the archive

Thanks for the port to eclone - this is queued for v19-rc2.

Oren.

Quoted 39 lines · Nathan Lynch

The following series adds support for eclone to the arch code, introduces the nsexeccwp utility which allows for isolated testing of eclone's pid-choosing capability, switches the restart utility to eclone, and finally phases out the clone_with_pids support code.

I've verified that nsexeccwp works correctly on x86 and powerpc with a mainline kernel with eclone support (but not checkpoint/restart); s390 needs to be built and tested (Serge?).

Based on ckpt-v19-rc1.

Nathan Lynch (8):
user-cr: add eclone/clone_args header
user-cr: x86_32 eclone wrapper
user-cr: s390 eclone wrapper
user-cr: ppc32 eclone wrapper
user-cr: use eclone API for restart
user-cr: remove x86_32 clone_with_pids
user-cr: remove s390 clone_with_pids
user-cr: remove powerpc clone_with_pids

Serge E. Hallyn (1):
user-cr: add nsexeccwp to test eclone

 Makefile       |    5 +-
 clone.h        |   54 +++++++++
 clone_ppc.c    |   58 ++++++-----
 clone_ppc_.S   |   52 +++++-----
 clone_s390x.c  |   97 ++++++++++-------
 clone_x86_32.c |   87 ++++++++-------
 eclone.h       |   25 +++++
 nsexeccwp.c    |  329 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 restart.c      |   46 +++------
 9 files changed, 588 insertions(+), 165 deletions(-)
 create mode 100644 clone.h
 create mode 100644 eclone.h
 create mode 100644 nsexeccwp.c