Linux Container Development
 help / color / mirror / Atom feed
* [PATCH 0/4] user-cr: powerpc support etc
@ 2009-09-16  9:27 Nathan Lynch
       [not found] ` <1253093271-16357-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Lynch @ 2009-09-16  9:27 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-qjLDD68F18O7TbgM5vRIOg

Patch 1 is an obvious fix, I think.

The rest is an assortment of hacks I've employed to get this building
and working on powerpc.

Nathan Lynch (4):
  fix rename fallout
  restart: (build fix hack) define sa_family_t and struct linger
  mktree: initial powerpc support hacks
  makefile hack for powerpc

 Makefile      |    5 +++-
 clone_ppc32.S |   79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 powerpc_asm.h |   46 +++++++++++++++++++++++++++++++++
 restart.c     |   31 ++++++++++++++++++++++
 4 files changed, 160 insertions(+), 1 deletions(-)
 create mode 100644 clone_ppc32.S
 create mode 100644 powerpc_asm.h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] fix rename fallout
       [not found] ` <1253093271-16357-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
@ 2009-09-16  9:27   ` Nathan Lynch
  2009-09-16  9:27   ` [PATCH 2/4] restart: (build fix hack) define sa_family_t and struct linger Nathan Lynch
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Nathan Lynch @ 2009-09-16  9:27 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-qjLDD68F18O7TbgM5vRIOg

mktree was renamed to restart; update Makefile accordingly.

Signed-off-by: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 497648e..8cd0c2d 100644
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,7 @@ all: $(PROGS)
 
 ckptinfo: ckptinfo_types.o
 
-mktree:	CFLAGS += -D__REENTRANT -pthread
+restart: CFLAGS += -D__REENTRANT -pthread
 
 ckptinfo_types.o: ckptinfo_types.c
 	@echo $(CC) -c $(CFLAGS) $<
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] restart: (build fix hack) define sa_family_t and struct linger
       [not found] ` <1253093271-16357-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
  2009-09-16  9:27   ` [PATCH 1/4] fix rename fallout Nathan Lynch
@ 2009-09-16  9:27   ` Nathan Lynch
  2009-09-16  9:27   ` [PATCH 3/4] mktree: initial powerpc support hacks Nathan Lynch
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Nathan Lynch @ 2009-09-16  9:27 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-qjLDD68F18O7TbgM5vRIOg

restart.c doesn't build against exported kernel headers:

$ make CPPFLAGS=-I$PWD/../linux-2.6.git/usr/include
cc -g -Wall -Wstrict-prototypes -Wno-trigraphs -I../linux/include -I../linux/arch//include -DCHECKPOINT_DEBUG -D__REENTRANT -pthread -I/home/nathanl/devel/user-cr.git/../linux-2.6.git/usr/include restart.c clone_ppc32.o -o restart
In file included from /home/nathanl/devel/user-cr.git/../linux-2.6.git/usr/include/linux/checkpoint_hdr.h:16,
                 from restart.c:42:
/home/nathanl/devel/user-cr.git/../linux-2.6.git/usr/include/linux/un.h:7: error: expected specifier-qualifier-list before ‘sa_family_t’
In file included from restart.c:42:
/home/nathanl/devel/user-cr.git/../linux-2.6.git/usr/include/linux/checkpoint_hdr.h:407: error: field ‘linger’ has incomplete type
make: *** [restart] Error 1

I am not sure what the right fix is.  This is not it.
---
 restart.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/restart.c b/restart.c
index 2d8d796..b93a2e1 100644
--- a/restart.c
+++ b/restart.c
@@ -10,6 +10,13 @@
 
 #define _GNU_SOURCE
 
+/* Hacks ahoy */
+typedef unsigned short	sa_family_t;
+struct linger {
+	int		l_onoff;	/* Linger active		*/
+	int		l_linger;	/* How long to linger for	*/
+};
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-- 
1.6.0.6

