1 // Copyright 2018 The BoringSSL Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "internal.h" 16 17 #if defined(OPENSSL_AARCH64) && defined(OPENSSL_FUCHSIA) && \ 18 !defined(OPENSSL_STATIC_ARMCAP) && !defined(OPENSSL_NO_ASM) 19 20 #include <zircon/features.h> 21 #include <zircon/syscalls.h> 22 #include <zircon/types.h> 23 24 OPENSSL_cpuid_setup(void)25void OPENSSL_cpuid_setup(void) { 26 uint32_t hwcap; 27 zx_status_t rc = zx_system_get_features(ZX_FEATURE_KIND_CPU, &hwcap); 28 if (rc != ZX_OK || (hwcap & ZX_ARM64_FEATURE_ISA_ASIMD) == 0) { 29 // If NEON/ASIMD is missing, don't report other features either. This 30 // matches OpenSSL, and the other features depend on SIMD registers. 31 return; 32 } 33 34 OPENSSL_armcap_P |= ARMV7_NEON; 35 36 if (hwcap & ZX_ARM64_FEATURE_ISA_AES) { 37 OPENSSL_armcap_P |= ARMV8_AES; 38 } 39 if (hwcap & ZX_ARM64_FEATURE_ISA_PMULL) { 40 OPENSSL_armcap_P |= ARMV8_PMULL; 41 } 42 if (hwcap & ZX_ARM64_FEATURE_ISA_SHA1) { 43 OPENSSL_armcap_P |= ARMV8_SHA1; 44 } 45 if (hwcap & ZX_ARM64_FEATURE_ISA_SHA256) { 46 OPENSSL_armcap_P |= ARMV8_SHA256; 47 } 48 if (hwcap & ZX_ARM64_FEATURE_ISA_SHA512) { 49 OPENSSL_armcap_P |= ARMV8_SHA512; 50 } 51 } 52 53 #endif // OPENSSL_AARCH64 && OPENSSL_FUCHSIA && !OPENSSL_STATIC_ARMCAP 54