[CRIU] [PATCH] ppc64: Fix broken SYS V shared memory support

Laurent Dufour ldufour at linux.vnet.ibm.com
Wed Jun 24 06:18:56 PDT 2015


The initial support of the SYS V shared memory on ppc64 is broken. The call
to shmat done in the restore blob has no chance to work correctly.

This patch fixes the sys_shmat call.

Signed-off-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
---
 arch/ppc64/include/asm/restorer.h |  2 +-
 arch/ppc64/restorer.c             | 19 ++++++++++++++++++-
 arch/ppc64/syscall-common-ppc64.S |  8 --------
 arch/ppc64/syscall-ppc64.def      |  1 +
 4 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/arch/ppc64/include/asm/restorer.h b/arch/ppc64/include/asm/restorer.h
index 0549992def65..d4560f74cf29 100644
--- a/arch/ppc64/include/asm/restorer.h
+++ b/arch/ppc64/include/asm/restorer.h
@@ -131,6 +131,6 @@ static inline int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe,
 /*
  * Defined in arch/ppc64/syscall-common-ppc64.S
  */
-int sys_shmat(int shmid, const void *shmaddr, int shmflg);
+unsigned long sys_shmat(int shmid, const void *shmaddr, int shmflg);
 
 #endif /*__CR_ASM_RESTORER_H__*/
diff --git a/arch/ppc64/restorer.c b/arch/ppc64/restorer.c
index c5e19d9fb977..665676045d3f 100644
--- a/arch/ppc64/restorer.c
+++ b/arch/ppc64/restorer.c
@@ -6,9 +6,26 @@
 
 #include "syscall.h"
 #include "log.h"
-//#include "cpu.h"
 
 int restore_nonsigframe_gpregs(UserPpc64RegsEntry *r)
 {
 	return 0;
 }
+
+unsigned long sys_shmat(int shmid, const void *shmaddr, int shmflg)
+{
+	unsigned long raddr;
+	int ret;
+
+	ret = sys_ipc(21 /*SHMAT */,
+		      shmid,		 	/* first 		*/
+		      shmflg,		 	/* second 		*/
+		      (unsigned long)&raddr,	/* third 		*/
+		      shmaddr,			/* ptr			*/
+		      0 			/* fifth not used 	*/);
+
+	if (ret)
+		raddr = (unsigned long) ret;
+
+	return raddr;
+}
diff --git a/arch/ppc64/syscall-common-ppc64.S b/arch/ppc64/syscall-common-ppc64.S
index d8521e39ca81..e18d6adf419e 100644
--- a/arch/ppc64/syscall-common-ppc64.S
+++ b/arch/ppc64/syscall-common-ppc64.S
@@ -22,11 +22,3 @@ ENTRY(__cr_restore_rt)
 	b	__syscall_common
 END(__cr_restore_rt)
 
-# On Power, shmat is done through the ipc system call.
-ENTRY(sys_shmat)
-	mr	r7, r4	# shmaddr -> ptr
-	mr	r4, r3	# shmid -> first
-	li	r3, 21	# call = SHMAT
-	li	r0, __NR_ipc
-	b	__syscall_common
-END(sys_shmat)
diff --git a/arch/ppc64/syscall-ppc64.def b/arch/ppc64/syscall-ppc64.def
index 52de3b867b85..3debf7b6966d 100644
--- a/arch/ppc64/syscall-ppc64.def
+++ b/arch/ppc64/syscall-ppc64.def
@@ -98,3 +98,4 @@ __NR_kcmp		354		sys_kcmp		(pid_t pid1, pid_t pid2, int type, unsigned long idx1,
 __NR_memfd_create	360		sys_memfd_create	(const char *name, unsigned int flags)
 __NR_io_setup		227		sys_io_setup		(unsigned nr_events, aio_context_t *ctx_idp)
 __NR_io_getevents	229		sys_io_getevents	(aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout)
+__NR_ipc		117		sys_ipc			(unsigned int call, int first, unsigned long second, unsigned long third, const void *ptr, long fifth)
-- 
1.9.1



More information about the CRIU mailing list