aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-07-10 21:31:48 -0400
committerJack Lloyd <[email protected]>2019-08-27 09:27:33 -0400
commit308bdc190f4e6a3606f801390d191988a0438557 (patch)
treef8c9763c439fca5fda33c523928c7bd02d929a84 /src/lib/utils
parentecb22c16531db3023c739fa1436d8f3893fa1081 (diff)
Add support for POWER9 DARN RNG
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/cpuid/cpuid.cpp1
-rw-r--r--src/lib/utils/cpuid/cpuid.h7
-rw-r--r--src/lib/utils/cpuid/cpuid_ppc.cpp3
3 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/utils/cpuid/cpuid.cpp b/src/lib/utils/cpuid/cpuid.cpp
index e890af061..18ccff419 100644
--- a/src/lib/utils/cpuid/cpuid.cpp
+++ b/src/lib/utils/cpuid/cpuid.cpp
@@ -63,6 +63,7 @@ std::string CPUID::to_string()
#if defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY)
CPUID_PRINT(altivec);
CPUID_PRINT(ppc_crypto);
+ CPUID_PRINT(darn_rng);
#endif
#if defined(BOTAN_TARGET_CPU_IS_ARM_FAMILY)
diff --git a/src/lib/utils/cpuid/cpuid.h b/src/lib/utils/cpuid/cpuid.h
index d278a8fcc..256c6cc57 100644
--- a/src/lib/utils/cpuid/cpuid.h
+++ b/src/lib/utils/cpuid/cpuid.h
@@ -107,6 +107,7 @@ class BOTAN_PUBLIC_API(2,1) CPUID final
#if defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY)
CPUID_ALTIVEC_BIT = (1ULL << 0),
CPUID_PPC_CRYPTO_BIT = (1ULL << 1),
+ CPUID_DARN_BIT = (1ULL << 2),
#endif
#if defined(BOTAN_TARGET_CPU_IS_ARM_FAMILY)
@@ -138,6 +139,12 @@ class BOTAN_PUBLIC_API(2,1) CPUID final
static bool has_ppc_crypto()
{ return has_cpuid_bit(CPUID_PPC_CRYPTO_BIT); }
+ /**
+ * Check if the processor supports POWER9 DARN RNG
+ */
+ static bool has_darn_rng()
+ { return has_cpuid_bit(CPUID_DARN_BIT); }
+
#endif
#if defined(BOTAN_TARGET_CPU_IS_ARM_FAMILY)
diff --git a/src/lib/utils/cpuid/cpuid_ppc.cpp b/src/lib/utils/cpuid/cpuid_ppc.cpp
index 08a04cafd..ff528d88e 100644
--- a/src/lib/utils/cpuid/cpuid_ppc.cpp
+++ b/src/lib/utils/cpuid/cpuid_ppc.cpp
@@ -58,6 +58,7 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
enum PPC_hwcap_bit {
ALTIVEC_bit = (1 << 28),
CRYPTO_bit = (1 << 25),
+ DARN_bit = (1 << 21),
ARCH_hwcap_altivec = 16, // AT_HWCAP
ARCH_hwcap_crypto = 26, // AT_HWCAP2
@@ -72,6 +73,8 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
const unsigned long hwcap_crypto = OS::get_auxval(PPC_hwcap_bit::ARCH_hwcap_crypto);
if(hwcap_crypto & PPC_hwcap_bit::CRYPTO_bit)
detected_features |= CPUID::CPUID_PPC_CRYPTO_BIT;
+ if(hwcap_crypto & PPC_hwcap_bit::DARN_bit)
+ detected_features |= CPUID::CPUID_DARN_BIT;
return detected_features;