From: Meng Zhuo Date: Thu, 26 May 2022 14:36:15 +0000 (+0800) Subject: internal/cpu: add sha512 for arm64 X-Git-Tag: go1.20rc1~1750 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=228f891c905af8c01743085a74b2189f58eecba1;p=gostls13.git internal/cpu: add sha512 for arm64 The new M1 cpu (Apple) comes with sha512 hardware acceleration feature. Change-Id: I823d1e9b09b472bd21571eee75cc5314cd66b1ff Reviewed-on: https://go-review.googlesource.com/c/go/+/408836 Reviewed-by: Than McIntosh Run-TryBot: Cherry Mui Reviewed-by: Cherry Mui TryBot-Result: Gopher Robot --- diff --git a/src/internal/cpu/cpu.go b/src/internal/cpu/cpu.go index ae23b59617..c02dadccf6 100644 --- a/src/internal/cpu/cpu.go +++ b/src/internal/cpu/cpu.go @@ -61,6 +61,7 @@ var ARM64 struct { HasPMULL bool HasSHA1 bool HasSHA2 bool + HasSHA512 bool HasCRC32 bool HasATOMICS bool HasCPUID bool diff --git a/src/internal/cpu/cpu_arm64.go b/src/internal/cpu/cpu_arm64.go index f64d9e4dd3..d02c9b99d0 100644 --- a/src/internal/cpu/cpu_arm64.go +++ b/src/internal/cpu/cpu_arm64.go @@ -12,6 +12,7 @@ func doinit() { {Name: "pmull", Feature: &ARM64.HasPMULL}, {Name: "sha1", Feature: &ARM64.HasSHA1}, {Name: "sha2", Feature: &ARM64.HasSHA2}, + {Name: "sha512", Feature: &ARM64.HasSHA512}, {Name: "crc32", Feature: &ARM64.HasCRC32}, {Name: "atomics", Feature: &ARM64.HasATOMICS}, {Name: "cpuid", Feature: &ARM64.HasCPUID}, diff --git a/src/internal/cpu/cpu_arm64_darwin.go b/src/internal/cpu/cpu_arm64_darwin.go index 730e14caff..60beadddbb 100644 --- a/src/internal/cpu/cpu_arm64_darwin.go +++ b/src/internal/cpu/cpu_arm64_darwin.go @@ -9,6 +9,7 @@ package cpu func osInit() { ARM64.HasATOMICS = sysctlEnabled([]byte("hw.optional.armv8_1_atomics\x00")) ARM64.HasCRC32 = sysctlEnabled([]byte("hw.optional.armv8_crc32\x00")) + ARM64.HasSHA512 = sysctlEnabled([]byte("hw.optional.armv8_2_sha512\x00")) // There are no hw.optional sysctl values for the below features on Mac OS 11.0 // to detect their supported state dynamically. Assume the CPU features that