From 788cd1794dc39e382eb6612aa256918d8e0d3a55 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 11 Jan 2018 17:59:24 -0500 Subject: [PATCH] Use x86 highest basic before calling a leaf function This was a latent bug that just surfaced on a Sun Core2 workstation. RDSEED caused an illegal instruction exception on the Core2. It seems we managed to miss it because old processors had family and stepping values so low they never set CPUID.EBX.RDSEED[bit 18] = 1. Newer processors had the feature so CPUID.EBX.RDSEED[bit 18] = 1 was accurate. --- cpu.cpp | 4 ++-- ppc-simd.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cpu.cpp b/cpu.cpp index c3db0f77..a5d036b1 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -240,7 +240,7 @@ void DetectX86Features() g_cacheLineSize = 8 * GETBYTE(cpuid1[1], 1); g_hasRDRAND = !!(cpuid1[2] /*ECX*/ & RDRAND_FLAG); - if (cpuid1[0] /*EAX*/ >= 7) + if (cpuid0[0] /*EAX*/ >= 7) { if (CpuId(7, 0, cpuid2)) { @@ -261,7 +261,7 @@ void DetectX86Features() g_cacheLineSize = GETBYTE(cpuid2[2], 0); g_hasRDRAND = !!(cpuid1[2] /*ECX*/ & RDRAND_FLAG); - if (cpuid1[0] /*EAX*/ >= 7) + if (cpuid0[0] /*EAX*/ >= 7) { if (CpuId(7, 0, cpuid2)) { diff --git a/ppc-simd.cpp b/ppc-simd.cpp index b2db77e3..c9affcd3 100644 --- a/ppc-simd.cpp +++ b/ppc-simd.cpp @@ -7,7 +7,7 @@ // appropriate instructions sets in some build configurations. // TODO: we still need to implement Power8 SHA. Once we have Power8 SHA, -// we should be able to use CRYPTOPP_POWER8_AES_AVAILABLE and +// we should be able to use CRYPTOPP_POWER8_AES_AVAILABLE and // CRYPTOPP_POWER8_SHA_AVAILABLE instead of the broader // CRYPTOPP_POWER8_AVAILABLE. The change will need to be coordinated // with the defines in config.h.