mirror of https://gitee.com/openkylin/linux.git
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 <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200803020719.96114-1-mpe@ellerman.id.au
This commit is contained in:
parent
8d8a629d00
commit
872d11bca9
|
@ -11,9 +11,9 @@ $(OUTPUT)/fpu_syscall: fpu_asm.S
|
|||
$(OUTPUT)/fpu_preempt: fpu_asm.S
|
||||
$(OUTPUT)/fpu_signal: fpu_asm.S
|
||||
|
||||
$(OUTPUT)/vmx_syscall: vmx_asm.S
|
||||
$(OUTPUT)/vmx_preempt: vmx_asm.S
|
||||
$(OUTPUT)/vmx_signal: vmx_asm.S
|
||||
$(OUTPUT)/vmx_syscall: vmx_asm.S ../utils.c
|
||||
$(OUTPUT)/vmx_preempt: vmx_asm.S ../utils.c
|
||||
$(OUTPUT)/vmx_signal: vmx_asm.S ../utils.c
|
||||
|
||||
$(OUTPUT)/vsx_preempt: CFLAGS += -mvsx
|
||||
$(OUTPUT)/vsx_preempt: vsx_asm.S
|
||||
$(OUTPUT)/vsx_preempt: vsx_asm.S ../utils.c
|
||||
|
|
|
@ -57,6 +57,9 @@ int test_preempt_vmx(void)
|
|||
int i, rc, threads;
|
||||
pthread_t *tids;
|
||||
|
||||
// vcmpequd used in vmx_asm.S is v2.07
|
||||
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
|
||||
|
||||
threads = sysconf(_SC_NPROCESSORS_ONLN) * THREAD_FACTOR;
|
||||
tids = malloc(threads * sizeof(pthread_t));
|
||||
FAIL_IF(!tids);
|
||||
|
|
|
@ -96,6 +96,9 @@ int test_signal_vmx(void)
|
|||
void *rc_p;
|
||||
pthread_t *tids;
|
||||
|
||||
// vcmpequd used in vmx_asm.S is v2.07
|
||||
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
|
||||
|
||||
threads = sysconf(_SC_NPROCESSORS_ONLN) * THREAD_FACTOR;
|
||||
tids = malloc(threads * sizeof(pthread_t));
|
||||
FAIL_IF(!tids);
|
||||
|
|
|
@ -49,9 +49,14 @@ int test_vmx_syscall(void)
|
|||
* Setup an environment with much context switching
|
||||
*/
|
||||
pid_t pid2;
|
||||
pid_t pid = fork();
|
||||
pid_t pid;
|
||||
int ret;
|
||||
int child_ret;
|
||||
|
||||
// vcmpequd used in vmx_asm.S is v2.07
|
||||
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
|
||||
|
||||
pid = fork();
|
||||
FAIL_IF(pid == -1);
|
||||
|
||||
pid2 = fork();
|
||||
|
|
|
@ -92,6 +92,8 @@ int test_preempt_vsx(void)
|
|||
int i, rc, threads;
|
||||
pthread_t *tids;
|
||||
|
||||
SKIP_IF(!have_hwcap(PPC_FEATURE_HAS_VSX));
|
||||
|
||||
threads = sysconf(_SC_NPROCESSORS_ONLN) * THREAD_FACTOR;
|
||||
tids = malloc(threads * sizeof(pthread_t));
|
||||
FAIL_IF(!tids);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <asm/cputable.h>
|
||||
|
||||
#include "event.h"
|
||||
#include "utils.h"
|
||||
|
@ -104,6 +105,9 @@ static int test_body(void)
|
|||
struct event events[3];
|
||||
u64 overhead;
|
||||
|
||||
// The STCX_FAIL event we use works on Power8 or later
|
||||
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
|
||||
|
||||
setup_event(&events[0], PERF_COUNT_HW_INSTRUCTIONS, PERF_TYPE_HARDWARE, "instructions");
|
||||
setup_event(&events[1], PERF_COUNT_HW_CPU_CYCLES, PERF_TYPE_HARDWARE, "cycles");
|
||||
setup_event(&events[2], PM_STCX_FAIL, PERF_TYPE_RAW, "stcx_fail");
|
||||
|
|
|
@ -78,6 +78,9 @@ int ptrace_tar(void)
|
|||
pid_t pid;
|
||||
int ret, status;
|
||||
|
||||
// TAR was added in v2.07
|
||||
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
|
||||
|
||||
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3, 0777|IPC_CREAT);
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
|
|
|
@ -61,6 +61,8 @@ int ptrace_vsx(void)
|
|||
pid_t pid;
|
||||
int ret, status, i;
|
||||
|
||||
SKIP_IF(!have_hwcap(PPC_FEATURE_HAS_VSX));
|
||||
|
||||
shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
|
||||
|
||||
for (i = 0; i < VEC_MAX; i++)
|
||||
|
|
|
@ -8,7 +8,7 @@ build_32bit = $(shell if ($(CC) $(CFLAGS) -m32 -o /dev/null memcmp.c >/dev/null
|
|||
|
||||
TEST_GEN_PROGS := memcmp_64 strlen
|
||||
|
||||
$(OUTPUT)/memcmp_64: memcmp.c
|
||||
$(OUTPUT)/memcmp_64: memcmp.c ../utils.c
|
||||
$(OUTPUT)/memcmp_64: CFLAGS += -m64 -maltivec
|
||||
|
||||
ifeq ($(build_32bit),1)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <time.h>
|
||||
#include <asm/cputable.h>
|
||||
#include "utils.h"
|
||||
|
||||
#define SIZE 256
|
||||
|
@ -151,6 +152,11 @@ static int testcase(bool islarge)
|
|||
|
||||
static int testcases(void)
|
||||
{
|
||||
#ifdef __powerpc64__
|
||||
// vcmpequd used in memcmp_64.S is v2.07
|
||||
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
|
||||
#endif
|
||||
|
||||
testcase(0);
|
||||
testcase(1);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue