]> Cypherpunks repositories - gostls13.git/commitdiff
internal/cpu: change s390x API to match x/sys/cpu
authorMichael Munday <mike.munday@ibm.com>
Thu, 28 Feb 2019 09:40:51 +0000 (04:40 -0500)
committerMichael Munday <mike.munday@ibm.com>
Thu, 28 Feb 2019 13:46:45 +0000 (13:46 +0000)
This CL changes the internal/cpu API to more closely match the
public version in x/sys/cpu (added in CL 163003). This will make it
easier to update the dependencies of vendored code. The most prominent
renaming is from VE1 to VXE for the vector-enhancements facility 1.
VXE is the mnemonic used for this facility in the HWCAP vector.

Change-Id: I922d6c8bb287900a4bd7af70567e22eac567b5c1
Reviewed-on: https://go-review.googlesource.com/c/164437
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/crypto/elliptic/p256_s390x.go
src/internal/cpu/cpu.go
src/internal/cpu/cpu_s390x.go

index ac53a85a5cb03e32b35d7523e2226536029a2503..0d9478bfd6a4599736bc383b64cf64e845e693cf 100644 (file)
@@ -15,7 +15,7 @@ import (
 
 const (
        offsetS390xHasVX  = unsafe.Offsetof(cpu.S390X.HasVX)
-       offsetS390xHasVE1 = unsafe.Offsetof(cpu.S390X.HasVE1)
+       offsetS390xHasVE1 = unsafe.Offsetof(cpu.S390X.HasVXE)
 )
 
 type p256CurveFast struct {
index eb74a9fa82a59793995cceb5c81d1805658aa361..3029bcb0c295d917c0309fce5b347c9e42499eaf 100644 (file)
@@ -109,25 +109,26 @@ type arm64 struct {
 var S390X s390x
 
 type s390x struct {
-       _               CacheLinePad
-       HasZArch        bool // z architecture mode is active [mandatory]
-       HasSTFLE        bool // store facility list extended [mandatory]
-       HasLDisp        bool // long (20-bit) displacements [mandatory]
-       HasEImm         bool // 32-bit immediates [mandatory]
-       HasDFP          bool // decimal floating point
-       HasETF3Enhanced bool // ETF-3 enhanced
-       HasMSA          bool // message security assist (CPACF)
-       HasAES          bool // KM-AES{128,192,256} functions
-       HasAESCBC       bool // KMC-AES{128,192,256} functions
-       HasAESCTR       bool // KMCTR-AES{128,192,256} functions
-       HasAESGCM       bool // KMA-GCM-AES{128,192,256} functions
-       HasGHASH        bool // KIMD-GHASH function
-       HasSHA1         bool // K{I,L}MD-SHA-1 functions
-       HasSHA256       bool // K{I,L}MD-SHA-256 functions
-       HasSHA512       bool // K{I,L}MD-SHA-512 functions
-       HasVX           bool // vector facility. Note: the runtime sets this when it processes auxv records.
-       HasVE1          bool // vector-enhancement 1
-       _               CacheLinePad
+       _         CacheLinePad
+       HasZARCH  bool // z architecture mode is active [mandatory]
+       HasSTFLE  bool // store facility list extended [mandatory]
+       HasLDISP  bool // long (20-bit) displacements [mandatory]
+       HasEIMM   bool // 32-bit immediates [mandatory]
+       HasDFP    bool // decimal floating point
+       HasETF3EH bool // ETF-3 enhanced
+       HasMSA    bool // message security assist (CPACF)
+       HasAES    bool // KM-AES{128,192,256} functions
+       HasAESCBC bool // KMC-AES{128,192,256} functions
+       HasAESCTR bool // KMCTR-AES{128,192,256} functions
+       HasAESGCM bool // KMA-GCM-AES{128,192,256} functions
+       HasGHASH  bool // KIMD-GHASH function
+       HasSHA1   bool // K{I,L}MD-SHA-1 functions
+       HasSHA256 bool // K{I,L}MD-SHA-256 functions
+       HasSHA512 bool // K{I,L}MD-SHA-512 functions
+       HasSHA3   bool // K{I,L}MD-SHA3-{224,256,384,512} and K{I,L}MD-SHAKE-{128,256} functions
+       HasVX     bool // vector facility. Note: the runtime sets this when it processes auxv records.
+       HasVXE    bool // vector-enhancements facility 1
+       _         CacheLinePad
 }
 
 // Initialize examines the processor and sets the relevant variables above.
index 4d63ef60d101f02d6fbd33d97747d944020064bf..2c3c9d0ea89d5523d0ff19aa82e007d40d50f246 100644 (file)
@@ -22,9 +22,15 @@ const (
        aes256 function = 20 // AES-256
 
        // K{I,L}MD function codes
-       sha1   function = 1 // SHA-1
-       sha256 function = 2 // SHA-256
-       sha512 function = 3 // SHA-512
+       sha1     function = 1  // SHA-1
+       sha256   function = 2  // SHA-256
+       sha512   function = 3  // SHA-512
+       sha3_224 function = 32 // SHA3-224
+       sha3_256 function = 33 // SHA3-256
+       sha3_384 function = 34 // SHA3-384
+       sha3_512 function = 35 // SHA3-512
+       shake128 function = 36 // SHAKE-128
+       shake256 function = 37 // SHAKE-256
 
        // KLMD function codes
        ghash function = 65 // GHASH
@@ -72,7 +78,7 @@ const (
        msa8 facility = 146 // message-security-assist extension 8
 
        // vector facilities
-       ve1 facility = 135 // vector-enhancements 1
+       vxe facility = 135 // vector-enhancements 1
 
        // Note: vx and highgprs are excluded because they require
        // kernel support and so must be fetched from HWCAP.
@@ -110,26 +116,26 @@ func klmdQuery() queryResult
 
 func doinit() {
        options = []option{
-               {Name: "zarch", Feature: &S390X.HasZArch},
+               {Name: "zarch", Feature: &S390X.HasZARCH},
                {Name: "stfle", Feature: &S390X.HasSTFLE},
-               {Name: "ldisp", Feature: &S390X.HasLDisp},
+               {Name: "ldisp", Feature: &S390X.HasLDISP},
                {Name: "msa", Feature: &S390X.HasMSA},
-               {Name: "eimm", Feature: &S390X.HasEImm},
+               {Name: "eimm", Feature: &S390X.HasEIMM},
                {Name: "dfp", Feature: &S390X.HasDFP},
-               {Name: "etf3eh", Feature: &S390X.HasETF3Enhanced},
+               {Name: "etf3eh", Feature: &S390X.HasETF3EH},
                {Name: "vx", Feature: &S390X.HasVX},
-               {Name: "ve1", Feature: &S390X.HasVE1},
+               {Name: "vxe", Feature: &S390X.HasVXE},
        }
 
        aes := []function{aes128, aes192, aes256}
        facilities := stfle()
 
-       S390X.HasZArch = facilities.Has(zarch)
+       S390X.HasZARCH = facilities.Has(zarch)
        S390X.HasSTFLE = facilities.Has(stflef)
-       S390X.HasLDisp = facilities.Has(ldisp)
-       S390X.HasEImm = facilities.Has(eimm)
+       S390X.HasLDISP = facilities.Has(ldisp)
+       S390X.HasEIMM = facilities.Has(eimm)
        S390X.HasDFP = facilities.Has(dfp)
-       S390X.HasETF3Enhanced = facilities.Has(etf3eh)
+       S390X.HasETF3EH = facilities.Has(etf3eh)
        S390X.HasMSA = facilities.Has(msa)
 
        if S390X.HasMSA {
@@ -153,8 +159,13 @@ func doinit() {
                S390X.HasSHA256 = kimd.Has(sha256) && klmd.Has(sha256)
                S390X.HasSHA512 = kimd.Has(sha512) && klmd.Has(sha512)
                S390X.HasGHASH = kimd.Has(ghash) // KLMD-GHASH does not exist
+               sha3 := []function{
+                       sha3_224, sha3_256, sha3_384, sha3_512,
+                       shake128, shake256,
+               }
+               S390X.HasSHA3 = kimd.Has(sha3...) && klmd.Has(sha3...)
        }
        if S390X.HasVX {
-               S390X.HasVE1 = facilities.Has(ve1)
+               S390X.HasVXE = facilities.Has(vxe)
        }
 }