From 88cc8a00f4a7fc34003b961c572d5a78462dd682 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Tue, 4 Jul 2017 11:19:53 +0200 Subject: Windows: correctly handle SEH exceptions during self-tests in order to disable CPU extended features in such case. --- src/Crypto/cpu.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/Crypto/cpu.c') diff --git a/src/Crypto/cpu.c b/src/Crypto/cpu.c index 7ec5b988..69a7fcff 100644 --- a/src/Crypto/cpu.c +++ b/src/Crypto/cpu.c @@ -200,10 +200,10 @@ static uint64 xgetbv() #endif } -int g_x86DetectionDone = 0; -int g_hasISSE = 0, g_hasSSE2 = 0, g_hasSSSE3 = 0, g_hasMMX = 0, g_hasAESNI = 0, g_hasCLMUL = 0, g_isP4 = 0; -int g_hasAVX = 0, g_hasAVX2 = 0, g_hasBMI2 = 0, g_hasSSE42 = 0, g_hasSSE41 = 0, g_isIntel = 0, g_isAMD = 0; -uint32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; +volatile int g_x86DetectionDone = 0; +volatile int g_hasISSE = 0, g_hasSSE2 = 0, g_hasSSSE3 = 0, g_hasMMX = 0, g_hasAESNI = 0, g_hasCLMUL = 0, g_isP4 = 0; +volatile int g_hasAVX = 0, g_hasAVX2 = 0, g_hasBMI2 = 0, g_hasSSE42 = 0, g_hasSSE41 = 0, g_isIntel = 0, g_isAMD = 0; +volatile uint32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; VC_INLINE int IsIntel(const uint32 output[4]) { @@ -381,5 +381,23 @@ int is_aes_hw_cpu_supported () return bHasAESNI; } +void DisableCPUExtendedFeatures () +{ + g_hasSSE2 = 0; + g_hasISSE = 0; + g_hasMMX = 0; + g_hasSSE2 = 0; + g_hasISSE = 0; + g_hasMMX = 0; + g_hasAVX = 0; + g_hasAVX2 = 0; + g_hasBMI2 = 0; + g_hasSSE42 = 0; + g_hasSSE41 = 0; + g_hasSSSE3 = 0; + g_hasAESNI = 0; + g_hasCLMUL = 0; +} + #endif -- cgit v1.2.3