All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] powerpc: Individual System V IPC system calls
@ 2015-10-13  1:49 Sam Bobroff
  2015-10-13  9:38 ` [v2,1/1] " Michael Ellerman
  2015-10-15 11:10 ` Michael Ellerman
  0 siblings, 2 replies; 7+ messages in thread
From: Sam Bobroff @ 2015-10-13  1:49 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mpe, anton, mikey

This patch provides individual system call numbers for the following
System V IPC system calls, on PowerPC, so that they do not need to be
multiplexed:
* semop, semget, semctl, semtimedop
* msgsnd, msgrcv, msgget, msgctl
* shmat, shmdt, shmget, shmctl

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
---

v2:

Rebased onto today's next-20151012.

 arch/powerpc/include/asm/systbl.h      | 12 ++++++++++++
 arch/powerpc/include/asm/unistd.h      |  2 +-
 arch/powerpc/include/uapi/asm/unistd.h | 12 ++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 126d0c4..c9e26cb 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -370,3 +370,15 @@ COMPAT_SYS(execveat)
 PPC64ONLY(switch_endian)
 SYSCALL_SPU(userfaultfd)
 SYSCALL_SPU(membarrier)
+SYSCALL(semop)
+SYSCALL(semget)
+COMPAT_SYS(semctl)
+COMPAT_SYS(semtimedop)
+COMPAT_SYS(msgsnd)
+COMPAT_SYS(msgrcv)
+SYSCALL(msgget)
+COMPAT_SYS(msgctl)
+COMPAT_SYS(shmat)
+SYSCALL(shmdt)
+SYSCALL(shmget)
+COMPAT_SYS(shmctl)
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 13411be..6d8f802 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -12,7 +12,7 @@
 #include <uapi/asm/unistd.h>
 
 
-#define __NR_syscalls		366
+#define __NR_syscalls		378
 
 #define __NR__exit __NR_exit
 #define NR_syscalls	__NR_syscalls
diff --git a/arch/powerpc/include/uapi/asm/unistd.h b/arch/powerpc/include/uapi/asm/unistd.h
index 63377380..81579e9 100644
--- a/arch/powerpc/include/uapi/asm/unistd.h
+++ b/arch/powerpc/include/uapi/asm/unistd.h
@@ -388,5 +388,17 @@
 #define __NR_switch_endian	363
 #define __NR_userfaultfd	364
 #define __NR_membarrier		365
+#define __NR_semop		366
+#define __NR_semget		367
+#define __NR_semctl		368
+#define __NR_semtimedop		369
+#define __NR_msgsnd		370
+#define __NR_msgrcv		371
+#define __NR_msgget		372
+#define __NR_msgctl		373
+#define __NR_shmat		374
+#define __NR_shmdt		375
+#define __NR_shmget		376
+#define __NR_shmctl		377
 
 #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
-- 
2.1.4

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

* Re: [v2,1/1] powerpc: Individual System V IPC system calls
  2015-10-13  1:49 [PATCH v2 1/1] powerpc: Individual System V IPC system calls Sam Bobroff
@ 2015-10-13  9:38 ` Michael Ellerman
  2015-10-13 11:46   ` Arnd Bergmann
  2015-10-14  7:00   ` Sam Bobroff
  2015-10-15 11:10 ` Michael Ellerman
  1 sibling, 2 replies; 7+ messages in thread
From: Michael Ellerman @ 2015-10-13  9:38 UTC (permalink / raw)
  To: Sam bobroff, linuxppc-dev; +Cc: mikey, anton

On Tue, 2015-13-10 at 01:49:28 UTC, Sam bobroff wrote:
> This patch provides individual system call numbers for the following
> System V IPC system calls, on PowerPC, so that they do not need to be
> multiplexed:
> * semop, semget, semctl, semtimedop
> * msgsnd, msgrcv, msgget, msgctl
> * shmat, shmdt, shmget, shmctl

