Skip to content

Commit 9dbd592

Browse files
committed
selftests/powerpc: Fix error handling in FPU/VMX preemption tests
The FPU & VMX preemption tests do not check for errors returned by the low-level asm routines, preempt_fpu() / preempt_vsx() respectively. That means any register corruption detected by the asm routines does not result in a test failure. Fix it by returning the return value of the asm routines from the pthread child routines. Fixes: e5ab8be ("selftests/powerpc: Test preservation of FPU and VMX regs across preemption") Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 402928b commit 9dbd592

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,20 @@ __thread double darray[] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
3737
int threads_starting;
3838
int running;
3939

40-
extern void preempt_fpu(double *darray, int *threads_starting, int *running);
40+
extern int preempt_fpu(double *darray, int *threads_starting, int *running);
4141

4242
void *preempt_fpu_c(void *p)
4343
{
44+
long rc;
4445
int i;
46+
4547
srand(pthread_self());
4648
for (i = 0; i < 21; i++)
4749
darray[i] = rand();
4850

49-
/* Test failed if it ever returns */
50-
preempt_fpu(darray, &threads_starting, &running);
51+
rc = preempt_fpu(darray, &threads_starting, &running);
5152

52-
return p;
53+
return (void *)rc;
5354
}
5455

5556
int test_preempt_fpu(void)

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ __thread vector int varray[] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10,11,12},
3737
int threads_starting;
3838
int running;
3939

40-
extern void preempt_vmx(vector int *varray, int *threads_starting, int *running);
40+
extern int preempt_vmx(vector int *varray, int *threads_starting, int *running);
4141

4242
void *preempt_vmx_c(void *p)
4343
{
4444
int i, j;
45+
long rc;
46+
4547
srand(pthread_self());
4648
for (i = 0; i < 12; i++)
4749
for (j = 0; j < 4; j++)
4850
varray[i][j] = rand();
4951

50-
/* Test fails if it ever returns */
51-
preempt_vmx(varray, &threads_starting, &running);
52-
return p;
52+
rc = preempt_vmx(varray, &threads_starting, &running);
53+
54+
return (void *)rc;
5355
}
5456

5557
int test_preempt_vmx(void)

0 commit comments

Comments
 (0)