Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8194494

SHA-512 stub uses AVX 2 instructions on non-supporting CPUs

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 9, 10
    • Fix Version/s: 10
    • Component/s: hotspot
    • Labels:
    • Environment:

      Intel Celeron J3455, J3355, N3450 and N3350

    • Subcomponent:
    • Resolved In Build:
      b39
    • CPU:
      x86_64

      Backports

        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.
        1. zzz.java
          0.6 kB
          Tobias Hartmann

          Issue Links

            Activity

            Hide
            thartmann Tobias Hartmann added a comment -
            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
            Show
            thartmann Tobias Hartmann added a comment - 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
            Hide
            thartmann Tobias Hartmann added a comment - - edited
            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
            Show
            thartmann Tobias Hartmann added a comment - - edited 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
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk/jdk10/rev/a97a26eb896f
            User: thartmann
            Date: 2018-01-05 09:28:19 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk/jdk10/rev/a97a26eb896f User: thartmann Date: 2018-01-05 09:28:19 +0000

              People

              • Assignee:
                thartmann Tobias Hartmann
                Reporter:
                thartmann Tobias Hartmann
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: