From af10c132b845dbf290e8df2f41fe396e017dbd9c Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Mon, 13 Jan 2025 21:43:18 +0800 Subject: [PATCH] LoongArch64: Fix dsymv and ssymv LASX version "fmov.d $f2, $f4" leaves all the bits higher than the 63-th bit unpredictable but it's obvious that the following code uses the value of those high bits. We actually want to replicate the lower 64 bits here, so we should use xvreplve0.d instead. LA464 (Loongson 3[A-Z]-5000) happens to replicate them for us due to some uarch internal details so the issue was not detected, but for LA664 (Loongson 3[A-Z]-6000) and future uarch we need to do things correctly or we end up getting a lot of test failures. Closes: https://bbs.aosc.io/t/topic/302 Signed-off-by: Xi Ruoyao --- kernel/loongarch64/dsymv_L_lasx.S | 2 +- kernel/loongarch64/dsymv_U_lasx.S | 2 +- kernel/loongarch64/ssymv_L_lasx.S | 2 +- kernel/loongarch64/ssymv_U_lasx.S | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/loongarch64/dsymv_L_lasx.S b/kernel/loongarch64/dsymv_L_lasx.S index a36cff9a9..508232228 100644 --- a/kernel/loongarch64/dsymv_L_lasx.S +++ b/kernel/loongarch64/dsymv_L_lasx.S @@ -288,7 +288,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //Acc U2 GACC xvf, d, U4, U2 - fmov.d $f2, $f4 + xvreplve0.d U2, U4 .L03: /* &4 */ sub.d T0, M, J addi.d T0, T0, -1 diff --git a/kernel/loongarch64/dsymv_U_lasx.S b/kernel/loongarch64/dsymv_U_lasx.S index 892c5ed2f..21bf3dffc 100644 --- a/kernel/loongarch64/dsymv_U_lasx.S +++ b/kernel/loongarch64/dsymv_U_lasx.S @@ -272,7 +272,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //Acc U2 GACC xvf, d, U4, U2 - fmov.d $f2, $f4 + xvreplve0.d U2, U4 .L03: /* &4 */ andi T0, J, 4 diff --git a/kernel/loongarch64/ssymv_L_lasx.S b/kernel/loongarch64/ssymv_L_lasx.S index 81796883d..21ffcec69 100644 --- a/kernel/loongarch64/ssymv_L_lasx.S +++ b/kernel/loongarch64/ssymv_L_lasx.S @@ -279,7 +279,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //Acc U2 GACC xvf, s, U4, U2 - fmov.d $f2, $f4 + xvreplve0.d U2, U4 .L03: /* &4 */ sub.d T0, M, J diff --git a/kernel/loongarch64/ssymv_U_lasx.S b/kernel/loongarch64/ssymv_U_lasx.S index ff68723e1..662f311d9 100644 --- a/kernel/loongarch64/ssymv_U_lasx.S +++ b/kernel/loongarch64/ssymv_U_lasx.S @@ -263,7 +263,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //Acc U2 GACC xvf, s, U4, U2 - fmov.d $f2, $f4 + xvreplve0.d U2, U4 .L03: /* &4 */ andi T0, J, 4