Enable RDSEED and SHA for AMD processors

AMD donated a AMD Ryzen 7 1700X to the GCC Compile Farm. We were able to verify compatibility and correctness. Many thanks to AMD for the donation
pull/242/merge
Jeffrey Walton 2017-05-21 11:38:56 -04:00
parent 5fd202077c
commit 2f58912fdd
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 11 additions and 0 deletions

11
cpu.cpp
View File

@ -267,10 +267,21 @@ void DetectX86Features()
else if (IsAMD(cpuid1)) else if (IsAMD(cpuid1))
{ {
static const unsigned int RDRAND_FLAG = (1 << 30); static const unsigned int RDRAND_FLAG = (1 << 30);
static const unsigned int RDSEED_FLAG = (1 << 18);
static const unsigned int SHA_FLAG = (1 << 29);
CpuId(0x01, cpuid1); CpuId(0x01, cpuid1);
g_hasRDRAND = !!(cpuid1[2] /*ECX*/ & RDRAND_FLAG); g_hasRDRAND = !!(cpuid1[2] /*ECX*/ & RDRAND_FLAG);
if (cpuid1[0] /*EAX*/ >= 7)
{
if (CpuId(7, cpuid3))
{
g_hasRDSEED = !!(cpuid3[1] /*EBX*/ & RDSEED_FLAG);
g_hasSHA = !!(cpuid3[1] /*EBX*/ & SHA_FLAG);
}
}
CpuId(0x80000005, cpuid1); CpuId(0x80000005, cpuid1);
g_cacheLineSize = GETBYTE(cpuid1[2], 0); g_cacheLineSize = GETBYTE(cpuid1[2], 0);
} }