Commit 49d3e90f authored by Mao Minkai's avatar Mao Minkai Committed by guzitao
Browse files

sw64: save and restore CSR_WR_FREGS for SIMD libs

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB73UR



--------------------------------

If the lib uses SIMD optimization, save CSR_WR_FREGS before the main
part and restore it afterwards to avoid clobbering user SIMD state.

Signed-off-by: default avatarMao Minkai <maominkai@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 91b709ff
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
/*
 * Zero an entire page.
 */
#include <asm/csr.h>
#include <asm/export.h>
	.text
	.align 4
@@ -37,6 +38,9 @@ clear_page:
	stl_nc	$31,0x78($16)
*/

#ifdef CONFIG_SUBARCH_C4
	csrr	$7, CSR_WR_FREGS
#endif
	vstd_nc	$f31, 0x0($16)
	vstd_nc	$f31, 0x20($16)
	subl	$0, 1, $0
@@ -47,6 +51,9 @@ clear_page:
	bne	$0, 1b

	memb
#ifdef CONFIG_SUBARCH_C4
	csrw	$7, CSR_WR_FREGS
#endif
	ret

	.end clear_page
+7 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
 * stuff.
 *
 */
#include <asm/csr.h>
#include <asm/export.h>
/* Allow an exception for an insn; exit if we get one.  */
#define FIXUP_LDST(x,y...)			\
@@ -34,6 +35,9 @@ ____clear_user_simd_force_ali_addr:
	bis	$31, $31, $7
	mov	$17, $18
	bis	$31, $31, $17
#ifdef CONFIG_SUBARCH_C4
	csrr	$6, CSR_WR_FREGS
#endif
#include "deep-set_template-force_ali_addr.S"
255:
	bis	$31, $18, $0
@@ -43,5 +47,8 @@ $restore_simd:
	RESTORE_SIMD_REGS

$return:
#ifdef CONFIG_SUBARCH_C4
	csrw	$6, CSR_WR_FREGS
#endif
	ret
	.end ____clear_user_simd_force_ali_addr
+7 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
 * stuff.
 *
 */
#include <asm/csr.h>
#include <asm/export.h>
/* Allow an exception for an insn; exit if we get one.  */
#define FIXUP_LDST(x,y...)			\
@@ -34,6 +35,9 @@ ____clear_user_simd_no_una_check:
	bis	$31, $31, $7
	mov	$17, $18
	bis	$31, $31, $17
#ifdef CONFIG_SUBARCH_C4
	csrr	$6, CSR_WR_FREGS
#endif
#include "deep-set_template-no_una_check.S"
255:
	bis	$31, $18, $0
@@ -43,5 +47,8 @@ $restore_simd:
	RESTORE_SIMD_REGS

$return:
#ifdef CONFIG_SUBARCH_C4
	csrw	$6, CSR_WR_FREGS
#endif
	ret
	.end ____clear_user_simd_no_una_check
+8 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#include <asm/csr.h>

/* Allow an exception for an insn; exit if we get one.  */
#define FIXUP_LDST(x, y)			\
	99: x, y;			\
@@ -25,6 +27,9 @@ ____copy_user_simd_force_ali_addr:
	.prologue 0
	.set noreorder
	bis	$31, $31, $7
#ifdef CONFIG_SUBARCH_C4
	csrr	$6, CSR_WR_FREGS
#endif
#include "deep-copy_template-force_ali_addr.S"
255:
	bis	$31, $18, $0
@@ -40,5 +45,8 @@ $restore_simd:
	RESTORE_SIMD_REGS

$return:
#ifdef CONFIG_SUBARCH_C4
	csrw	$6, CSR_WR_FREGS
#endif
	ret
	.end ____copy_user_simd_force_ali_addr
+8 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#include <asm/csr.h>

/* Allow an exception for an insn; exit if we get one.  */
#define FIXUP_LDST(x, y)			\
	99: x, y;			\
@@ -25,6 +27,9 @@ ____copy_user_simd_no_una_check:
	.prologue 0
	.set noreorder
	bis	$31, $31, $7
#ifdef CONFIG_SUBARCH_C4
	csrr	$6, CSR_WR_FREGS
#endif
#include "deep-copy_template-no_una_check.S"
255:
	bis	$31, $18, $0
@@ -36,5 +41,8 @@ $restore_simd:
	RESTORE_SIMD_REGS

$return:
#ifdef CONFIG_SUBARCH_C4
	csrw	$6, CSR_WR_FREGS
#endif
	ret
	.end ____copy_user_simd_no_una_check
Loading