1 /* Copyright (c) 2016, Google Inc.
2 *
3 * Permission to use, copy, modify, and/or distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15 #include <openssl/cpu.h>
16
17 #if defined(OPENSSL_PPC64LE)
18
19 #include <sys/auxv.h>
20
21 #include "internal.h"
22
23
24 #if !defined(PPC_FEATURE2_HAS_VCRYPTO)
25 /* PPC_FEATURE2_HAS_VCRYPTO was taken from section 4.1.2.3 of the “OpenPOWER
26 * ABI for Linux Supplement”. */
27 #define PPC_FEATURE2_HAS_VCRYPTO 0x02000000
28 #endif
29
OPENSSL_cpuid_setup(void)30 void OPENSSL_cpuid_setup(void) {
31 OPENSSL_ppc64le_hwcap2 = getauxval(AT_HWCAP2);
32 }
33
CRYPTO_is_PPC64LE_vcrypto_capable(void)34 int CRYPTO_is_PPC64LE_vcrypto_capable(void) {
35 return (OPENSSL_ppc64le_hwcap2 & PPC_FEATURE2_HAS_VCRYPTO) != 0;
36 }
37
38 #endif /* OPENSSL_PPC64LE */
39