From fd5e35fcb685b6a0b43742b72f6542fd5f80b8fb Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 30 Nov 2018 05:28:44 -0500 Subject: [PATCH] Fix SIGILL on Linux when using XLC for DARN --- ppc_power9.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ppc_power9.cpp b/ppc_power9.cpp index 38c231f5..f4fbd371 100644 --- a/ppc_power9.cpp +++ b/ppc_power9.cpp @@ -6,6 +6,14 @@ // additional CXXFLAGS are required to enable the appropriate // 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 "config.h" @@ -43,6 +51,8 @@ bool CPU_ProbePower9() { #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) return false; +#elif defined(__xlC__) && defined(__linux__) + return false; #elif defined(CRYPTOPP_POWER9_AVAILABLE) # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) // longjmp and clobber warnings. Volatile is required. @@ -80,15 +90,18 @@ bool CPU_ProbePower9() #endif // _ARCH_PWR9 } -// The DARN probe is not guarded with a preprocessor macro at the moment. We don't -// use CRYPTOPP_POWER9_AVAILABLE because old compilers, like GCC 4.8 on CentOS 7, -// will report NO even though we can produce the random numbers. Other Power9 -// implementations which use builtins will use the preprocessor macro guard. This -// strategy also gets into a situation where Power9 is not available but DARN is. +// The DARN probe is not guarded with a preprocessor macro at the moment. We +// don't use CRYPTOPP_POWER9_AVAILABLE because old compilers, like GCC 4.8 on +// CentOS 7, will report NO even though we can produce the random numbers. +// Other Power9 implementations which use builtins will use the preprocessor +// macro guard. This strategy also gets into a situation where Power9 is not +// available but DARN is. bool CPU_ProbeDARN() { #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) return false; +#elif defined(__xlC__) && defined(__linux__) + return false; #else # if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY) // longjmp and clobber warnings. Volatile is required.