From a2b615d5270f0bc2ee1dfcdd7849bdd05ee76a14 Mon Sep 17 00:00:00 2001 From: Lion Yang Date: Thu, 5 Jan 2017 05:13:53 +0800 Subject: crypto: detect BMI usability on AMD64 for sha1 and sha256 The existing implementations on AMD64 only detects AVX2 usability, when they also contains BMI (bit-manipulation instructions). These instructions crash the running program as 'unknown instructions' on the architecture, e.g. i3-4000M, which supports AVX2 but not support BMI. This change added the detections for BMI1 and BMI2 to AMD64 runtime with two flags as the result, `support_bmi1` and `support_bmi2`, in runtime/runtime2.go. It also completed the condition to run AVX2 version in packages crypto/sha1 and crypto/sha256. Fixes #18512 Change-Id: I917bf0de365237740999de3e049d2e8f2a4385ad Reviewed-on: https://go-review.googlesource.com/34850 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot --- src/runtime/runtime2.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/runtime/runtime2.go') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index acc9426142..1ceab0ad8c 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -745,6 +745,8 @@ var ( lfenceBeforeRdtsc bool support_avx bool support_avx2 bool + support_bmi1 bool + support_bmi2 bool goarm uint8 // set by cmd/link on arm systems framepointer_enabled bool // set by cmd/link -- cgit v1.3-5-g9baa