Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/crypto/aes/arch/arm Fix AES NEON code for big-endian sof...
details: https://anonhg.NetBSD.org/src/rev/8ad1f7a9d94a
branches: trunk
changeset: 974915:8ad1f7a9d94a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Aug 16 18:02:03 2020 +0000
description:
Fix AES NEON code for big-endian softfp ARM.
...which is how the kernel runs. Switch to using __SOFTFP__ for
consistency with how it gets exposed to C, although I'm not sure how
to get it defined automagically in the toolchain for .S files so
that's set manually in files.aesneon for now.
diffstat:
sys/crypto/aes/arch/arm/aes_neon_32.S | 32 +++++++++++++++++++++++++-------
sys/crypto/aes/arch/arm/files.aesneon | 4 +++-
2 files changed, 28 insertions(+), 8 deletions(-)
diffs (105 lines):
diff -r 30e1eb1c1879 -r 8ad1f7a9d94a sys/crypto/aes/arch/arm/aes_neon_32.S
--- a/sys/crypto/aes/arch/arm/aes_neon_32.S Sun Aug 16 17:58:48 2020 +0000
+++ b/sys/crypto/aes/arch/arm/aes_neon_32.S Sun Aug 16 18:02:03 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aes_neon_32.S,v 1.5 2020/08/08 14:47:01 riastradh Exp $ */
+/* $NetBSD: aes_neon_32.S,v 1.6 2020/08/16 18:02:03 riastradh Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
#include <arm/asm.h>
-RCSID("$NetBSD: aes_neon_32.S,v 1.5 2020/08/08 14:47:01 riastradh Exp $")
+RCSID("$NetBSD: aes_neon_32.S,v 1.6 2020/08/16 18:02:03 riastradh Exp $")
.fpu neon
@@ -228,15 +228,19 @@
* aes_neon_enc1(const struct aesenc *enc@r0, uint8x16_t x@q0,
* unsigned nrounds@r1)
*
- * With -mfloat-abi=soft(fp) (here spelled `#ifdef _KERNEL'):
+ * With -mfloat-abi=soft(fp) (i.e., __SOFTFP__):
*
* uint8x16_t@(r0,r1,r2,r3)
* aes_neon_enc1(const struct aesenc *enc@r0,
* uint8x16_t x@(r2,r3,sp[0],sp[4]), nrounds@sp[8])
*/
ENTRY(aes_neon_enc1)
-#ifdef _KERNEL
+#ifdef __SOFTFP__
+#ifdef __ARM_BIG_ENDIAN
+ vmov d0, r3, r2 /* d0 := x lo */
+#else
vmov d0, r2, r3 /* d0 := x lo */
+#endif
vldr d1, [sp] /* d1 := x hi */
ldr r1, [sp, #8] /* r1 := nrounds */
#endif
@@ -434,10 +438,15 @@
vpop {d8-d15}
pop {r4, r5, r6, r7, r8, r10, r11, lr}
-#ifdef _KERNEL
+#ifdef __SOFTFP__
+#ifdef __ARM_BIG_ENDIAN
+ vmov r1, r0, d0
+ vmov r3, r2, d1
+#else
vmov r0, r1, d0
vmov r2, r3, d1
#endif
+#endif
bx lr
END(aes_neon_enc1)
@@ -457,8 +466,12 @@
* uint8x16_t x@(r2,r3,sp[0],sp[4]), nrounds@sp[8])
*/
ENTRY(aes_neon_dec1)
-#ifdef _KERNEL
+#ifdef __SOFTFP__
+#ifdef __ARM_BIG_ENDIAN
+ vmov d0, r3, r2 /* d0 := x lo */
+#else
vmov d0, r2, r3 /* d0 := x lo */
+#endif
vldr d1, [sp] /* d1 := x hi */
ldr r1, [sp, #8] /* r1 := nrounds */
#endif
@@ -669,9 +682,14 @@
vpop {d8-d15}
pop {r4, r5, r6, r7, r8, r10, r11, lr}
-#ifdef _KERNEL
+#ifdef __SOFTFP__
+#ifdef __ARM_BIG_ENDIAN
+ vmov r1, r0, d0
+ vmov r3, r2, d1
+#else
vmov r0, r1, d0
vmov r2, r3, d1
#endif
+#endif
bx lr
END(aes_neon_dec1)
diff -r 30e1eb1c1879 -r 8ad1f7a9d94a sys/crypto/aes/arch/arm/files.aesneon
--- a/sys/crypto/aes/arch/arm/files.aesneon Sun Aug 16 17:58:48 2020 +0000
+++ b/sys/crypto/aes/arch/arm/files.aesneon Sun Aug 16 18:02:03 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.aesneon,v 1.3 2020/06/30 17:03:13 riastradh Exp $
+# $NetBSD: files.aesneon,v 1.4 2020/08/16 18:02:03 riastradh Exp $
ifdef aarch64
makeoptions aes "COPTS.aes_neon.c"+="-march=armv8-a"
@@ -8,6 +8,8 @@
makeoptions aes "COPTS.aes_neon_subr.c"+="-mfloat-abi=softfp -mfpu=neon"
endif
+makeoptions aes "AOPTS.aes_neon_32.S"+="-D__SOFTFP__"
+
file crypto/aes/arch/arm/aes_neon.c aes & (cpu_cortex | aarch64)
file crypto/aes/arch/arm/aes_neon_impl.c aes & (cpu_cortex | aarch64)
file crypto/aes/arch/arm/aes_neon_subr.c aes & (cpu_cortex | aarch64)
Home |
Main Index |
Thread Index |
Old Index