]> Cypherpunks repositories - gostls13.git/commitdiff
x/crypto/chacha20poly1305: fix detection of BMI on AMD64
authorLion Yang <lion@aosc.xyz>
Wed, 4 Jan 2017 22:25:59 +0000 (06:25 +0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 5 Jan 2017 17:50:56 +0000 (17:50 +0000)
This change uses runtime.support_bmi2 as an additional condition
to examine the usability of AVX2 version algorithm, fixes
the crash on the platfrom which supports AVX2 but not support BMI2.

Fixes #18512

Change-Id: I408c0844ae2eb242dacf70cb9e8cec1b8f3bd941
Reviewed-on: https://go-review.googlesource.com/34851
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/vendor/golang_org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s

index 2fa9b555a89aa27f8fa3b937ba6af0921db026aa..7c6a1a5e68a47d3488d87ed5a28475c98b3d113e 100644 (file)
@@ -278,9 +278,11 @@ TEXT ·chacha20Poly1305Open(SB), 0, $288-97
        MOVQ ad+72(FP), adp
 
        // Check for AVX2 support
-       CMPB runtime·support_avx2(SB), $1
-       JE   chacha20Poly1305Open_AVX2
-
+       CMPB runtime·support_avx2(SB), $0
+       JE   noavx2bmi2Open
+       CMPB runtime·support_bmi2(SB), $1  // for MULXQ
+       JE  chacha20Poly1305Open_AVX2
+noavx2bmi2Open:
        // Special optimization, for very short buffers
        CMPQ inl, $128
        JBE  openSSE128 // About 16% faster
@@ -1485,9 +1487,11 @@ TEXT ·chacha20Poly1305Seal(SB), 0, $288-96
        MOVQ ad+72(FP), adp
 
        // Check for AVX2 support
-       CMPB runtime·support_avx2(SB), $1
+       CMPB runtime·support_avx2(SB), $0
+       JE   noavx2bmi2Seal
+       CMPB runtime·support_bmi2(SB), $1  // for MULXQ
        JE   chacha20Poly1305Seal_AVX2
-
+noavx2bmi2Seal:
        // Special optimization, for very short buffers
        CMPQ inl, $128
        JBE  sealSSE128 // About 15% faster