[MDEV-20386] Replace inline asm with compiler-builtin intrinsic functions Created: 2019-08-19 Updated: 2021-01-02 Resolved: 2021-01-01 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Encryption, Storage Engine - InnoDB |
| Affects Version/s: | 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.5.9, 10.6.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | MSAN, portability | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Description |
|
As noted in Here is a crude patch for WolfSSL:
and another for InnoDB:
Both these patches will require some compiler switches to enable the instructions to be emitted. For clang 8.0.1, -march=native did the trick for me, but that is obviously unacceptable. According to diagnostic messages from the compiler, the features might be called "rdseed" and "SSE 4.2". |
| Comments |
| Comment by Vladislav Vaintroub [ 2019-08-19 ] | |||||||||||
|
You may file a bug against wolfssl/wolfcrypt. we do not change WolfSSL code | |||||||||||
| Comment by Marko Mäkelä [ 2019-08-19 ] | |||||||||||
|
Very well, I can file a separate bug against WolfSSL. Meanwhile, can you please look at the InnoDB part? This is blocking the use of MSAN, which is an important tool for quality assurance. It promises to have only 3× CPU overhead, which is much lower than Valgrind. Hence, "won’t fix" is not an acceptable resolution. | |||||||||||
| Comment by Marko Mäkelä [ 2019-08-19 ] | |||||||||||
|
Replace inline asm with compiler built-in intrinsic functions #2415 was filed against WolfSSL. | |||||||||||
| Comment by Vladislav Vaintroub [ 2020-03-18 ] | |||||||||||
|
I'm closing this since this is not in our code, and since the bug was already files against WolfSSL. | |||||||||||
| Comment by Marko Mäkelä [ 2020-03-25 ] | |||||||||||
|
I am reopening this, because | |||||||||||
| Comment by Marko Mäkelä [ 2020-08-31 ] | |||||||||||
|
The WolfSSL problem was worked around by disabling all acceleration in WITH_MSAN=ON builds. The InnoDB CRC-32C implementation now uses Intel intrinsic functions. Only in GCC 4 we will have to use __builtin_ functions, because the header <nmmintrin.h> is not compatible with that compiler. | |||||||||||
| Comment by Marko Mäkelä [ 2020-09-01 ] | |||||||||||
|
I submitted WolfSSL pull request #3268 to use the Intel intrinsic functions for RDRAND and RDSEED whenever applicable and made a test build. | |||||||||||
| Comment by Marko Mäkelä [ 2020-09-25 ] | |||||||||||
|
My pull request was merged to WolfSSL, and we can actually enable the rdrand and rdseed instructions in WITH_MSAN builds. But, we still must disable the hand-written assembler code until some instrumentation is added to WolfSSL. That should involve invoking __msan_check_mem_is_initialized() on the input and __msan_unpoison() on the output of the assembler code. | |||||||||||
| Comment by Marko Mäkelä [ 2020-10-03 ] | |||||||||||
|
I submitted another test build with the newest WolfSSL. | |||||||||||
| Comment by Daniel Black [ 2020-10-06 ] | |||||||||||
|
note: -march flags/test still required (10.3-d99f787244ab82f658b3f4a6c9877289e6385e04
| |||||||||||
| Comment by Marko Mäkelä [ 2020-10-22 ] | |||||||||||
|
danblack, I did not claim to fix earlier versions than 10.5. The main motivation of this is to be able to use WITH_MSAN without any -march. There have been a lot of fixes in 10.5 to the CRC-32 and CRC-32C code that we did not port to earlier versions. Does the 10.3 build fail on a platform where clang is the default compiler, such as FreeBSD or Mac OS X? | |||||||||||
| Comment by Daniel Black [ 2020-10-23 ] | |||||||||||
|
pushed https://travis-ci.org/github/grooverdan/mariadb-server/builds/738179878 as OSX test with MSAN enabled. | |||||||||||
| Comment by Marko Mäkelä [ 2020-12-10 ] | |||||||||||
|
danblack, I updated the bb-10.5- | |||||||||||
| Comment by Marko Mäkelä [ 2021-01-01 ] | |||||||||||
| Comment by Marko Mäkelä [ 2021-01-01 ] | |||||||||||
|
|