selftests/powerpc: fix exec benchmark
Nicholas Piggin
reviewerPATCH 1/1 selftests/powerpc: fix exec benchmark
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.
--- tools/testing/selftests/powerpc/benchmarks/exec_target.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/powerpc/benchmarks/exec_target.c +5 -2
@@ -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 ); }
Signature · 1 line
2.17.0
Nick,
Quoted 29 lines · Nicholas Piggin
The
exec_targetbinary could segfault calling_exit(2)because r13 is not set up properly (and libc looks at that when performing a syscall). CallSYS_exitusing syscall(2) which doesn't seem to have this problem.Signed-off-by Nicholas Piggin <[email protected]>--- tools/testing/selftests/powerpc/benchmarks/exec_target.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/testing/selftests/powerpc/benchmarks/exec_target.c +5
-3@@ -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 ); } --
Quoted 2 lines
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
Quoted 37 lines · Mathieu Malaterre
Nick,
Quoted 29 lines · Nicholas Piggin
The
exec_targetbinary could segfault calling_exit(2)because r13 is not set up properly (and libc looks at that when performing a syscall). CallSYS_exitusing syscall(2) which doesn't seem to have this problem.Signed-off-by Nicholas Piggin <[email protected]>--- tools/testing/selftests/powerpc/benchmarks/exec_target.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/testing/selftests/powerpc/benchmarks/exec_target.c +5
-3@@ -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 ); } --Quoted 2 lines
2.17.0
Could you please apply the same patch to :
Quoted 3 lines
./tools/testing/selftests/size/get_size.cIt 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.
Michael Ellerman
AppliedQuoted 6 lines · Nicholas Piggin
The
exec_targetbinary could segfault calling_exit(2)because r13 is not set up properly (and libc looks at that when performing a syscall). CallSYS_exitusing syscall(2) which doesn't seem to have this problem.Signed-off-by Nicholas Piggin <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/c906d2c74e0bb9059fbf43e21f8a96
cheers