weidai11 / cryptopp

free C++ class library of cryptographic schemes
https://cryptopp.com
Other
4.66k stars 1.47k forks source link

PowerMac and Illegal Instruction #1115

Open noloader opened 2 years ago

noloader commented 2 years ago

This is another new issue. Running the test suite on an old PowerMac with Debian Sid installed in a debug build:

(gdb) r v
Starting program: /home/jwalton/cryptopp/cryptest.exe v
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc64-linux-gnu/libthread_db.so.1".
...

Program received signal SIGILL, Illegal instruction.
0x00000001008fe278 in CryptoPP::CPU_ProbePower8 () at ppc_power8.cpp:70
70              word64 w1[2] = {x, x}, w2[2] = {4, 6}, w3[2];
(gdb) c
Continuing.

Program received signal SIGILL, Illegal instruction.
0x00000001008fe158 in CryptoPP::SigIllHandler () at ppc_power8.cpp:34
34          {
(gdb) c
Continuing.

Program terminated with signal SIGILL, Illegal instruction.

The first SIGILL is expected since it is our probe. The second SIGILL is not.

It looks like GCC is using POWER8 instructions without guarding them.

Related issue for this platform and compiler are GH #986 and GH #1112.

noloader commented 2 years ago

This is a lot worse then I thought. GCC is using mtfprwz throughout the code where we were forced to use -mcpu=power8. mtfprwz is being used in function preamble. BLAKE2b, AES and SHA are crashing on an old PowerMac.