crypto/armcap.c: detect hardware-assisted SHA512 support.
authorAndy Polyakov <appro@openssl.org>
Sun, 11 Feb 2018 11:29:06 +0000 (12:29 +0100)
committerAndy Polyakov <appro@openssl.org>
Mon, 12 Feb 2018 13:04:53 +0000 (14:04 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/arm64cpuid.pl
crypto/arm_arch.h
crypto/armcap.c

index caa33875c93739e9f9645f1350078bb231bfeb69..68734f5bedb4076a9bed32a144fe81cf4c77e238 100755 (executable)
@@ -63,6 +63,7 @@ _armv8_sha256_probe:
        sha256su0       v0.4s, v0.4s
        ret
 .size  _armv8_sha256_probe,.-_armv8_sha256_probe
+
 .globl _armv8_pmull_probe
 .type  _armv8_pmull_probe,%function
 _armv8_pmull_probe:
@@ -70,6 +71,13 @@ _armv8_pmull_probe:
        ret
 .size  _armv8_pmull_probe,.-_armv8_pmull_probe
 
+.globl _armv8_sha512_probe
+.type  _armv8_sha512_probe,%function
+_armv8_sha512_probe:
+       .long   0xcec08000      // sha512su0    v0.2d,v0.2d
+       ret
+.size  _armv8_sha512_probe,.-_armv8_sha512_probe
+
 .globl OPENSSL_cleanse
 .type  OPENSSL_cleanse,%function
 .align 5
index 8b41408296fa22169be40576068a36116c8cc0e3..395ada61a487dad7b2d3168eaddc270aeffb494f 100644 (file)
@@ -79,5 +79,6 @@ extern unsigned int OPENSSL_armcap_P;
 # define ARMV8_SHA1      (1<<3)
 # define ARMV8_SHA256    (1<<4)
 # define ARMV8_PMULL     (1<<5)
+# define ARMV8_SHA512    (1<<6)
 
 #endif
index a1f77fa2fcf3a28d2b3a2c54f935f0711531e013..deffd93cc6865e9ed1fbfb713e320c3944ab0220 100644 (file)
@@ -46,6 +46,9 @@ void _armv8_aes_probe(void);
 void _armv8_sha1_probe(void);
 void _armv8_sha256_probe(void);
 void _armv8_pmull_probe(void);
+# ifdef __aarch64__
+void _armv8_sha512_probe(void);
+# endif
 uint32_t _armv7_tick(void);
 
 uint32_t OPENSSL_rdtsc(void)
@@ -94,6 +97,7 @@ static unsigned long (*getauxval) (unsigned long) = NULL;
 #  define HWCAP_CE_PMULL         (1 << 4)
 #  define HWCAP_CE_SHA1          (1 << 5)
 #  define HWCAP_CE_SHA256        (1 << 6)
+#  define HWCAP_CE_SHA512        (1 << 21)
 # endif
 
 void OPENSSL_cpuid_setup(void)
@@ -163,6 +167,11 @@ void OPENSSL_cpuid_setup(void)
 
             if (hwcap & HWCAP_CE_SHA256)
                 OPENSSL_armcap_P |= ARMV8_SHA256;
+
+# ifdef __aarch64__
+            if (hwcap & HWCAP_CE_SHA512)
+                OPENSSL_armcap_P |= ARMV8_SHA512;
+# endif
         }
     } else if (sigsetjmp(ill_jmp, 1) == 0) {
         _armv7_neon_probe();
@@ -182,6 +191,12 @@ void OPENSSL_cpuid_setup(void)
             _armv8_sha256_probe();
             OPENSSL_armcap_P |= ARMV8_SHA256;
         }
+# ifdef __aarch64__
+        if (sigsetjmp(ill_jmp, 1) == 0) {
+            _armv8_sha512_probe();
+            OPENSSL_armcap_P |= ARMV8_SHA512;
+        }
+# endif
     }
     if (sigsetjmp(ill_jmp, 1) == 0) {
         _armv7_tick();