Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0200560 authored by Michael Ellerman's avatar Michael Ellerman Committed by Greg Kroah-Hartman
Browse files

selftests/powerpc: Fix error handling in FPU/VMX preemption tests



[ Upstream commit 9dbd5927408c4a0707de73ae9dd9306b184e8fee ]

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


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9b5f0350
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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,
int threads_starting;
int running;

extern void preempt_fpu(double *darray, int *threads_starting, int *running);
extern int preempt_fpu(double *darray, int *threads_starting, int *running);

void *preempt_fpu_c(void *p)
{
	long rc;
	int i;

	srand(pthread_self());
	for (i = 0; i < 21; i++)
		darray[i] = rand();

	/* Test failed if it ever returns */
	preempt_fpu(darray, &threads_starting, &running);
	rc = preempt_fpu(darray, &threads_starting, &running);

	return p;
	return (void *)rc;
}

int test_preempt_fpu(void)
+6 −4
Original line number Diff line number Diff line
@@ -37,19 +37,21 @@ __thread vector int varray[] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10,11,12},
int threads_starting;
int running;

extern void preempt_vmx(vector int *varray, int *threads_starting, int *running);
extern int preempt_vmx(vector int *varray, int *threads_starting, int *running);

void *preempt_vmx_c(void *p)
{
	int i, j;
	long rc;

	srand(pthread_self());
	for (i = 0; i < 12; i++)
		for (j = 0; j < 4; j++)
			varray[i][j] = rand();

	/* Test fails if it ever returns */
	preempt_vmx(varray, &threads_starting, &running);
	return p;
	rc = preempt_vmx(varray, &threads_starting, &running);

	return (void *)rc;
}

int test_preempt_vmx(void)