Skip to content

Commit 872d11b

Browse files
committed
selftests/powerpc: Skip vmx/vsx/tar/etc tests on older CPUs
Some of our tests use VSX or newer VMX instructions, so need to be skipped on older CPUs to avoid SIGILL'ing. Similarly TAR was added in v2.07, and the PMU event used in the stcx fail test only works on Power8 or later. Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8d8a629 commit 872d11b

File tree

10 files changed

+34
-6
lines changed

10 files changed

+34
-6
lines changed

tools/testing/selftests/powerpc/math/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ $(OUTPUT)/fpu_syscall: fpu_asm.S
1111
$(OUTPUT)/fpu_preempt: fpu_asm.S
1212
$(OUTPUT)/fpu_signal: fpu_asm.S
1313

14-
$(OUTPUT)/vmx_syscall: vmx_asm.S
15-
$(OUTPUT)/vmx_preempt: vmx_asm.S
16-
$(OUTPUT)/vmx_signal: vmx_asm.S
14+
$(OUTPUT)/vmx_syscall: vmx_asm.S ../utils.c
15+
$(OUTPUT)/vmx_preempt: vmx_asm.S ../utils.c
16+
$(OUTPUT)/vmx_signal: vmx_asm.S ../utils.c
1717

1818
$(OUTPUT)/vsx_preempt: CFLAGS += -mvsx
19-
$(OUTPUT)/vsx_preempt: vsx_asm.S
19+
$(OUTPUT)/vsx_preempt: vsx_asm.S ../utils.c

tools/testing/selftests/powerpc/math/vmx_preempt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ int test_preempt_vmx(void)
5757
int i, rc, threads;
5858
pthread_t *tids;
5959

60+
// vcmpequd used in vmx_asm.S is v2.07
61+
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
62+
6063
threads = sysconf(_SC_NPROCESSORS_ONLN) * THREAD_FACTOR;
6164
tids = malloc(threads * sizeof(pthread_t));
6265
FAIL_IF(!tids);

tools/testing/selftests/powerpc/math/vmx_signal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ int test_signal_vmx(void)
9696
void *rc_p;
9797
pthread_t *tids;
9898

99+
// vcmpequd used in vmx_asm.S is v2.07
100+
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
101+
99102
threads = sysconf(_SC_NPROCESSORS_ONLN) * THREAD_FACTOR;
100103
tids = malloc(threads * sizeof(pthread_t));
101104
FAIL_IF(!tids);

tools/testing/selftests/powerpc/math/vmx_syscall.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ int test_vmx_syscall(void)
4949
* Setup an environment with much context switching
5050
*/
5151
pid_t pid2;
52-
pid_t pid = fork();
52+
pid_t pid;
5353
int ret;
5454
int child_ret;
55+
56+
// vcmpequd used in vmx_asm.S is v2.07
57+
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
58+
59+
pid = fork();
5560
FAIL_IF(pid == -1);
5661

5762
pid2 = fork();

tools/testing/selftests/powerpc/math/vsx_preempt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ int test_preempt_vsx(void)
9292
int i, rc, threads;
9393
pthread_t *tids;
9494

95+
SKIP_IF(!have_hwcap(PPC_FEATURE_HAS_VSX));
96+
9597
threads = sysconf(_SC_NPROCESSORS_ONLN) * THREAD_FACTOR;
9698
tids = malloc(threads * sizeof(pthread_t));
9799
FAIL_IF(!tids);

tools/testing/selftests/powerpc/pmu/count_stcx_fail.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdbool.h>
1010
#include <string.h>
1111
#include <sys/prctl.h>
12+
#include <asm/cputable.h>
1213

1314
#include "event.h"
1415
#include "utils.h"
@@ -104,6 +105,9 @@ static int test_body(void)
104105
struct event events[3];
105106
u64 overhead;
106107

108+
// The STCX_FAIL event we use works on Power8 or later
109+
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
110+
107111
setup_event(&events[0], PERF_COUNT_HW_INSTRUCTIONS, PERF_TYPE_HARDWARE, "instructions");
108112
setup_event(&events[1], PERF_COUNT_HW_CPU_CYCLES, PERF_TYPE_HARDWARE, "cycles");
109113
setup_event(&events[2], PM_STCX_FAIL, PERF_TYPE_RAW, "stcx_fail");

tools/testing/selftests/powerpc/ptrace/ptrace-tar.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ int ptrace_tar(void)
7878
pid_t pid;
7979
int ret, status;
8080

81+
// TAR was added in v2.07
82+
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
83+
8184
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3, 0777|IPC_CREAT);
8285
pid = fork();
8386
if (pid < 0) {

tools/testing/selftests/powerpc/ptrace/ptrace-vsx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ int ptrace_vsx(void)
6161
pid_t pid;
6262
int ret, status, i;
6363

64+
SKIP_IF(!have_hwcap(PPC_FEATURE_HAS_VSX));
65+
6466
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
6567

6668
for (i = 0; i < VEC_MAX; i++)

tools/testing/selftests/powerpc/stringloops/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build_32bit = $(shell if ($(CC) $(CFLAGS) -m32 -o /dev/null memcmp.c >/dev/null
88

99
TEST_GEN_PROGS := memcmp_64 strlen
1010

11-
$(OUTPUT)/memcmp_64: memcmp.c
11+
$(OUTPUT)/memcmp_64: memcmp.c ../utils.c
1212
$(OUTPUT)/memcmp_64: CFLAGS += -m64 -maltivec
1313

1414
ifeq ($(build_32bit),1)

tools/testing/selftests/powerpc/stringloops/memcmp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <string.h>
55
#include <sys/mman.h>
66
#include <time.h>
7+
#include <asm/cputable.h>
78
#include "utils.h"
89

910
#define SIZE 256
@@ -151,6 +152,11 @@ static int testcase(bool islarge)
151152

152153
static int testcases(void)
153154
{
155+
#ifdef __powerpc64__
156+
// vcmpequd used in memcmp_64.S is v2.07
157+
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
158+
#endif
159+
154160
testcase(0);
155161
testcase(1);
156162
return 0;

0 commit comments

Comments
 (0)