From 2f58912fddb27d1e8e0045e77adb745db62e5f42 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 21 May 2017 11:38:56 -0400 Subject: [PATCH] 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 --- cpu.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cpu.cpp b/cpu.cpp index f5822600..dd2d87fa 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -267,10 +267,21 @@ void DetectX86Features() else if (IsAMD(cpuid1)) { 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); 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); g_cacheLineSize = GETBYTE(cpuid1[2], 0); }