boringssl/util
David Benjamin 054e151b16 Rewrite ARM feature detection.
This removes the thread-unsafe SIGILL-based detection and the
multi-consumer-hostile CRYPTO_set_NEON_capable API. (Changing
OPENSSL_armcap_P after initialization is likely to cause problems.)

The right way to detect ARM features on Linux is getauxval. On aarch64,
we should be able to rely on this, so use it straight. Split this out
into its own file. The #ifdefs in the old cpu-arm.c meant it shared all
but no code with its arm counterpart anyway.

Unfortunately, various versions of Android have different missing APIs, so, on
arm, we need a series of workarounds. Previously, we used a SIGILL fallback
based on OpenSSL's logic, but this is inherently not thread-safe. (SIGILL also
does not tell us if the OS knows how to save and restore NEON state.) Instead,
base the behavior on Android NDK's cpu-features library, what Chromium
currently uses with CRYPTO_set_NEON_capable:

- Android before API level 20 does not provide getauxval. Where missing,
  we can read from /proc/self/auxv.

- On some versions of Android, /proc/self/auxv is also not readable, so
  use /proc/cpuinfo's Features line.

- Linux only advertises optional features in /proc/cpuinfo. ARMv8 makes NEON
  mandatory, so /proc/cpuinfo can't be used without additional effort.

Finally, we must blacklist a particular chip because the NEON unit is broken
(https://crbug.com/341598).

Unfortunately, this means CRYPTO_library_init now depends on /proc being
available, which will require some care with Chromium's sandbox. The
simplest solution is to just call CRYPTO_library_init before entering
the sandbox.

It's worth noting that Chromium's current EnsureOpenSSLInit function already
depends on /proc/cpuinfo to detect the broken CPU, by way of base::CPU.
android_getCpuFeatures also interally depends on it. We were already relying on
both of those being stateful and primed prior to entering the sandbox.

BUG=chromium:589200

Change-Id: Ic5d1c341aab5a614eb129d8aa5ada2809edd6af8
Reviewed-on: https://boringssl-review.googlesource.com/7506
Reviewed-by: David Benjamin <davidben@google.com>
2016-03-26 04:54:44 +00:00
..
bot Update cmake-linux64.tar.gz and cmake-mac.tar.gz. 2016-03-10 17:23:17 +00:00
32-bit-toolchain.cmake
all_tests.go Adding scripts to generate line coverage. 2016-03-03 23:33:48 +00:00
all_tests.json Run ripemd_test as part of all_tests.go. 2016-03-17 21:37:14 +00:00
doc.config Add X25519 and Ed25519 support. 2015-11-17 21:56:12 +00:00
doc.css
doc.go Have doc.go parse struct comments. 2016-01-26 23:23:23 +00:00
generate_build_files.py Rewrite ARM feature detection. 2016-03-26 04:54:44 +00:00
generate-asm-lcov.py Fixing assembly coverage 2016-03-23 18:23:42 +00:00
generate-coverage.sh Adding scripts to generate line coverage. 2016-03-03 23:33:48 +00:00
make_errors.go Markdown-ify BUILDING. 2015-09-03 18:38:21 +00:00
run_android_tests.go Add a script to run tests on Android. 2016-03-08 17:08:27 +00:00