blob: c431c818f92ff7310c65cf1e16ef5f1d616cb034 [file] [log] [blame]
Steven Valdezbb1ceac2016-10-07 10:34:51 -04001/* 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
30static unsigned long g_ppc64le_hwcap2 = 0;
31
32void OPENSSL_cpuid_setup(void) {
33 g_ppc64le_hwcap2 = getauxval(AT_HWCAP2);
34}
35
36int CRYPTO_is_PPC64LE_vcrypto_capable(void) {
37 return (g_ppc64le_hwcap2 & PPC_FEATURE2_HAS_VCRYPTO) != 0;
38}
39
40#endif /* OPENSSL_PPC64LE */