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

Commit b8340673 authored by Paul Burton's avatar Paul Burton Committed by Ralf Baechle
Browse files

MIPS: preserve scalar FP CSR when switching vector context



Switching the vector context implicitly saves & restores the state of
the aliased scalar FP data registers, however the scalar FP control
& status register is distinct from the MSA control & status register.
In order to allow scalar FP to function correctly in programs using
MSA, the scalar CSR needs to be saved & restored along with the MSA
vector context.

Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7301/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent f7a46fa7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -64,8 +64,10 @@
	/* Check whether we're saving scalar or vector context. */
	bgtz	a3, 1f

	/* Save 128b MSA vector context. */
	/* Save 128b MSA vector context + scalar FP control & status. */
	cfc1	t1, fcr31
	msa_save_all	a0
	sw	t1, THREAD_FCR31(a0)
	b	2f

1:	/* Save 32b/64b scalar FP context. */
+5 −0
Original line number Diff line number Diff line
@@ -1154,6 +1154,11 @@ static int enable_restore_fp_context(int msa)

	/* We need to restore the vector context. */
	restore_msa(current);

	/* Restore the scalar FP control & status register */
	if (!was_fpu_owner)
		asm volatile("ctc1 %0, $31" : : "r"(current->thread.fpu.fcr31));

	return 0;
}