Fix SIGILL on Linux when using XLC for DARN

pull/752/head
Jeffrey Walton 2018-11-30 05:28:44 -05:00
parent 8fba667250
commit fd5e35fcb6
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 18 additions and 5 deletions

View File

@ -6,6 +6,14 @@
// additional CXXFLAGS are required to enable the appropriate // additional CXXFLAGS are required to enable the appropriate
// instructions sets in some build configurations. // instructions sets in some build configurations.
// The XLC on Linux case is a special case because code generated by XLC on
// Linux claims the generator is available when it is not. LLVM Clang does
// not have the trouble. The problem seems to be related to the signal
// handler. It looks like first call to CPU_ProbePower9() and CPU_ProbeDARN()
// are correct, but the call to HasDARN() returns the wrong result. If I am
// parsing things correctly while stepping the code and disassembly, it looks
// like the result of the inline asm is being removed.
#include "pch.h" #include "pch.h"
#include "config.h" #include "config.h"
@ -43,6 +51,8 @@ bool CPU_ProbePower9()
{ {
#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
return false; return false;
#elif defined(__xlC__) && defined(__linux__)
return false;
#elif defined(CRYPTOPP_POWER9_AVAILABLE) #elif defined(CRYPTOPP_POWER9_AVAILABLE)
# if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY)
// longjmp and clobber warnings. Volatile is required. // longjmp and clobber warnings. Volatile is required.
@ -80,15 +90,18 @@ bool CPU_ProbePower9()
#endif // _ARCH_PWR9 #endif // _ARCH_PWR9
} }
// The DARN probe is not guarded with a preprocessor macro at the moment. We don't // The DARN probe is not guarded with a preprocessor macro at the moment. We
// use CRYPTOPP_POWER9_AVAILABLE because old compilers, like GCC 4.8 on CentOS 7, // don't use CRYPTOPP_POWER9_AVAILABLE because old compilers, like GCC 4.8 on
// will report NO even though we can produce the random numbers. Other Power9 // CentOS 7, will report NO even though we can produce the random numbers.
// implementations which use builtins will use the preprocessor macro guard. This // Other Power9 implementations which use builtins will use the preprocessor
// strategy also gets into a situation where Power9 is not available but DARN is. // macro guard. This strategy also gets into a situation where Power9 is not
// available but DARN is.
bool CPU_ProbeDARN() bool CPU_ProbeDARN()
{ {
#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
return false; return false;
#elif defined(__xlC__) && defined(__linux__)
return false;
#else #else
# if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY)
// longjmp and clobber warnings. Volatile is required. // longjmp and clobber warnings. Volatile is required.