[PATCH] selftests/powerpc: fix exec benchmark

Subsystems: kernel selftest framework, the rest

STALE3064d

4 messages, 3 authors, 2018-05-16 · open the first message on its own page

[PATCH] selftests/powerpc: fix exec benchmark

From: Nicholas Piggin <npiggin@gmail.com>
Date: 2018-05-12 03:35:40

The exec_target binary could segfault calling _exit(2) because r13
is not set up properly (and libc looks at that when performing a
syscall). Call SYS_exit using syscall(2) which doesn't seem to
have this problem.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 tools/testing/selftests/powerpc/benchmarks/exec_target.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/powerpc/benchmarks/exec_target.c b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
index 3c9c144192be..c14b0fc1edde 100644
--- a/tools/testing/selftests/powerpc/benchmarks/exec_target.c
+++ b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
@@ -6,8 +6,11 @@
  * Copyright 2018, Anton Blanchard, IBM Corp.
  */
 
-void _exit(int);
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/syscall.h>
+
 void _start(void)
 {
-	_exit(0);
+	syscall(SYS_exit, 0);
 }
-- 
2.17.0

Re: [PATCH] selftests/powerpc: fix exec benchmark

From: Mathieu Malaterre <hidden>
Date: 2018-05-12 08:54:26

Nick,

On Sat, May 12, 2018 at 5:35 AM, Nicholas Piggin [off-list ref] wrote:
quoted hunk
The exec_target binary could segfault calling _exit(2) because r13
is not set up properly (and libc looks at that when performing a
syscall). Call SYS_exit using syscall(2) which doesn't seem to
have this problem.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 tools/testing/selftests/powerpc/benchmarks/exec_target.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/powerpc/benchmarks/exec_target.c b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
index 3c9c144192be..c14b0fc1edde 100644
--- a/tools/testing/selftests/powerpc/benchmarks/exec_target.c
+++ b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
@@ -6,8 +6,11 @@
  * Copyright 2018, Anton Blanchard, IBM Corp.
  */

-void _exit(int);
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/syscall.h>
+
 void _start(void)
 {
-       _exit(0);
+       syscall(SYS_exit, 0);
 }
--
2.17.0
Could you please apply the same patch to :

./tools/testing/selftests/size/get_size.c

It segfault on ppc32 with default cross compiler from Debian.

Thanks

Re: [PATCH] selftests/powerpc: fix exec benchmark

From: Mathieu Malaterre <hidden>
Date: 2018-05-12 16:36:04

On Sat, May 12, 2018 at 10:54 AM, Mathieu Malaterre [off-list ref] wrote:
Nick,

On Sat, May 12, 2018 at 5:35 AM, Nicholas Piggin [off-list ref] wrote:
quoted
The exec_target binary could segfault calling _exit(2) because r13
is not set up properly (and libc looks at that when performing a
syscall). Call SYS_exit using syscall(2) which doesn't seem to
have this problem.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 tools/testing/selftests/powerpc/benchmarks/exec_target.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/powerpc/benchmarks/exec_target.c b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
index 3c9c144192be..c14b0fc1edde 100644
--- a/tools/testing/selftests/powerpc/benchmarks/exec_target.c
+++ b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
@@ -6,8 +6,11 @@
  * Copyright 2018, Anton Blanchard, IBM Corp.
  */

-void _exit(int);
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/syscall.h>
+
 void _start(void)
 {
-       _exit(0);
+       syscall(SYS_exit, 0);
 }
--
2.17.0
Could you please apply the same patch to :

./tools/testing/selftests/size/get_size.c

It segfault on ppc32 with default cross compiler from Debian.
Nevermind, I did not tested and this seems not to be sufficient to
make the executable run properly.

Re: selftests/powerpc: fix exec benchmark

From: Michael Ellerman <hidden>
Date: 2018-05-16 13:38:52

On Sat, 2018-05-12 at 03:35:24 UTC, Nicholas Piggin wrote:
The exec_target binary could segfault calling _exit(2) because r13
is not set up properly (and libc looks at that when performing a
syscall). Call SYS_exit using syscall(2) which doesn't seem to
have this problem.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Applied to powerpc next, thanks.

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

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help