JDK-8194494 : SHA-512 stub uses AVX 2 instructions on non-supporting CPUs
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9,10
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • CPU: x86_64
  • Submitted: 2018-01-03
  • Updated: 2018-09-25
  • Resolved: 2018-01-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 11
10 b39Fixed 11Fixed
Related Reports
Relates :  
Relates :  
Description
See: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2018-January/028002.html

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x00007fae6f67c0b4, pid=16238, tid=16239

Stack: [0x00007fae8f6b8000,0x00007fae8f7b8000],  sp=0x00007fae8f7b6940, 
free space=1018k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
v  ~StubRoutines::sha512_implCompress J 171% c2 zzz.main([Ljava/lang/String;)V (96 bytes) @ 0x00007fae770f3689 [0x00007fae770f34a0+0x00000000000001e9]
v  ~StubRoutines::call_stub
V  [libjvm.so+0x7dc059]
V  [libjvm.so+0x7ff420]
V  [libjvm.so+0x801cb1]
C  [libjli.so+0x4b20]
C  [libjli.so+0x89ad]
C  [libpthread.so.0+0x7519]  start_thread+0xd9

The problem seems to be that the processor does not support AVX 2 instructions but the SHA-512 stub uses them. The instruction at the failing address is:

0x00007fae6f67c0b4:  vpblendd(xmm0, xmm0, xmm1, 0xF0, AVX_128bit)

Looking at the specification for the Intel Celeron J3455 [1], AVX 2 is not supported. I think the problem is that the stub is only guarded by UseSHA and since the CPU does support SHA, the stub is emitted without checking for AVX 2
support.

This code was introduced in JDK 9 by JDK-8165381.
Comments
This affects Intel Celeron J3455, J3355, N3450, N3350 and potentially other processors that have SHA support but no AVX 2 support. I don't have such a machine available for testing but I was able to trigger the problem by enforcing UseSHA512Intrinsics=true: --- a/src/hotspot/cpu/x86/vm_version_x86.cpp Tue Jan 02 07:50:17 2018 -0500 +++ b/src/hotspot/cpu/x86/vm_version_x86.cpp Wed Jan 03 16:56:20 2018 +0100 @@ -882,7 +882,7 @@ FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); } - if (UseSHA) { + if (true) { if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) { FLAG_SET_DEFAULT(UseSHA512Intrinsics, true); } And then running with AVX 2 disabled (-XX:UseAVX=1). The stub will still contain AVX 2 instructions, triggering the following assert in a debug build: # Internal Error (/oracle/jdk_hs/open/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp:3803), pid=31128, tid=31129 # Error: assert(VM_Version::supports_avx2()) failed
04-01-2018

ILW = Crash in stub code due to unsupported AVX 2 instruction, on CPUs supporting SHA but not AVX 2, -XX:DisableIntrinsic=_sha5_implCompress or -XX:-UseSHA = HML = P2
03-01-2018