Skip to content

Commit f30ecb8

Browse files
committed
Runtime dispatch now depends on a simple cntb test rather than envvar.
1 parent b08e296 commit f30ecb8

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

crypto/arm64cpuid.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@
120120
ret
121121
.size _armv8_sve2_probe,.-_armv8_sve2_probe
122122
123+
.globl _armv8_sve_get_vl_bytes
124+
.type _armv8_sve_get_vl_bytes,%function
125+
_armv8_sve_get_vl_bytes:
126+
AARCH64_VALID_CALL_TARGET
127+
.inst 0x0420e3e0 // cntb x0
128+
ret
129+
.size _armv8_sve_get_vl_bytes,.-_armv8_sve_get_vl_bytes
130+
123131
.globl _armv8_cpuid_probe
124132
.type _armv8_cpuid_probe,%function
125133
_armv8_cpuid_probe:

crypto/armcap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ void _armv8_eor3_probe(void);
211211
void _armv8_sve_probe(void);
212212
void _armv8_sve2_probe(void);
213213
void _armv8_rng_probe(void);
214+
unsigned long _armv8_sve_get_vl_bytes(void);
214215
# endif
215216
# endif /* !__APPLE__ && !OSSL_IMPLEMENT_GETAUXVAL */
216217

@@ -445,9 +446,10 @@ void OPENSSL_cpuid_setup(void)
445446
MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_QCOMM, QCOM_CPU_PART_ORYON_X1)) &&
446447
(OPENSSL_armcap_P & ARMV8_SHA3))
447448
OPENSSL_armcap_P |= ARMV8_HAVE_SHA3_AND_WORTH_USING;
448-
if ((OPENSSL_armcap_P & ARMV8_SVE2) != 0
449-
&& (e = getenv("OPENSSL_SVE2_POLY1305")) != NULL && atoi(e) != 0)
449+
if ((OPENSSL_armcap_P & ARMV8_SVE2) && (_armv8_sve_get_vl_bytes() > 16)) {
450+
// This implementation faster if vector length > 128 bits
450451
OPENSSL_armcap_P |= ARMV8_SVE2_POLY1305;
452+
}
451453
# endif
452454
}
453455
#endif /* _WIN32, __ARM_MAX_ARCH__ >= 7 */

0 commit comments

Comments
 (0)