From 3db34abf2f9ec9c25b1140955fced60c8d40394c Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 27 Nov 2018 02:54:26 -0500 Subject: Add Power9 Random Number Generator support (GH #747, PR #748) --- cpu.h | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'cpu.h') diff --git a/cpu.h b/cpu.h index 648c859f..220eedfd 100644 --- a/cpu.h +++ b/cpu.h @@ -591,10 +591,12 @@ extern bool g_PowerpcDetectionDone; extern bool g_hasAltivec; extern bool g_hasPower7; extern bool g_hasPower8; +extern bool g_hasPower9; extern bool g_hasAES; extern bool g_hasPMULL; extern bool g_hasSHA256; extern bool g_hasSHA512; +extern bool g_hasDARN; extern word32 g_cacheLineSize; void CRYPTOPP_API DetectPowerpcFeatures(); #endif // CRYPTOPP_DOXYGEN_PROCESSING @@ -608,7 +610,7 @@ void CRYPTOPP_API DetectPowerpcFeatures(); /// \details Runtime support requires compile time support. When compiling with GCC, you may /// need to compile with -mcpu=power4; while IBM XL C/C++ compilers require /// -qarch=pwr6 -qaltivec. Also see PowerPC's _ALTIVEC_ preprocessor macro. -/// \details Atilvec was first available on Power4 platforms. However Crypto++ releies heavily +/// \details Atilvec was first available in the early 2000's. However Crypto++ releies heavily /// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7 /// extensions, then the GNUmakefile sets -DCRYPTOPP_DISABLE_POWER7. /// \note This function is only available on PowerPC and PowerPC-64 platforms @@ -619,13 +621,13 @@ inline bool HasAltivec() return g_hasAltivec; } -/// \brief Determine if a PowerPC processor has Power8 available -/// \returns true if the hardware is capable of Power8 at runtime, false otherwise. +/// \brief Determine if a PowerPC processor has Power7 available +/// \returns true if the hardware is capable of Power7 at runtime, false otherwise. /// \details Altivec instructions are available under most modern PowerPCs. /// \details Runtime support requires compile time support. When compiling with GCC, you may -/// need to compile with -mcpu=power8; while IBM XL C/C++ compilers require -/// -qarch=pwr8 -qaltivec. Also see PowerPC's _ALTIVEC_ preprocessor macro. -/// \details Atilvec was first available on Power4 platforms. However Crypto++ releies heavily +/// need to compile with -mcpu=power7; while IBM XL C/C++ compilers require +/// -qarch=pwr7 -qaltivec. Also see PowerPC's _ALTIVEC_ preprocessor macro. +/// \details Atilvec was first available in the early 2000's. However Crypto++ releies heavily /// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7 /// extensions, then the GNUmakefile sets -DCRYPTOPP_DISABLE_POWER7. /// \note This function is only available on PowerPC and PowerPC-64 platforms @@ -642,7 +644,7 @@ inline bool HasPower7() /// \details Runtime support requires compile time support. When compiling with GCC, you may /// need to compile with -mcpu=power8; while IBM XL C/C++ compilers require /// -qarch=pwr8 -qaltivec. Also see PowerPC's _ALTIVEC_ preprocessor macro. -/// \details Atilvec was first available on Power4 platforms. However Crypto++ releies heavily +/// \details Atilvec was first available in the early 2000's. However Crypto++ releies heavily /// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7 /// extensions, then the GNUmakefile sets -DCRYPTOPP_DISABLE_POWER7. /// \note This function is only available on PowerPC and PowerPC-64 platforms @@ -653,6 +655,23 @@ inline bool HasPower8() return g_hasPower8; } +/// \brief Determine if a PowerPC processor has Power9 available +/// \returns true if the hardware is capable of Power9 at runtime, false otherwise. +/// \details Altivec instructions are available under most modern PowerPCs. +/// \details Runtime support requires compile time support. When compiling with GCC, you may +/// need to compile with -mcpu=power9; while IBM XL C/C++ compilers require +/// -qarch=pwr9 -qaltivec. Also see PowerPC's _ALTIVEC_ preprocessor macro. +/// \details Atilvec was first available in the early 2000's. However Crypto++ releies heavily +/// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7 +/// extensions, then the GNUmakefile sets -DCRYPTOPP_DISABLE_POWER7. +/// \note This function is only available on PowerPC and PowerPC-64 platforms +inline bool HasPower9() +{ + if (!g_PowerpcDetectionDone) + DetectPowerpcFeatures(); + return g_hasPower9; +} + /// \brief Determine if a PowerPC processor has AES available /// \returns true if the hardware is capable of AES at runtime, false otherwise. /// \details AES is part of the in-crypto extensions on Power8 and Power9. @@ -709,6 +728,23 @@ inline bool HasSHA512() return g_hasSHA512; } +/// \brief Determine if a PowerPC processor has DARN available +/// \returns true if the hardware is capable of DARN at runtime, false otherwise. +/// \details Altivec instructions are available under most modern PowerPCs. +/// \details Runtime support requires compile time support. When compiling with GCC, you may +/// need to compile with -mcpu=power9; while IBM XL C/C++ compilers require +/// -qarch=pwr9 -qaltivec. Also see PowerPC's _ALTIVEC_ preprocessor macro. +/// \details Atilvec was first available in the early 2000's. However Crypto++ relies heavily +/// on unaligned loads and stores which is a Power7 feature. If the platform lacks Power7 +/// extensions, then the GNUmakefile sets -DCRYPTOPP_DISABLE_POWER7. +/// \note This function is only available on PowerPC and PowerPC-64 platforms +inline bool HasDARN() +{ + if (!g_PowerpcDetectionDone) + DetectPowerpcFeatures(); + return g_hasDARN; +} + /// \brief Provides the cache line size /// \returns lower bound on the size of a cache line in bytes, if available /// \details GetCacheLineSize() returns the lower bound on the size of a cache line, if it -- cgit v1.2.1