selftests/powerpc: Fix fpu_signal failures

My recent commit e5d00aaac651 ("selftests/powerpc: Check all FPRs in
fpu_preempt") inadvertently broke the fpu_signal test.

It needs to take into account that fpu_preempt now loads 32 FPRs, so
enlarge darray.

Also use the newly added randomise_darray() to properly randomise darray.

Finally the checking done in signal_fpu_sig() needs to skip checking
f30/f31, because they are used as scratch registers in check_all_fprs(),
called by preempt_fpu(), and so could hold other values when the signal
is taken.

Fixes: e5d00aaac651 ("selftests/powerpc: Check all FPRs in fpu_preempt")
Reported-by: Spoorthy <spoorthy@linux.ibm.com>
Depends-on: 2ba107f6795d ("selftests/powerpc: Generate better bit patterns for FPU tests")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240301101035.1230024-1-mpe@ellerman.id.au

Changed files
+6 -10
tools
testing
selftests
powerpc
+6 -10
tools/testing/selftests/powerpc/math/fpu_signal.c
··· 18 18 #include <pthread.h> 19 19 20 20 #include "utils.h" 21 + #include "fpu.h" 21 22 22 23 /* Number of times each thread should receive the signal */ 23 24 #define ITERATIONS 10 ··· 28 27 */ 29 28 #define THREAD_FACTOR 8 30 29 31 - __thread double darray[] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 32 - 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 33 - 2.1}; 30 + __thread double darray[32]; 34 31 35 32 bool bad_context; 36 33 int threads_starting; ··· 42 43 ucontext_t *uc = context; 43 44 mcontext_t *mc = &uc->uc_mcontext; 44 45 45 - /* Only the non volatiles were loaded up */ 46 - for (i = 14; i < 32; i++) { 47 - if (mc->fp_regs[i] != darray[i - 14]) { 46 + // Don't check f30/f31, they're used as scratches in check_all_fprs() 47 + for (i = 0; i < 30; i++) { 48 + if (mc->fp_regs[i] != darray[i]) { 48 49 bad_context = true; 49 50 break; 50 51 } ··· 53 54 54 55 void *signal_fpu_c(void *p) 55 56 { 56 - int i; 57 57 long rc; 58 58 struct sigaction act; 59 59 act.sa_sigaction = signal_fpu_sig; ··· 62 64 return p; 63 65 64 66 srand(pthread_self()); 65 - for (i = 0; i < 21; i++) 66 - darray[i] = rand(); 67 - 67 + randomise_darray(darray, ARRAY_SIZE(darray)); 68 68 rc = preempt_fpu(darray, &threads_starting, &running); 69 69 70 70 return (void *) rc;