Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: e5ab8be68e44 ("selftests/powerpc: Test preservation of FPU and VMX regs across preemption")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231128132748.1990179-1-mpe@ellerman.id.au

+11 -8
+5 -4
tools/testing/selftests/powerpc/math/fpu_preempt.c
··· 37 37 int threads_starting; 38 38 int running; 39 39 40 - extern void preempt_fpu(double *darray, int *threads_starting, int *running); 40 + extern int preempt_fpu(double *darray, int *threads_starting, int *running); 41 41 42 42 void *preempt_fpu_c(void *p) 43 43 { 44 + long rc; 44 45 int i; 46 + 45 47 srand(pthread_self()); 46 48 for (i = 0; i < 21; i++) 47 49 darray[i] = rand(); 48 50 49 - /* Test failed if it ever returns */ 50 - preempt_fpu(darray, &threads_starting, &running); 51 + rc = preempt_fpu(darray, &threads_starting, &running); 51 52 52 - return p; 53 + return (void *)rc; 53 54 } 54 55 55 56 int test_preempt_fpu(void)
+6 -4
tools/testing/selftests/powerpc/math/vmx_preempt.c
··· 37 37 int threads_starting; 38 38 int running; 39 39 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); 41 41 42 42 void *preempt_vmx_c(void *p) 43 43 { 44 44 int i, j; 45 + long rc; 46 + 45 47 srand(pthread_self()); 46 48 for (i = 0; i < 12; i++) 47 49 for (j = 0; j < 4; j++) 48 50 varray[i][j] = rand(); 49 51 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; 53 55 } 54 56 55 57 int test_preempt_vmx(void)