_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] mktree: initial powerpc support hacks
       [not found] ` <1253093271-16357-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
  2009-09-16  9:27   ` [PATCH 1/4] fix rename fallout Nathan Lynch
  2009-09-16  9:27   ` [PATCH 2/4] restart: (build fix hack) define sa_family_t and struct linger Nathan Lynch
@ 2009-09-16  9:27   ` Nathan Lynch
  2009-09-16  9:27   ` [PATCH 4/4] makefile hack for powerpc Nathan Lynch
  2009-09-16 18:05   ` [PATCH 0/4] user-cr: powerpc support etc Oren Laadan
  4 siblings, 0 replies; 6+ messages in thread
From: Nathan Lynch @ 2009-09-16  9:27 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-qjLDD68F18O7TbgM5vRIOg

---
 clone_ppc32.S |   79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 powerpc_asm.h |   46 +++++++++++++++++++++++++++++++++
 restart.c     |   24 +++++++++++++++++
 3 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100644 clone_ppc32.S
 create mode 100644 powerpc_asm.h

diff --git a/clone_ppc32.S b/clone_ppc32.S
new file mode 100644
index 0000000..e159b19
--- /dev/null
+++ b/clone_ppc32.S
@@ -0,0 +1,79 @@
+#include <asm/unistd.h>
+#include "powerpc_asm.h"
+
+/* int [r3] clone_with_pids(int (*fn)(void *arg) [r3],
+ *                          void *child_stack [r4],
+ *                          int flags [r5],
+ *                          void *arg [r6],
+ *                          void *parent_tid [r7],
+ *                          void *tls [r8],
+ *                          void *child_tid [r9],
+ *                          struct target_pid_set *setp [r10]);
+ * Creates a child task with the pids specified by setp.
+ * Returns to parent only, child execution and exit is handled here.
+ * On error, returns negated errno.  On success, returns the pid of the child
+ * created.
+ */
+
+	.text
+	.globl __clone_with_pids
+__clone_with_pids:
+
+	/* No argument validation. */
+
+	/* Set up parent's stack frame. */
+	stwu	r1,-32(r1)
+
+	/* Save non-volatiles (r28-r31) which we plan to use. */
+	stmw	r28,16(r1)
+
+	/* Set up child's stack frame. */
+	clrrwi	r4,r4,4
+	li	r0,0
+	stw	r0,-16(r4)
+
+	/* Save fn, stack pointer, flags, and arg across system call. */
+	mr	r28,r3
+	mr	r29,r4
+	mr	r30,r5
+	mr	r31,r6
+
+	/* Set up arguments for system call.  Stack pointer is already in r4. */
+	mr	r3,r5	/* flags */
+	mr	r5,r7	/* parent_tid */
+	mr	r6,r8	/* tls */
+	mr	r7,r9	/* child_tid */
+	mr	r8,r10	/* setp */
+
+	/* Do the system call */
+	li	r0,__NR_clone_with_pids
+	sc
+
+	/* Parent or child? */
+	cmpwi	cr1,r3,0
+	crandc	4*cr1+eq,4*cr1+eq,4*cr0+so
+	bne	cr1,parent
+
+	/* Child. Call fn. */
+	mtctr	r28
+	mr 	r3,r31
+	bctrl
+
+	/* Assume result of fn in r3 and exit. */
+	li	r0,__NR_exit
+	sc
+
+parent:
+	/* Restore non-volatiles. */
+	lmw	r28,16(r1)
+
+	addi	r1,r1,32
+
+	/* Return to caller on success. */
+	bnslr
+
+	/* Handle error.  Negate the return value to signal an error
+	 * to the caller, which must set errno.
+	 */
+	neg	r3,r3
+	blr
diff --git a/powerpc_asm.h b/powerpc_asm.h
new file mode 100644
index 0000000..58f459f
--- /dev/null
+++ b/powerpc_asm.h
@@ -0,0 +1,46 @@
+#ifndef __POWERPC_ASM_H
+#define _POWERPC_ASM_H
+
+#define	r0	0
+#define	r1	1
+#define	r2	2
+#define	r3	3
+#define	r4	4
+#define	r5	5
+#define	r6	6
+#define	r7	7
+#define	r8	8
+#define	r9	9
+#define	r10	10
+#define	r11	11
+#define	r12	12
+#define	r13	13
+#define	r14	14
+#define	r15	15
+#define	r16	16
+#define	r17	17
+#define	r18	18
+#define	r19	19
+#define	r20	20
+#define	r21	21
+#define	r22	22
+#define	r23	23
+#define	r24	24
+#define	r25	25
+#define	r26	26
+#define	r27	27
+#define	r28	28
+#define	r29	29
+#define	r30	30
+#define	r31	31
+
+#define	cr0	0
+#define	cr1	1
+#define	cr2	2
+#define	cr3	3
+#define	cr4	4
+#define	cr5	5
+#define	cr6	6
+#define	cr7	7
+
+#endif /* _POWERPC_ASM_H */
diff --git a/restart.c b/restart.c
index b93a2e1..499614e 100644
--- a/restart.c
+++ b/restart.c
@@ -1951,6 +1951,30 @@ int clone_with_pids(int (*fn)(void *), void *child_stack, int flags,
 		return retval;
 }
 
+#elif defined(__powerpc__) && defined(__NR_clone_with_pids)
+
+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);
+
+static 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;
+}
 #else  /* !defined(__NR_clone_with_pids) */
 
 /* on other architectures fallback to regular clone(2) */
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] makefile hack for powerpc
       [not found] ` <1253093271-16357-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2009-09-16  9:27   ` [PATCH 3/4] mktree: initial powerpc support hacks Nathan Lynch
@ 2009-09-16  9:27   ` Nathan Lynch
  2009-09-16 18:05   ` [PATCH 0/4] user-cr: powerpc support etc Oren Laadan
  4 siblings, 0 replies; 6+ messages in thread
From: Nathan Lynch @ 2009-09-16  9:27 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-qjLDD68F18O7TbgM5vRIOg

Add an explict restart target which links clone_ppc32.o into the
restart executable.

Ideas on how to handle this in a mergeable form are welcome.
---
 Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index 8cd0c2d..10c068c 100644
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,9 @@ all: $(PROGS)
 ckptinfo: ckptinfo_types.o
 
 restart: CFLAGS += -D__REENTRANT -pthread
+# powerpc hack
+restart: restart.c clone_ppc32.o
+	$(CC) $(CFLAGS) $(CPPFLAGS) $^ -o $@
 
 ckptinfo_types.o: ckptinfo_types.c
 	@echo $(CC) -c $(CFLAGS) $<
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] user-cr: powerpc support etc
       [not found] ` <1253093271-16357-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2009-09-16  9:27   ` [PATCH 4/4] makefile hack for powerpc Nathan Lynch
@ 2009-09-16 18:05   ` Oren Laadan
  4 siblings, 0 replies; 6+ messages in thread
From: Oren Laadan @ 2009-09-16 18:05 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: containers-qjLDD68F18O7TbgM5vRIOg


got them .. thanks.

Nathan Lynch wrote:
> Patch 1 is an obvious fix, I think.
> 
> The rest is an assortment of hacks I've employed to get this building
> and working on powerpc.
> 
> Nathan Lynch (4):
>   fix rename fallout
>   restart: (build fix hack) define sa_family_t and struct linger
>   mktree: initial powerpc support hacks
>   makefile hack for powerpc
> 
>  Makefile      |    5 +++-
>  clone_ppc32.S |   79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  powerpc_asm.h |   46 +++++++++++++++++++++++++++++++++
>  restart.c     |   31 ++++++++++++++++++++++
>  4 files changed, 160 insertions(+), 1 deletions(-)
>  create mode 100644 clone_ppc32.S
>  create mode 100644 powerpc_asm.h
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-09-16 18:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-16  9:27 [PATCH 0/4] user-cr: powerpc support etc Nathan Lynch
     [not found] ` <1253093271-16357-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
2009-09-16  9:27   ` [PATCH 1/4] fix rename fallout Nathan Lynch
2009-09-16  9:27   ` [PATCH 2/4] restart: (build fix hack) define sa_family_t and struct linger Nathan Lynch
2009-09-16  9:27   ` [PATCH 3/4] mktree: initial powerpc support hacks Nathan Lynch
2009-09-16  9:27   ` [PATCH 4/4] makefile hack for powerpc Nathan Lynch
2009-09-16 18:05   ` [PATCH 0/4] user-cr: powerpc support etc Oren Laadan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox