Skip to content

Commit 380cb2f

Browse files
committed
selftests/powerpc: Fix fpu_signal failures
My recent commit e5d00aa ("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: e5d00aa ("selftests/powerpc: Check all FPRs in fpu_preempt") Reported-by: Spoorthy <[email protected]> Depends-on: 2ba107f ("selftests/powerpc: Generate better bit patterns for FPU tests") Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent fad87db commit 380cb2f

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <pthread.h>
1919

2020
#include "utils.h"
21+
#include "fpu.h"
2122

2223
/* Number of times each thread should receive the signal */
2324
#define ITERATIONS 10
@@ -27,9 +28,7 @@
2728
*/
2829
#define THREAD_FACTOR 8
2930

30-
__thread double darray[] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
31-
1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0,
32-
2.1};
31+
__thread double darray[32];
3332

3433
bool bad_context;
3534
int threads_starting;
@@ -43,9 +42,9 @@ void signal_fpu_sig(int sig, siginfo_t *info, void *context)
4342
ucontext_t *uc = context;
4443
mcontext_t *mc = &uc->uc_mcontext;
4544

46-
/* Only the non volatiles were loaded up */
47-
for (i = 14; i < 32; i++) {
48-
if (mc->fp_regs[i] != darray[i - 14]) {
45+
// Don't check f30/f31, they're used as scratches in check_all_fprs()
46+
for (i = 0; i < 30; i++) {
47+
if (mc->fp_regs[i] != darray[i]) {
4948
bad_context = true;
5049
break;
5150
}
@@ -54,7 +53,6 @@ void signal_fpu_sig(int sig, siginfo_t *info, void *context)
5453

5554
void *signal_fpu_c(void *p)
5655
{
57-
int i;
5856
long rc;
5957
struct sigaction act;
6058
act.sa_sigaction = signal_fpu_sig;
@@ -64,9 +62,7 @@ void *signal_fpu_c(void *p)
6462
return p;
6563

6664
srand(pthread_self());
67-
for (i = 0; i < 21; i++)
68-
darray[i] = rand();
69-
65+
randomise_darray(darray, ARRAY_SIZE(darray));
7066
rc = preempt_fpu(darray, &threads_starting, &running);
7167

7268
return (void *) rc;

0 commit comments

Comments
 (0)