summaryrefslogtreecommitdiff
path: root/cpu.cpp
diff options
context:
space:
mode:
authorhygonsoc <45824512+hygonsoc@users.noreply.github.com>2018-12-21 06:33:16 +0800
committerJeffrey Walton <noloader@gmail.com>2018-12-20 17:33:16 -0500
commit6dfb428f1066f02b6fe8181c81da1b062c430665 (patch)
tree51c983ca121a7ff9d0386d9d49c86e5b2b789fab /cpu.cpp
parent398964b87d93ee5c379f2b21a7304a7683e3cd61 (diff)
downloadcryptopp-git-6dfb428f1066f02b6fe8181c81da1b062c430665.tar.gz
Add Hygon Dhyana support to enable RDRAND/RDSEED/ADX/AVX2 Feature (PR #765)
Hugh, interesting. Thank you very much. Ping @randombit. Botan may want or need this, too.
Diffstat (limited to 'cpu.cpp')
-rw-r--r--cpu.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/cpu.cpp b/cpu.cpp
index b60ef1df..4dcd5c0c 100644
--- a/cpu.cpp
+++ b/cpu.cpp
@@ -280,6 +280,14 @@ static inline bool IsAMD(const word32 output[4])
(output[3] /*EDX*/ == 0x69746E65);
}
+static inline bool IsHygon(const word32 output[4])
+{
+ // This is the "HygonGenuine" string.
+ return (output[1] /*EBX*/ == 0x6f677948) &&
+ (output[2] /*ECX*/ == 0x656e6975) &&
+ (output[3] /*EDX*/ == 0x6e65476e);
+}
+
static inline bool IsVIA(const word32 output[4])
{
// This is the "CentaurHauls" string. Some non-PadLock's can return "VIA VIA VIA "
@@ -383,7 +391,7 @@ void DetectX86Features()
}
}
}
- else if (IsAMD(cpuid0))
+ else if (IsAMD(cpuid0) || IsHygon(cpuid0))
{
CRYPTOPP_CONSTANT(RDRAND_FLAG = (1 << 30))
CRYPTOPP_CONSTANT(RDSEED_FLAG = (1 << 18))