diff options
author | David CARLIER <devnexen@gmail.com> | 2021-04-19 21:26:50 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-05-11 10:00:27 +0200 |
commit | f1a45f68bcdceaa2944d078cc65ffb0b3845c43e (patch) | |
tree | 6bf172341d161ed8ef615154db94183b0b9a7d06 /crypto/armcap.c | |
parent | d29d7a7ff22e8e3be1c8bbdb8edd3ab9c72ed021 (diff) |
armcap: fix Mac M1 SHA512 support.
The SIGILL catch/trap works however disabled purposely for Darwin,
thus relying on native api instead.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14935)
Diffstat (limited to 'crypto/armcap.c')
-rw-r--r-- | crypto/armcap.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/crypto/armcap.c b/crypto/armcap.c index dc2326f8f6..28cadfbb2e 100644 --- a/crypto/armcap.c +++ b/crypto/armcap.c @@ -13,6 +13,9 @@ #include <setjmp.h> #include <signal.h> #include <openssl/crypto.h> +#ifdef __APPLE__ +#include <sys/sysctl.h> +#endif #include "internal/cryptlib.h" #include "arm_arch.h" @@ -135,7 +138,8 @@ void OPENSSL_cpuid_setup(void) return; } -# if defined(__APPLE__) && !defined(__aarch64__) +# if defined(__APPLE__) +# if !defined(__aarch64__) /* * Capability probing by catching SIGILL appears to be problematic * on iOS. But since Apple universe is "monocultural", it's actually @@ -151,6 +155,15 @@ void OPENSSL_cpuid_setup(void) * Unified code works because it never triggers SIGILL on Apple * devices... */ +# else + { + unsigned int sha512; + size_t len = sizeof(sha512); + + if (sysctlbyname("hw.optional.armv8_2_sha512", &sha512, &len, NULL, 0) == 0 && sha512 == 1) + OPENSSL_armcap_P |= ARMV8_SHA512; + } +# endif # endif OPENSSL_armcap_P = 0; |