diff --git a/crypto/cpu-arm.c b/crypto/cpu-arm.c index 675d174e..a42484db 100644 --- a/crypto/cpu-arm.c +++ b/crypto/cpu-arm.c @@ -50,19 +50,6 @@ void CRYPTO_set_NEON_capable(char neon_capable) { } } -char CRYPTO_is_NEON_functional(void) { - static const uint32_t kWantFlags = ARMV7_NEON | ARMV7_NEON_FUNCTIONAL; - return (OPENSSL_armcap_P & kWantFlags) == kWantFlags; -} - -void CRYPTO_set_NEON_functional(char neon_functional) { - if (neon_functional) { - OPENSSL_armcap_P |= ARMV7_NEON_FUNCTIONAL; - } else { - OPENSSL_armcap_P &= ~ARMV7_NEON_FUNCTIONAL; - } -} - int CRYPTO_is_ARMv8_AES_capable(void) { return (OPENSSL_armcap_P & ARMV8_AES) != 0; } diff --git a/crypto/crypto.c b/crypto/crypto.c index da8807db..7d62ff61 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -63,7 +63,7 @@ uint32_t OPENSSL_ia32cap_P[4] = {0}; uint32_t OPENSSL_armcap_P = #if defined(OPENSSL_STATIC_ARMCAP_NEON) || defined(__ARM_NEON__) - ARMV7_NEON | ARMV7_NEON_FUNCTIONAL | + ARMV7_NEON | #endif #if defined(OPENSSL_STATIC_ARMCAP_AES) ARMV8_AES | @@ -80,9 +80,9 @@ uint32_t OPENSSL_armcap_P = 0; #elif defined(__ARM_NEON__) -uint32_t OPENSSL_armcap_P = ARMV7_NEON | ARMV7_NEON_FUNCTIONAL; +uint32_t OPENSSL_armcap_P = ARMV7_NEON; #else -uint32_t OPENSSL_armcap_P = ARMV7_NEON_FUNCTIONAL; +uint32_t OPENSSL_armcap_P = 0; #endif #endif diff --git a/crypto/poly1305/poly1305.c b/crypto/poly1305/poly1305.c index 5a49e2df..f560af7c 100644 --- a/crypto/poly1305/poly1305.c +++ b/crypto/poly1305/poly1305.c @@ -170,7 +170,7 @@ void CRYPTO_poly1305_init(poly1305_state *statep, const uint8_t key[32]) { uint32_t t0, t1, t2, t3; #if defined(OPENSSL_ARM) && !defined(OPENSSL_NO_ASM) - if (CRYPTO_is_NEON_functional()) { + if (CRYPTO_is_NEON_capable()) { CRYPTO_poly1305_init_neon(statep, key); return; } @@ -217,7 +217,7 @@ void CRYPTO_poly1305_update(poly1305_state *statep, const uint8_t *in, struct poly1305_state_st *state = (struct poly1305_state_st *)statep; #if defined(OPENSSL_ARM) && !defined(OPENSSL_NO_ASM) - if (CRYPTO_is_NEON_functional()) { + if (CRYPTO_is_NEON_capable()) { CRYPTO_poly1305_update_neon(statep, in, in_len); return; } @@ -263,7 +263,7 @@ void CRYPTO_poly1305_finish(poly1305_state *statep, uint8_t mac[16]) { uint32_t b, nb; #if defined(OPENSSL_ARM) && !defined(OPENSSL_NO_ASM) - if (CRYPTO_is_NEON_functional()) { + if (CRYPTO_is_NEON_capable()) { CRYPTO_poly1305_finish_neon(statep, mac); return; } diff --git a/include/openssl/arm_arch.h b/include/openssl/arm_arch.h index 1471db90..e7010f40 100644 --- a/include/openssl/arm_arch.h +++ b/include/openssl/arm_arch.h @@ -105,12 +105,6 @@ /* ARMV7_NEON is true when a NEON unit is present in the current CPU. */ #define ARMV7_NEON (1 << 0) -/* ARMV7_NEON_FUNCTIONAL is true when the NEON unit doesn't contain subtle bugs. - * The Poly1305 NEON code is known to trigger bugs in the NEON units of some - * phones. If this bit isn't set then the Poly1305 NEON code won't be used. - * See https://code.google.com/p/chromium/issues/detail?id=341598. */ -#define ARMV7_NEON_FUNCTIONAL (1 << 10) - /* ARMV8_AES indicates support for hardware AES instructions. */ #define ARMV8_AES (1 << 2) diff --git a/include/openssl/cpu.h b/include/openssl/cpu.h index e946304a..15faa9c9 100644 --- a/include/openssl/cpu.h +++ b/include/openssl/cpu.h @@ -118,23 +118,13 @@ static inline int CRYPTO_is_NEON_capable(void) { } /* CRYPTO_set_NEON_capable sets the return value of |CRYPTO_is_NEON_capable|. - * By default, unless the code was compiled with |-mfpu=neon|, NEON is assumed - * not to be present. It is not autodetected. Calling this with a zero - * argument also causes |CRYPTO_is_NEON_functional| to return false. */ + * If this function is called before |CRYPTO_library_init| in + * |BORINGSSL_NO_STATIC_INITIALIZER| builds, the logic to probe for NEON support + * will not run. + * + * TODO(davidben): Remove this function. https://crbug.com/589200. */ OPENSSL_EXPORT void CRYPTO_set_NEON_capable(char neon_capable); -/* CRYPTO_is_NEON_functional returns true if the current CPU has a /working/ - * NEON unit. Some phones have a NEON unit, but the Poly1305 NEON code causes - * it to fail. See https://code.google.com/p/chromium/issues/detail?id=341598 */ -OPENSSL_EXPORT char CRYPTO_is_NEON_functional(void); - -/* CRYPTO_set_NEON_functional sets the "NEON functional" flag. For - * |CRYPTO_is_NEON_functional| to return true, both this flag and the NEON flag - * must be true. By default NEON is assumed to be functional if the code was - * compiled with |-mfpu=neon| or if |CRYPTO_set_NEON_capable| has been called - * with a non-zero argument. */ -OPENSSL_EXPORT void CRYPTO_set_NEON_functional(char neon_functional); - /* CRYPTO_is_ARMv8_AES_capable returns true if the current CPU supports the * ARMv8 AES instruction. */ int CRYPTO_is_ARMv8_AES_capable(void); @@ -153,10 +143,6 @@ static inline int CRYPTO_is_NEON_capable(void) { #endif } -static inline int CRYPTO_is_NEON_functional(void) { - return CRYPTO_is_NEON_capable(); -} - static inline int CRYPTO_is_ARMv8_AES_capable(void) { #if defined(OPENSSL_STATIC_ARMCAP_AES) return 1;