You tested this right? :)  Tell me about it.

Also we could make these available to SPU programs, but I don't think there's
any point, no one's going to do a libc update for that.

cheers

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

* Re: [v2,1/1] powerpc: Individual System V IPC system calls
  2015-10-13  9:38 ` [v2,1/1] " Michael Ellerman
@ 2015-10-13 11:46   ` Arnd Bergmann
  2015-10-14  7:00   ` Sam Bobroff
  1 sibling, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2015-10-13 11:46 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Michael Ellerman, Sam bobroff, linuxppc-dev, mikey, anton

On Tuesday 13 October 2015 20:38:42 Michael Ellerman wrote:
> On Tue, 2015-13-10 at 01:49:28 UTC, Sam bobroff wrote:
> > This patch provides individual system call numbers for the following
> > System V IPC system calls, on PowerPC, so that they do not need to be
> > multiplexed:
> > * semop, semget, semctl, semtimedop
> > * msgsnd, msgrcv, msgget, msgctl
> > * shmat, shmdt, shmget, shmctl
> 
> You tested this right?   Tell me about it.
> 
> Also we could make these available to SPU programs, but I don't think there's
> any point, no one's going to do a libc update for that.
> 

The existing sys_ipc is also in the list of exceptions that are
not exported to the SPU. I don't remember what the reason for this
is, but there probably was one.

	Arnd

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

* Re: [v2,1/1] powerpc: Individual System V IPC system calls
  2015-10-13  9:38 ` [v2,1/1] " Michael Ellerman
  2015-10-13 11:46   ` Arnd Bergmann
@ 2015-10-14  7:00   ` Sam Bobroff
  2015-10-14  9:38     ` Michael Ellerman
  1 sibling, 1 reply; 7+ messages in thread
From: Sam Bobroff @ 2015-10-14  7:00 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, mikey, anton

On Tue, Oct 13, 2015 at 08:38:42PM +1100, Michael Ellerman wrote:
> On Tue, 2015-13-10 at 01:49:28 UTC, Sam bobroff wrote:
> > This patch provides individual system call numbers for the following
> > System V IPC system calls, on PowerPC, so that they do not need to be
> > multiplexed:
> > * semop, semget, semctl, semtimedop
> > * msgsnd, msgrcv, msgget, msgctl
> > * shmat, shmdt, shmget, shmctl
> 
> You tested this right? :)  Tell me about it.

Why yes I did:

I have written a (fairly) trivial test program that calls each function in a
way that doesn't fail (but that doesn't necessarily attempt to exercise the
full functionality of it; my intent was primarily to validate the parameter
passing part as that is where most of the code change is (on the glibc side)).

I patched a local copy of glibc with the new kernel header and various tweaks
to correctly format the parameter lists for the new calls (there is actually
quite a lot of code in glibc around the IPC calls due to various compatibility
issues). I could then build a full tool chain that supported the new calls.

(This was a lot more extensive than the kernel patch but should be fairly close
to what needs to go into glibc.)

I used that tool chain to build a complete host system (using buildroot). Then
I could run the following tests:

* glibc: stock
  Host kernel: stock
  Result: success
  Notes: As expected, base case.

* glibc: stock
  Host kernel: patched
  Result: success
  Notes: As expected, the old ipc() call still exists in the patched host.

* glibc: patched
  Host kernel: stock
  Result: failure
  Notes: As expected, the test was run with a glibc that requires a patched
  kernel on an unpatched one so the syscalls are unknown.

* glibc: patched
  Host kernel: patched
  Result: success
  Notes: As expected. (Also, a bit of debug in glibc shows the new system call
  paths being followed.)

(I also re-ran the tests both for little-endian and big-endian hosts.)

It would obviously be good to have someone else test this, but I can't see a
way to make it easy to do. They would presumably have to go through all of the
above, which seems too much to ask given how trivial the kernel side of the
patch is. Still, it bothers me a bit so if there is any way please let me know.
(I thought about writing some assembly to directly test the syscall numbers but
all it would do is verify that the numbers are valid, which really isn't much
of a test.)

> Also we could make these available to SPU programs, but I don't think there's
> any point, no one's going to do a libc update for that.
> 
> cheers

Cheers,
Sam.

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

* Re: [v2,1/1] powerpc: Individual System V IPC system calls
  2015-10-14  7:00   ` Sam Bobroff
