summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/cryptlib.c
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2016-11-04 17:30:30 +0000
committermiod <miod@openbsd.org>2016-11-04 17:30:30 +0000
commite60c46c4c9a5c27f2a64a9eeda73a83a36b3f7a8 (patch)
tree4a1d8de71c6b778094c6bb11703e3e5b3ad28f83 /lib/libcrypto/cryptlib.c
parentBe verbose when PATCH_PATH is not set (that is temporary until we agree on (diff)
downloadwireguard-openbsd-e60c46c4c9a5c27f2a64a9eeda73a83a36b3f7a8.tar.xz
wireguard-openbsd-e60c46c4c9a5c27f2a64a9eeda73a83a36b3f7a8.zip
Replace all uses of magic numbers when operating on OPENSSL_ia32_P[] by
meaningful constants in a private header file, so that reviewers can actually get a chance to figure out what the code is attempting to do without knowing all cpuid bits. While there, turn it from an array of two 32-bit ints into a properly aligned 64-bit int. Use of OPENSSL_ia32_P is now restricted to the assembler parts. C code will now always use OPENSSL_cpu_caps() and check for the proper bits in the whole 64-bit word it returns. i386 tests and ok jsing@
Diffstat (limited to 'lib/libcrypto/cryptlib.c')
-rw-r--r--lib/libcrypto/cryptlib.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/lib/libcrypto/cryptlib.c b/lib/libcrypto/cryptlib.c
index fa091fbaeac..8dec9caa93e 100644
--- a/lib/libcrypto/cryptlib.c
+++ b/lib/libcrypto/cryptlib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptlib.c,v 1.38 2016/11/04 13:56:04 miod Exp $ */
+/* $OpenBSD: cryptlib.c,v 1.39 2016/11/04 17:30:30 miod Exp $ */
/* ====================================================================
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
*
@@ -627,47 +627,30 @@ CRYPTO_get_lock_name(int type)
defined(__INTEL__) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
-unsigned int OPENSSL_ia32cap_P[2];
+uint64_t OPENSSL_ia32cap_P;
uint64_t
OPENSSL_cpu_caps(void)
{
- return *(uint64_t *)OPENSSL_ia32cap_P;
+ return OPENSSL_ia32cap_P;
}
#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM)
#define OPENSSL_CPUID_SETUP
-typedef unsigned long long IA32CAP;
void
OPENSSL_cpuid_setup(void)
{
static int trigger = 0;
- IA32CAP OPENSSL_ia32_cpuid(void);
- IA32CAP vec;
+ uint64_t OPENSSL_ia32_cpuid(void);
if (trigger)
return;
trigger = 1;
-
- vec = OPENSSL_ia32_cpuid();
-
- /*
- * |(1<<10) sets a reserved bit to signal that variable
- * was initialized already... This is to avoid interference
- * with cpuid snippets in ELF .init segment.
- */
- OPENSSL_ia32cap_P[0] = (unsigned int)vec | (1 << 10);
- OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32);
+ OPENSSL_ia32cap_P = OPENSSL_ia32_cpuid();
}
#endif
#else
-unsigned long *
-OPENSSL_ia32cap_loc(void)
-{
- return NULL;
-}
-
uint64_t
OPENSSL_cpu_caps(void)
{