[10] RFR(XS): 8194494: SHA-512 stub uses AVX 2 instructions on non-supporting CPUs

Tobias Hartmann tobias.hartmann at oracle.com
Thu Jan 4 07:48:35 UTC 2018


Hi Csaba,

On 03.01.2018 20:13, matecs wrote:
> after severe segfaults in gcc7.2 (i also got a lot of deprecation,
> various null related, and soe other kind of warnings, you really
> should check the compilation on fresh sid...:),

I think that's because gcc 7.2 is currently not supported. See:
https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms

We are building with gcc 4.9.2 on Linux.

> finally it seems that i have a working self built jre...:)
> i can confirm that your patch works, the discussed trigger code
> runs without any issue. 

Perfect, thanks a lot for verifying the patch!

> then i tried my project's (freerouter.nop.hu)
> crypto tests to see the performance and it seems to me that
> this jvm only uses aes intrinsics, but none of the sha ones,
> however the cpu reports itself as it can do sha...

The SHA-512 stub is currently only implemented with AVX but SHA-256 and SHA-1 should use SHA instructions if available.

How did you check that no SHA instructions are used?

Best regards,
Tobias
> mc36 at player:~/jre/bin$ ./java -version
> openjdk version "9-internal"
> OpenJDK Runtime Environment (build 9-internal+0-adhoc.mc36.jdk9)
> OpenJDK 64-Bit Server VM (build 9-internal+0-adhoc.mc36.jdk9, mixed mode)
> mc36 at player:~/jre/bin$ ./java -jar /safe/src/src/rtr.jar test crypto
> aes: 618131 rnd, 632966144 bytes, 3 sec, 205975 pps, 1687mbps
> blowfish: 76307 rnd, 78138368 bytes, 3 sec, 25427 pps, 208mbps
> 3des: 13551 rnd, 13876224 bytes, 3 sec, 4515 pps, 36mbps
> des: 32947 rnd, 33737728 bytes, 3 sec, 10978 pps, 89mbps
> rc2: 43106 rnd, 44140544 bytes, 3 sec, 14363 pps, 117mbps
> md2: 12870 rnd, 13178880 bytes, 3 sec, 4288 pps, 35mbps
> md5: 49721 rnd, 50914304 bytes, 3 sec, 16568 pps, 135mbps
> sha1: 49745 rnd, 50938880 bytes, 3 sec, 16576 pps, 135mbps
> sha256: 50830 rnd, 52049920 bytes, 3 sec, 16937 pps, 138mbps
> sha384: 42972 rnd, 44003328 bytes, 3 sec, 14319 pps, 117mbps
> sha512: 42997 rnd, 44028928 bytes, 3 sec, 14327 pps, 117mbps
> hmac-md2: 10985 rnd, 11248640 bytes, 3 sec, 3660 pps, 29mbps
> hmac-md5: 41570 rnd, 42567680 bytes, 3 sec, 13852 pps, 113mbps
> hmac-sha1: 42608 rnd, 43630592 bytes, 3 sec, 14197 pps, 116mbps
> hmac-sha256: 40003 rnd, 40963072 bytes, 3 sec, 13329 pps, 109mbps
> hmac-sha384: 30728 rnd, 31465472 bytes, 3 sec, 10239 pps, 83mbps
> hmac-sha512: 30505 rnd, 31237120 bytes, 3 sec, 10164 pps, 83mbps
> error cfg.cfgInit.stopRouter:cfgInit.java:745 shutdown code=1 reason=finished
> mc36 at player:~/jre/bin$
> 
> 
> mc36 at mediapc:~/jre/bin$ ./java -jar /safe/src/src/rtr.jar test crypto
> aes: 340851 rnd, 349031424 bytes, 3 sec, 113579 pps, 930mbps
> blowfish: 47741 rnd, 48886784 bytes, 3 sec, 15908 pps, 130mbps
> 3des: 8761 rnd, 8971264 bytes, 3 sec, 2919 pps, 23mbps
> des: 24891 rnd, 25488384 bytes, 3 sec, 8294 pps, 67mbps
> rc2: 33098 rnd, 33892352 bytes, 3 sec, 11028 pps, 90mbps
> md2: 8770 rnd, 8980480 bytes, 3 sec, 2922 pps, 23mbps
> md5: 34564 rnd, 35393536 bytes, 3 sec, 11517 pps, 94mbps
> sha1: 36215 rnd, 37084160 bytes, 3 sec, 12067 pps, 98mbps
> sha256: 34091 rnd, 34909184 bytes, 3 sec, 11359 pps, 93mbps
> sha384: 31332 rnd, 32083968 bytes, 3 sec, 10440 pps, 85mbps
> sha512: 30960 rnd, 31703040 bytes, 3 sec, 10316 pps, 84mbps
> hmac-md2: 7952 rnd, 8142848 bytes, 3 sec, 2649 pps, 21mbps
> hmac-md5: 29842 rnd, 30558208 bytes, 3 sec, 9944 pps, 81mbps
> hmac-sha1: 30471 rnd, 31202304 bytes, 3 sec, 10153 pps, 83mbps
> hmac-sha256: 28544 rnd, 29229056 bytes, 3 sec, 9511 pps, 77mbps
> hmac-sha384: 22197 rnd, 22729728 bytes, 3 sec, 7396 pps, 60mbps
> hmac-sha512: 21893 rnd, 22418432 bytes, 3 sec, 7295 pps, 59mbps
> error cfg.cfgInit.stopRouter:cfgInit.java:745 shutdown code=1 reason=finished
> mc36 at mediapc:~/jre/bin$
> 
> 
> 
> 
> 
> 
> On 01/03/2018 05:49 PM, Tobias Hartmann wrote:
>> Hi,
>>
>> please review the following patch:
>> https://bugs.openjdk.java.net/browse/JDK-8194494
>> http://cr.openjdk.java.net/~thartmann/8194494/webrev.00/
>>
>> The VM crashes with SIGILL on CPUs that have the SHA extension but no AVX 2 support because since JDK-8165381 the
>> SHA-512 stub uses AVX 2 instructions (for example, 'vpblendd'). In addition to UseSHA, we need to check for
>> supports_avx2() && supports_bmi2() on x86.
>>
>> I had no suitable machine available for testing but I was able to trigger the problem by enforcing
>> UseSHA512Intrinsics=true on my machine and disabling AVX 2 support (see comments in the bug for details).
>>
>> This problem was reported by Csaba Mate [1].
>>
>> Thanks,
>> Tobias
>>
>> [1] http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2018-January/028002.html
>>


More information about the hotspot-compiler-dev mailing list