blob: b368ed41dd3c01e74ec22f55e41723e4e90f03cf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright 2016 The BoringSSL Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "internal.h"
#if defined(OPENSSL_AARCH64) && defined(OPENSSL_LINUX) && \
!defined(OPENSSL_STATIC_ARMCAP) && !defined(OPENSSL_NO_ASM)
#include <sys/auxv.h>
using namespace bssl;
void bssl::OPENSSL_cpuid_setup() {
unsigned long hwcap = getauxval(AT_HWCAP);
// See /usr/include/asm/hwcap.h on an aarch64 installation for the source of
// these values.
static const unsigned long kNEON = 1 << 1;
static const unsigned long kAES = 1 << 3;
static const unsigned long kPMULL = 1 << 4;
static const unsigned long kSHA1 = 1 << 5;
static const unsigned long kSHA256 = 1 << 6;
static const unsigned long kSHA3 = 1 << 17;
static const unsigned long kSHA512 = 1 << 21;
if ((hwcap & kNEON) == 0) {
// Matching OpenSSL, if NEON is missing, don't report other features
// either.
return;
}
BSSL_armcap_P |= ARMV7_NEON;
if (hwcap & kAES) {
BSSL_armcap_P |= ARMV8_AES;
}
if (hwcap & kPMULL) {
BSSL_armcap_P |= ARMV8_PMULL;
}
if (hwcap & kSHA1) {
BSSL_armcap_P |= ARMV8_SHA1;
}
if (hwcap & kSHA256) {
BSSL_armcap_P |= ARMV8_SHA256;
}
if (hwcap & kSHA512) {
BSSL_armcap_P |= ARMV8_SHA512;
}
if (hwcap & kSHA3) {
BSSL_armcap_P |= ARMV8_SHA3;
}
}
#endif // OPENSSL_AARCH64 && OPENSSL_LINUX && !OPENSSL_STATIC_ARMCAP
|