Module Name:    src
Committed By:   riastradh
Date:           Mon Aug 17 16:26:02 UTC 2020

Modified Files:
        src/tests/sys/crypto/aes: Makefile t_aes.c
        src/tests/sys/crypto/chacha: Makefile t_chacha.c

Log Message:
Make the AES and ChaCha NEON tests work in softfloat userland.

(`Softfloat' here refers to the ABI, which of course may be running
on a CPU with NEON.)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/sys/crypto/aes/Makefile
cvs rdiff -u -r1.3 -r1.4 src/tests/sys/crypto/aes/t_aes.c
cvs rdiff -u -r1.4 -r1.5 src/tests/sys/crypto/chacha/Makefile
cvs rdiff -u -r1.3 -r1.4 src/tests/sys/crypto/chacha/t_chacha.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/sys/crypto/aes/Makefile
diff -u src/tests/sys/crypto/aes/Makefile:1.4 src/tests/sys/crypto/aes/Makefile:1.5
--- src/tests/sys/crypto/aes/Makefile:1.4	Sun Aug 16 15:52:14 2020
+++ src/tests/sys/crypto/aes/Makefile	Mon Aug 17 16:26:02 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2020/08/16 15:52:14 martin Exp $
+#	$NetBSD: Makefile,v 1.5 2020/08/17 16:26:02 riastradh Exp $
 
 .include <bsd.own.mk>
 
@@ -19,7 +19,7 @@ SRCS.t_aes+=	aes_ct_dec.c
 SRCS.t_aes+=	aes_ct_enc.c
 SRCS.t_aes+=	aes_selftest.c
 
-.if !empty(MACHINE_ARCH:Mearmv7hf*) || !empty(MACHINE_ARCH:Maarch64*)
+.if !empty(MACHINE_ARCH:Mearmv7*) || !empty(MACHINE_ARCH:Maarch64*)
 
 .PATH:	${NETBSDSRCDIR}/sys/crypto/aes/arch/arm
 CPPFLAGS+=	-I${NETBSDSRCDIR}/sys/crypto/aes/arch/arm
@@ -32,10 +32,16 @@ SRCS.t_aes+=	aes_armv8_64.S
 SRCS.t_aes+=	aes_neon.c
 SRCS.t_aes+=	aes_neon_impl.c
 SRCS.t_aes+=	aes_neon_subr.c
-.if !empty(MACHINE_ARCH:Mearmv7hf*)
+.if !empty(MACHINE_ARCH:Mearmv7*)
 SRCS.t_aes+=	aes_neon_32.S
 .endif
 
+.if !empty(MACHINE_ARCH:Mearmv7*) && empty(MACHINE_ARCH:Mearmv7hf*)
+COPTS.aes_neon.c+=	-mfloat-abi=softfp -mfpu=neon
+COPTS.aes_neon_subr.c+=	-mfloat-abi=softfp -mfpu=neon
+AOPTS.aes_neon_32.S+=	-D__SOFTFP__
+.endif
+
 .endif				# earmv7/aarch64
 
 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"

Index: src/tests/sys/crypto/aes/t_aes.c
diff -u src/tests/sys/crypto/aes/t_aes.c:1.3 src/tests/sys/crypto/aes/t_aes.c:1.4
--- src/tests/sys/crypto/aes/t_aes.c:1.3	Sun Jul 26 14:01:14 2020
+++ src/tests/sys/crypto/aes/t_aes.c	Mon Aug 17 16:26:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_aes.c,v 1.3 2020/07/26 14:01:14 riastradh Exp $	*/
+/*	$NetBSD: t_aes.c,v 1.4 2020/08/17 16:26:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #include <crypto/aes/arch/arm/aes_armv8.h>
 #endif
 
-#ifdef __ARM_NEON
+#if __ARM_ARCH >= 7
 #include <crypto/aes/arch/arm/aes_neon.h>
 #endif
 
@@ -93,7 +93,7 @@ ATF_TC_BODY(name, tc)							      \
 AES_SELFTEST(aes_armv8_selftest, &aes_armv8_impl, "ARMv8.0-AES self-test")
 #endif
 
-#ifdef __ARM_NEON
+#if __ARM_ARCH >= 7
 AES_SELFTEST(aes_neon_selftest, &aes_neon_impl, "ARM NEON vpaes self-test")
 #endif
 
@@ -118,7 +118,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, aes_armv8_selftest);
 #endif
 
-#ifdef __ARM_NEON
+#if __ARM_ARCH >= 7
 	ATF_TP_ADD_TC(tp, aes_neon_selftest);
 #endif
 

Index: src/tests/sys/crypto/chacha/Makefile
diff -u src/tests/sys/crypto/chacha/Makefile:1.4 src/tests/sys/crypto/chacha/Makefile:1.5
--- src/tests/sys/crypto/chacha/Makefile:1.4	Sun Aug 16 15:52:14 2020
+++ src/tests/sys/crypto/chacha/Makefile	Mon Aug 17 16:26:02 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2020/08/16 15:52:14 martin Exp $
+#	$NetBSD: Makefile,v 1.5 2020/08/17 16:26:02 riastradh Exp $
 
 .include <bsd.own.mk>
 
@@ -16,19 +16,24 @@ SRCS.t_chacha+=	t_chacha.c
 SRCS.t_chacha+=	chacha_ref.c
 SRCS.t_chacha+=	chacha_selftest.c
 
-.if !empty(MACHINE_ARCH:Mearmv7hf*) || !empty(MACHINE_ARCH:Maarch64*)
+.if !empty(MACHINE_ARCH:Mearmv7*) || !empty(MACHINE_ARCH:Maarch64*)
 
 .PATH:	${NETBSDSRCDIR}/sys/crypto/chacha/arch/arm
 CPPFLAGS+=	-I${NETBSDSRCDIR}/sys/crypto/chacha/arch/arm
 
 SRCS.t_chacha+=	chacha_neon.c
-.if !empty(MACHINE_ARCH:Mearmv7hf*)
+.if !empty(MACHINE_ARCH:Mearmv7*)
 SRCS.t_chacha+=	chacha_neon_32.S
 .elif !empty(MACHINE_ARCH:Maarch64*)
 SRCS.t_chacha+=	chacha_neon_64.S
 .endif
 SRCS.t_chacha+=	chacha_neon_impl.c
 
+.if !empty(MACHINE_ARCH:Mearmv7*) && empty(MACHINE_ARCH:Mearmv7hf*)
+COPTS.chacha_neon.c+=		-mfloat-abi=softfp -mfpu=neon
+AOPTS.chacha_neon_32.S+=	-D__SOFTFP__
+.endif
+
 .endif				# earmv7 or aarch64
 
 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"

Index: src/tests/sys/crypto/chacha/t_chacha.c
diff -u src/tests/sys/crypto/chacha/t_chacha.c:1.3 src/tests/sys/crypto/chacha/t_chacha.c:1.4
--- src/tests/sys/crypto/chacha/t_chacha.c:1.3	Mon Jul 27 20:59:53 2020
+++ src/tests/sys/crypto/chacha/t_chacha.c	Mon Aug 17 16:26:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_chacha.c,v 1.3 2020/07/27 20:59:53 riastradh Exp $	*/
+/*	$NetBSD: t_chacha.c,v 1.4 2020/08/17 16:26:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include <crypto/chacha/arch/x86/chacha_sse2.h>
 #endif
 
-#ifdef __ARM_NEON
+#if __ARM_ARCH >= 7
 #include <crypto/chacha/arch/arm/chacha_neon.h>
 #endif
 
@@ -81,7 +81,7 @@ ATF_TC_BODY(name, tc)							      \
 		atf_tc_fail("%s self-test failed", (impl)->ci_name);	      \
 }
 
-#ifdef __ARM_NEON
+#if __ARM_ARCH >= 7
 CHACHA_SELFTEST(chacha_neon_selftest, &chacha_neon_impl,
     "ARM NEON ChaCha self-test")
 #endif
@@ -96,7 +96,7 @@ ATF_TP_ADD_TCS(tp)
 
 	ATF_TP_ADD_TC(tp, chacha_ref_selftest);
 
-#ifdef __ARM_NEON
+#if __ARM_ARCH >= 7
 	ATF_TP_ADD_TC(tp, chacha_neon_selftest);
 #endif
 

Reply via email to