PPC assebmly pack: initial POWER9 support tidbits.
[openssl.git] / crypto / ppccap.c
index 76cfdbde8b7ab3f192008dd4af5fb720aeca8c14..2c98daf5b4df785d88269b8519dd9cbcc2942e18 100644 (file)
@@ -151,6 +151,7 @@ static unsigned long (*getauxval) (unsigned long) = NULL;
 
 #define HWCAP2                  26      /* AT_HWCAP2 */
 #define HWCAP_VEC_CRYPTO        (1U << 25)
+#define HWCAP_ARCH_3_00         (1U << 23)
 
 # if defined(__GNUC__) && __GNUC__>=2
 __attribute__ ((constructor))
@@ -208,6 +209,9 @@ void OPENSSL_cpuid_setup(void)
     if (__power_set(0xffffffffU<<16))           /* POWER8 and later */
         OPENSSL_ppccap_P |= PPC_CRYPTO207;
 
+    if (__power_set(0xffffffffU<<17))           /* POWER9 and later */
+        OPENSSL_ppccap_P |= PPC_MADD300;
+
     return;
 # endif
 #endif
@@ -236,6 +240,10 @@ void OPENSSL_cpuid_setup(void)
                 OPENSSL_ppccap_P |= PPC_CRYPTO207;
         }
 
+        if (hwcap & HWCAP_ARCH_3_00) {
+            OPENSSL_ppccap_P |= PPC_MADD300;
+        }
+
         return;
     }
 
@@ -285,6 +293,11 @@ void OPENSSL_cpuid_setup(void)
         }
     }
 
+    if (sigsetjmp(ill_jmp, 1) == 0) {
+        OPENSSL_madd300_probe();
+        OPENSSL_ppccap_P |= PPC_MADD300;
+    }
+
     sigaction(SIGILL, &ill_oact, NULL);
     sigprocmask(SIG_SETMASK, &oset, NULL);
 }