@ 2015-10-14  9:38     ` Michael Ellerman
  2015-10-14 22:36       ` Sam Bobroff
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Ellerman @ 2015-10-14  9:38 UTC (permalink / raw)
  To: Sam Bobroff; +Cc: linuxppc-dev, mikey, anton

On Wed, 2015-10-14 at 18:00 +1100, Sam Bobroff wrote:
> On Tue, Oct 13, 2015 at 08:38:42PM +1100, Michael Ellerman wrote:
> > On Tue, 2015-13-10 at 01:49:28 UTC, Sam bobroff wrote:
> > > This patch provides individual system call numbers for the following
> > > System V IPC system calls, on PowerPC, so that they do not need to be
> > > multiplexed:
> > > * semop, semget, semctl, semtimedop
> > > * msgsnd, msgrcv, msgget, msgctl
> > > * shmat, shmdt, shmget, shmctl
> > 
> > You tested this right? :)  Tell me about it.
> 
> Why yes I did:

...

> (I also re-ran the tests both for little-endian and big-endian hosts.)

Did you test on 32-bit at all?

> It would obviously be good to have someone else test this, but I can't see a
> way to make it easy to do. They would presumably have to go through all of the
> above, which seems too much to ask given how trivial the kernel side of the
> patch is. Still, it bothers me a bit so if there is any way please let me know.
> (I thought about writing some assembly to directly test the syscall numbers but
> all it would do is verify that the numbers are valid, which really isn't much
> of a test.)

Actually that is still a useful test, it at least tells you if the kernel
you're running on implements the syscalls. Obviously if you're on mainline
that's easy enough to work out from the git history, but if/when these get
backported to distro kernels, it's often harder to work out what's in the
source than just testing it directly.

So I wrote a quick dirty test for that, it seems to work for me:

diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 847adf6e8d16..b120dc11aebe 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -12,7 +12,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR
 
 export CFLAGS
 
-SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks
+SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks syscalls
 
 endif
 
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
new file mode 100644
index 000000000000..b35c7945bec5
--- /dev/null
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -0,0 +1,12 @@
+TEST_PROGS := ipc_unmuxed
+
+CFLAGS += -I../../../../../usr/include
+
+all: $(TEST_PROGS)
+
+$(TEST_PROGS): ../harness.c
+
+include ../../lib.mk
+
+clean:
+	rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/syscalls/ipc.h b/tools/testing/selftests/powerpc/syscalls/ipc.h
new file mode 100644
index 000000000000..fbebc022edf6
--- /dev/null
+++ b/tools/testing/selftests/powerpc/syscalls/ipc.h
@@ -0,0 +1,47 @@
+#ifdef __NR_semop
+DO_TEST(semop, __NR_semop)
+#endif
+
+#ifdef __NR_semget
+DO_TEST(semget, __NR_semget)
+#endif
+
+#ifdef __NR_semctl
+DO_TEST(semctl, __NR_semctl)
+#endif
+
+#ifdef __NR_semtimedop
+DO_TEST(semtimedop, __NR_semtimedop)
+#endif
+
+#ifdef __NR_msgsnd
+DO_TEST(msgsnd, __NR_msgsnd)
+#endif
+
+#ifdef __NR_msgrcv
+DO_TEST(msgrcv, __NR_msgrcv)
+#endif
+
+#ifdef __NR_msgget
+DO_TEST(msgget, __NR_msgget)
+#endif
+
+#ifdef __NR_msgctl
+DO_TEST(msgctl, __NR_msgctl)
+#endif
+
+#ifdef __NR_shmat
+DO_TEST(shmat, __NR_shmat)
+#endif
+
+#ifdef __NR_shmdt
+DO_TEST(shmdt, __NR_shmdt)
+#endif
+
+#ifdef __NR_shmget
+DO_TEST(shmget, __NR_shmget)
+#endif
+
+#ifdef __NR_shmctl
+DO_TEST(shmctl, __NR_shmctl)
+#endif
diff --git a/tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c b/tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c
new file mode 100644
index 000000000000..2ac02706f8c8
--- /dev/null
+++ b/tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2015, Michael Ellerman, IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * This test simply tests that certain syscalls are implemented. It doesn't
+ * actually exercise their logic in any way.
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "utils.h"
+
+
+#define DO_TEST(_name, _num)	\
+static int test_##_name(void)			\
+{						\
+	int rc;					\
+	printf("Testing " #_name);		\
+	errno = 0;				\
+	rc = syscall(_num, -1, 0, 0, 0, 0, 0);	\
+	printf("\treturned %d, errno %d\n", rc, errno); \
+	return errno == ENOSYS;			\
+}
+
+#include "ipc.h"
+#undef DO_TEST
+
+static int ipc_unmuxed(void)
+{
+	int tests_done = 0;
+
+#define DO_TEST(_name, _num)		\
+	FAIL_IF(test_##_name());	\
+	tests_done++;
+
+#include "ipc.h"
+#undef DO_TEST
+
+	/*
+	 * If we ran no tests then it means none of the syscall numbers were
+	 * defined, possibly because we were built against old headers. But it
+	 * means we didn't really test anything, so instead of passing mark it
+	 * as a skip to give the user a clue.
+	 */
+	SKIP_IF(tests_done == 0);
+
+	return 0;
+}
+
+int main(void)
+{
+	return test_harness(ipc_unmuxed, "ipc_unmuxed");
+}


Which gives:

test: ipc_unmuxed
tags: git_version:v4.3-rc3-44-g10053fa531a8-dirty
Testing semop	returned -1, errno 22
Testing semget	returned -1, errno 2
Testing semctl	returned -1, errno 22
Testing semtimedop	returned -1, errno 22
Testing msgsnd	returned -1, errno 14
Testing msgrcv	returned -1, errno 22
Testing msgget	returned -1, errno 2
Testing msgctl	returned -1, errno 22
Testing shmat	returned -1, errno 22
Testing shmdt	returned -1, errno 22
Testing shmget	returned -1, errno 2
Testing shmctl	returned -1, errno 22
success: ipc_unmuxed


And on an unpatched system:

test: ipc_unmuxed
tags: git_version:v4.3-rc3-44-g10053fa531a8-dirty
Testing semop	returned -1, errno 38
[FAIL] Test FAILED on line 2
failure: ipc_unmuxed


Look OK?

cheers

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

* Re: [v2,1/1] powerpc: Individual System V IPC system calls
  2015-10-14  9:38     ` Michael Ellerman
@ 2015-10-14 22:36       ` Sam Bobroff
  0 siblings, 0 replies; 7+ messages in thread
From: Sam Bobroff @ 2015-10-14 22:36 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, mikey, anton

On Wed, Oct 14, 2015 at 08:38:15PM +1100, Michael Ellerman wrote:
> On Wed, 2015-10-14 at 18:00 +1100, Sam Bobroff wrote:
> > On Tue, Oct 13, 2015 at 08:38:42PM +1100, Michael Ellerman wrote:
> > > On Tue, 2015-13-10 at 01:49:28 UTC, Sam bobroff wrote:
> > > > This patch provides individual system call numbers for the following
> > > > System V IPC system calls, on PowerPC, so that they do not need to be
> > > > multiplexed:
> > > > * semop, semget, semctl, semtimedop
> > > > * msgsnd, msgrcv, msgget, msgctl
> > > > * shmat, shmdt, shmget, shmctl
> > > 
> > > You tested this right? :)  Tell me about it.
> > 
> > Why yes I did:
> 
> ...
> 
> > (I also re-ran the tests both for little-endian and big-endian hosts.)
> 
> Did you test on 32-bit at all?

I ran the test program, compiled for 32 and 64 bit, on a biarch power7 machine
(using -m32 and -m64 to the compiler) but only to verify that the fully patched
system succeeded. Is that sufficient?

> > It would obviously be good to have someone else test this, but I can't see a
> > way to make it easy to do. They would presumably have to go through all of the
> > above, which seems too much to ask given how trivial the kernel side of the
> > patch is. Still, it bothers me a bit so if there is any way please let me know.
> > (I thought about writing some assembly to directly test the syscall numbers but
> > all it would do is verify that the numbers are valid, which really isn't much
> > of a test.)
> 
> Actually that is still a useful test, it at least tells you if the kernel
> you're running on implements the syscalls. Obviously if you're on mainline
> that's easy enough to work out from the git history, but if/when these get
> backported to distro kernels, it's often harder to work out what's in the
> source than just testing it directly.

Oh, fair enough then.

> So I wrote a quick dirty test for that, it seems to work for me:

[snip]

Thanks :-)

