Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simd_32 test fails on ppc64le #1498

Closed
thmo opened this issue Mar 16, 2018 · 10 comments
Closed

simd_32 test fails on ppc64le #1498

thmo opened this issue Mar 16, 2018 · 10 comments

Comments

@thmo
Copy link

thmo commented Mar 16, 2018

For 2.4.0, with gcc 8.0.1 on ppc64le, we see the following test failures:

simd_32:
SIMD_4x32 ran 240 tests 8 FAILED
Failure 1: SIMD_4x32 SIMD_4x32 bswap elem0 BE produced unexpected result '4041265344' expected '3721182122'
Failure 2: SIMD_4x32 SIMD_4x32 bswap elem1 BE produced unexpected result '1732584193' expected '558065031'
Failure 3: SIMD_4x32 SIMD_4x32 bswap elem2 BE produced unexpected result '558065031' expected '1732584193'
Failure 4: SIMD_4x32 SIMD_4x32 bswap elem3 BE produced unexpected result '3721182122' expected '4041265344'
Failure 5: SIMD_4x32 SIMD_4x32 bswap elem0 LE produced unexpected result '4041265344' expected '3721182122'
Failure 6: SIMD_4x32 SIMD_4x32 bswap elem1 LE produced unexpected result '1732584193' expected '558065031'
Failure 7: SIMD_4x32 SIMD_4x32 bswap elem2 LE produced unexpected result '558065031' expected '1732584193'
Failure 8: SIMD_4x32 SIMD_4x32 bswap elem3 LE produced unexpected result '3721182122' expected '4041265344'

There are warnings during compilation:

g++ -fstack-protector -pthread -std=c++11 -D_REENTRANT -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -funwind-tables -fstack-clash-protection -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -maltivec -Ibuild/include -Ibuild/include/external -c src/tests/test_simd.cpp -o build/obj/test/test_simd.o
In file included from src/tests/test_simd.cpp:10:
build/include/botan/internal/simd_32.h: In constructor 'Botan::SIMD_4x32::SIMD_4x32(const uint32_t*)':
build/include/botan/internal/simd_32.h:82:64: warning: ISO C++ forbids compound-literals [-Wpedantic]
          m_vmx = (__vector unsigned int){B[0], B[1], B[2], B[3]};
                                                                ^
build/include/botan/internal/simd_32.h: In constructor 'Botan::SIMD_4x32::SIMD_4x32(uint32_t, uint32_t, uint32_t, uint32_t)':
build/include/botan/internal/simd_32.h:101:56: warning: ISO C++ forbids compound-literals [-Wpedantic]
          m_vmx = (__vector unsigned int){B0, B1, B2, B3};
                                                        ^
build/include/botan/internal/simd_32.h: In static member function 'static Botan::SIMD_4x32 Botan::SIMD_4x32::load_le(const void*)':
build/include/botan/internal/simd_32.h:141:57: warning: vec_lvsl is deprecated for little endian; use assignment for unaligned loads and stores [-Wdeprecated]
          __vector unsigned char perm = vec_lvsl(0, in_32);
                                                         ^
build/include/botan/internal/simd_32.h: In static member function 'static Botan::SIMD_4x32 Botan::SIMD_4x32::load_be(const void*)':
build/include/botan/internal/simd_32.h:182:57: warning: vec_lvsl is deprecated for little endian; use assignment for unaligned loads and stores [-Wdeprecated]
          __vector unsigned char perm = vec_lvsl(0, in_32);
                                                         ^
build/include/botan/internal/simd_32.h: In member function 'Botan::SIMD_4x32 Botan::SIMD_4x32::rho() const':
build/include/botan/internal/simd_32.h:310:74: warning: ISO C++ forbids compound-literals [-Wpedantic]
          res.m_vmx = vec_rl(m_vmx, (__vector unsigned int){r1, r1, r1, r1});
                                                                          ^
build/include/botan/internal/simd_32.h:311:93: warning: ISO C++ forbids compound-literals [-Wpedantic]
          res.m_vmx = vec_xor(res.m_vmx, vec_rl(m_vmx, (__vector unsigned int){r2, r2, r2, r2}));
                                                                                             ^
build/include/botan/internal/simd_32.h:312:93: warning: ISO C++ forbids compound-literals [-Wpedantic]
          res.m_vmx = vec_xor(res.m_vmx, vec_rl(m_vmx, (__vector unsigned int){r3, r3, r3, r3}));
                                                                                             ^
build/include/botan/internal/simd_32.h: In member function 'Botan::SIMD_4x32 Botan::SIMD_4x32::rotl() const':
build/include/botan/internal/simd_32.h:357:75: warning: ISO C++ forbids compound-literals [-Wpedantic]
          return SIMD_4x32(vec_rl(m_vmx, (__vector unsigned int){r, r, r, r}));
                                                                           ^
build/include/botan/internal/simd_32.h: In member function 'Botan::SIMD_4x32 Botan::SIMD_4x32::shl() const':
build/include/botan/internal/simd_32.h:519:75: warning: ISO C++ forbids compound-literals [-Wpedantic]
          return SIMD_4x32(vec_sl(m_vmx, (__vector unsigned int){s, s, s, s}));
                                                                           ^
build/include/botan/internal/simd_32.h: In member function 'Botan::SIMD_4x32 Botan::SIMD_4x32::shr() const':
build/include/botan/internal/simd_32.h:537:75: warning: ISO C++ forbids compound-literals [-Wpedantic]
          return SIMD_4x32(vec_sr(m_vmx, (__vector unsigned int){s, s, s, s}));
                                                                           ^
build/include/botan/internal/simd_32.h: In member function 'Botan::SIMD_4x32 Botan::SIMD_4x32::bswap() const':
build/include/botan/internal/simd_32.h:596:83: warning: vec_lvsl is deprecated for little endian; use assignment for unaligned loads and stores [-Wdeprecated]
          __vector unsigned char perm = vec_lvsl(0, static_cast<uint32_t*>(nullptr));
                                                                                   ^

not sure if that is related.

@thmo
Copy link
Author

thmo commented Mar 16, 2018

Noted that the test results are reversed compared to the expected results.

@randombit
Copy link
Owner

I don't see this problem with GCC 7.3 on ppc64le (CentOS 7) so it may be something about GCC 8.0. I don't think the warnings are related.

@randombit
Copy link
Owner

I can reproduce the error with gcc version 8.0.1 20180219 (experimental)

@randombit
Copy link
Owner

With -O0 everything works as expected, with -O1 fails. So I am highly suspicious this is a bug in GCC 8.

@randombit
Copy link
Owner

What is really strange is none of the SIMD enabled block ciphers see any test failures. But I can confirm that they are enabled (by seeing the performance difference between default and --clear-cpuid=altivec)

randombit added a commit that referenced this issue Mar 16, 2018
Seems to cause problems with GCC 8 on ppc64le. GH #1498
@randombit
Copy link
Owner

I was unable to reduce it to a small testcase, so it's hard to say for sure if this is a GCC bug or not. But I did find a reformation of the function (0ebad38) which passes the tests with GCC 8 so I guess that's something. Can you try that patch with 2.4.0? Should backport cleanly.

@thmo
Copy link
Author

thmo commented Mar 16, 2018

Unfortunately, that doesn't seem to help in our build environment, the test still fails:
https://kojipkgs.fedoraproject.org//work/tasks/6163/25746163/build.log

@randombit
Copy link
Owner

Ugh. Can you try this:

          vec.V = m_vmx;
          bswap_4(vec.R);
-         return SIMD_4x32(vec.V);
+         return SIMD_4x32(vec.R[0], vec.R[1], vec.R[2], vec.R[3]);

@thmo
Copy link
Author

thmo commented Mar 17, 2018

That seems to work.

@randombit
Copy link
Owner

Thanks for confirming. Fix applied to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants