Commit fa906382 authored by agl's avatar agl Committed by Commit bot

Move the call to CRYPTO_set_NEON_capable up.

BoringSSL needs to probe for NEON support via SIGILL in cases where
getauxval isn't provided and the application doesn't do explicit
initialisation.

However, Chromium might have gone multithreaded by the time that we
initialise BoringSSL and, although it doesn't look like we'll race the
disposition of SIGILL with anything, it's best not to test that hope.

So this change causes CRYPTO_set_NEON_capable to always be called, and
to be called before SSL_library_init. BoringSSL will take that as a
signal that probing for NEON support isn't needed.

BUG=none

Review URL: https://codereview.chromium.org/899463002

Cr-Commit-Position: refs/heads/master@{#314201}
parent a2a2970d
......@@ -48,6 +48,18 @@ class OpenSSLInitSingleton {
private:
friend struct DefaultSingletonTraits<OpenSSLInitSingleton>;
OpenSSLInitSingleton() {
#if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
const bool has_neon =
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
// CRYPTO_set_NEON_capable is called before |SSL_library_init| because this
// stops BoringSSL from probing for NEON support via SIGILL in the case
// that getauxval isn't present.
CRYPTO_set_NEON_capable(has_neon);
// See https://code.google.com/p/chromium/issues/detail?id=341598
base::CPU cpu;
CRYPTO_set_NEON_functional(!cpu.has_broken_neon());
#endif
SSL_load_error_strings();
SSL_library_init();
int num_locks = CRYPTO_num_locks();
......@@ -56,16 +68,6 @@ class OpenSSLInitSingleton {
locks_.push_back(new base::Lock());
CRYPTO_set_locking_callback(LockingCallback);
CRYPTO_THREADID_set_callback(CurrentThreadId);
#if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
const bool has_neon =
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
if (has_neon)
CRYPTO_set_NEON_capable(1);
// See https://code.google.com/p/chromium/issues/detail?id=341598
base::CPU cpu;
CRYPTO_set_NEON_functional(!cpu.has_broken_neon());
#endif
}
~OpenSSLInitSingleton() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment