From: David CARLIER Date: Mon, 19 Apr 2021 20:26:50 +0000 (+0100) Subject: armcap: fix Mac M1 SHA512 support. X-Git-Tag: openssl-3.0.0-alpha17~200 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1a45f68bcdceaa2944d078cc65ffb0b3845c43e;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14935) --- diff --git a/crypto/armcap.c b/crypto/armcap.c index dc2326f8f65..28cadfbb2ec 100644 --- a/crypto/armcap.c +++ b/crypto/armcap.c @@ -13,6 +13,9 @@ #include #include #include +#ifdef __APPLE__ +#include +#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;