Skip to content

Commit 3883e89

Browse files
committed
ARM32 assembly: Get CPU Id flags to choose assembly.
Added flag determination for Linux/Android/BSD/Windows/privilege-mode. Made AES and SHA-256 runtime dispatch. Updated the ARM32 assembly to support having multiple implementations compiled in.
1 parent 39a6073 commit 3883e89

11 files changed

Lines changed: 26303 additions & 25543 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,8 @@ WOLFSSL_ALLOW_SERVER_SC_EXT
785785
WOLFSSL_ALLOW_TLS_SHA1
786786
WOLFSSL_ALTERNATIVE_DOWNGRADE
787787
WOLFSSL_ALT_NAMES_NO_REV
788+
WOLFSSL_ARM32_BUILD
789+
WOLFSSL_ARM32_PRIVILEGE_MODE
788790
WOLFSSL_ARMASM_NEON_NO_TABLE_LOOKUP
789791
WOLFSSL_ARM_ARCH_NEON_64BIT
790792
WOLFSSL_ASCON_UNROLL

configure.ac

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,10 +3917,12 @@ ENABLED_ARMASM_INLINE="no"
39173917
ENABLED_ARMASM_SHA256_SMALL="no"
39183918
ENABLED_ARMASM_SHA3="unknown"
39193919
ENABLED_ARMASM_CRYPTO_SM4="no"
3920+
ENABLED_ARMASM_NO_BASE_IMPL="no"
3921+
ENABLED_ARMASM_NO_NEON_IMPL="no"
39203922
# ARM Assembly
39213923
# Both SHA3 and SHA512 instructions available with ARMV8.2-a
39223924
AC_ARG_ENABLE([armasm],
3923-
[AS_HELP_STRING([--enable-armasm],[Enable wolfSSL ARMv8 ASM support (default: disabled). Set to sha512-crypto or sha3-crypto to use SHA512 and SHA3 instructions with Aarch64 CPU.])],
3925+
[AS_HELP_STRING([--enable-armasm],[Enable wolfSSL ARMv8 ASM support (default: disabled). Set to sha512-crypto or sha3-crypto to use SHA512 and SHA3 instructions with Aarch64 CPU. On 32-bit ARM, no-base and no-neon-impl drop the base/NEON run-time fallbacks when the crypto extension is always present.])],
39243926
[ ENABLED_ARMASM=$enableval ],
39253927
[ ENABLED_ARMASM=no ]
39263928
)
@@ -4025,13 +4027,33 @@ then
40254027
esac
40264028
ENABLED_ARMASM_AES_BLOCK_INLINE=yes
40274029
;;
4030+
no-base)
4031+
case $host_cpu in
4032+
*arm*)
4033+
;;
4034+
*)
4035+
AC_MSG_ERROR([no-base option only available on 32-bit ARM CPU.])
4036+
break;;
4037+
esac
4038+
ENABLED_ARMASM_NO_BASE_IMPL=yes
4039+
;;
4040+
no-neon-impl)
4041+
case $host_cpu in
4042+
*arm*)
4043+
;;
4044+
*)
4045+
AC_MSG_ERROR([no-neon-impl option only available on 32-bit ARM CPU.])
4046+
break;;
4047+
esac
4048+
ENABLED_ARMASM_NO_NEON_IMPL=yes
4049+
;;
40284050
*)
40294051
case $host_cpu in
40304052
*aarch64*)
40314053
AC_MSG_ERROR([Invalid choice of ARM asm inclusions (yes, inline, no-crypto, sha512-crypto, sha3-crypto, no-sha512-crypto, no-sha3-crypto, barrier-sb, barrier-detect): $ENABLED_ARMASM.])
40324054
break;;
40334055
*arm*)
4034-
AC_MSG_ERROR([Invalid choice of ARM asm inclusions (yes, inline, no-crypto, sha256-small, aes-block-dup): $ENABLED_ARMASM.])
4056+
AC_MSG_ERROR([Invalid choice of ARM asm inclusions (yes, inline, no-crypto, sha256-small, aes-block-dup, no-base, no-neon-impl): $ENABLED_ARMASM.])
40354057
break;;
40364058
esac
40374059
break;;
@@ -4194,6 +4216,17 @@ if test "$ENABLED_ARMASM_NEON" = "no"; then
41944216
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ARMASM_NO_NEON"
41954217
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_ARMASM_NO_NEON"
41964218
fi
4219+
# 32-bit ARM run-time dispatch: drop a fallback implementation when the crypto
4220+
# extension is always present. Gates both the C dispatch and the generated
4221+
# assembly, so define for the C and assembler flags.
4222+
if test "$ENABLED_ARMASM_NO_BASE_IMPL" = "yes"; then
4223+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ARMASM_NO_BASE_IMPL"
4224+
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_ARMASM_NO_BASE_IMPL"
4225+
fi
4226+
if test "$ENABLED_ARMASM_NO_NEON_IMPL" = "yes"; then
4227+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ARMASM_NO_NEON_IMPL"
4228+
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_ARMASM_NO_NEON_IMPL"
4229+
fi
41974230

41984231
if test "$ENABLED_ARMASM_INLINE" = "yes"; then
41994232
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ARMASM_INLINE"

0 commit comments

Comments
 (0)