> Which gives:
> 
> test: ipc_unmuxed
> tags: git_version:v4.3-rc3-44-g10053fa531a8-dirty
> Testing semop	returned -1, errno 22
> Testing semget	returned -1, errno 2
> Testing semctl	returned -1, errno 22
> Testing semtimedop	returned -1, errno 22
> Testing msgsnd	returned -1, errno 14
> Testing msgrcv	returned -1, errno 22
> Testing msgget	returned -1, errno 2
> Testing msgctl	returned -1, errno 22
> Testing shmat	returned -1, errno 22
> Testing shmdt	returned -1, errno 22
> Testing shmget	returned -1, errno 2
> Testing shmctl	returned -1, errno 22
> success: ipc_unmuxed
> 
> 
> And on an unpatched system:
> 
> test: ipc_unmuxed
> tags: git_version:v4.3-rc3-44-g10053fa531a8-dirty
> Testing semop	returned -1, errno 38
> [FAIL] Test FAILED on line 2
> failure: ipc_unmuxed
> 
> 
> Look OK?

Yep! And 38 (ENOSYS) is the code we'd expect in the failure case.

> cheers

Cheers,
Sam.

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

* Re: [v2,1/1] powerpc: Individual System V IPC system calls
  2015-10-13  1:49 [PATCH v2 1/1] powerpc: Individual System V IPC system calls Sam Bobroff
  2015-10-13  9:38 ` [v2,1/1] " Michael Ellerman
@ 2015-10-15 11:10 ` Michael Ellerman
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2015-10-15 11:10 UTC (permalink / raw)
  To: Sam bobroff, linuxppc-dev; +Cc: mikey, anton

On Tue, 2015-13-10 at 01:49:28 UTC, Sam bobroff wrote:
> This patch provides individual system call numbers for the following
> System V IPC system calls, on PowerPC, so that they do not need to be
> multiplexed:
> * semop, semget, semctl, semtimedop
> * msgsnd, msgrcv, msgget, msgctl
> * shmat, shmdt, shmget, shmctl
> 
> Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/a34236155afb1cc41945e583

cheers

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

end of thread, other threads:[~2015-10-15 11:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-13  1:49 [PATCH v2 1/1] powerpc: Individual System V IPC system calls Sam Bobroff
2015-10-13  9:38 ` [v2,1/1] " Michael Ellerman
2015-10-13 11:46   ` Arnd Bergmann
2015-10-14  7:00   ` Sam Bobroff
2015-10-14  9:38     ` Michael Ellerman
2015-10-14 22:36       ` Sam Bobroff
2015-10-15 11:10 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.