Commit 1f17d610 authored by Michael Munday's avatar Michael Munday

internal/cpu: change s390x API to match x/sys/cpu

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/164437Reviewed-by: default avatarMartin Möhrmann <moehrmann@google.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 336ae0d2
...@@ -15,7 +15,7 @@ import ( ...@@ -15,7 +15,7 @@ import (
const ( const (
offsetS390xHasVX = unsafe.Offsetof(cpu.S390X.HasVX) offsetS390xHasVX = unsafe.Offsetof(cpu.S390X.HasVX)
offsetS390xHasVE1 = unsafe.Offsetof(cpu.S390X.HasVE1) offsetS390xHasVE1 = unsafe.Offsetof(cpu.S390X.HasVXE)
) )
type p256CurveFast struct { type p256CurveFast struct {
......
...@@ -109,25 +109,26 @@ type arm64 struct { ...@@ -109,25 +109,26 @@ type arm64 struct {
var S390X s390x var S390X s390x
type s390x struct { type s390x struct {
_ CacheLinePad _ CacheLinePad
HasZArch bool // z architecture mode is active [mandatory] HasZARCH bool // z architecture mode is active [mandatory]
HasSTFLE bool // store facility list extended [mandatory] HasSTFLE bool // store facility list extended [mandatory]
HasLDisp bool // long (20-bit) displacements [mandatory] HasLDISP bool // long (20-bit) displacements [mandatory]
HasEImm bool // 32-bit immediates [mandatory] HasEIMM bool // 32-bit immediates [mandatory]
HasDFP bool // decimal floating point HasDFP bool // decimal floating point
HasETF3Enhanced bool // ETF-3 enhanced HasETF3EH bool // ETF-3 enhanced
HasMSA bool // message security assist (CPACF) HasMSA bool // message security assist (CPACF)
HasAES bool // KM-AES{128,192,256} functions HasAES bool // KM-AES{128,192,256} functions
HasAESCBC bool // KMC-AES{128,192,256} functions HasAESCBC bool // KMC-AES{128,192,256} functions
HasAESCTR bool // KMCTR-AES{128,192,256} functions HasAESCTR bool // KMCTR-AES{128,192,256} functions
HasAESGCM bool // KMA-GCM-AES{128,192,256} functions HasAESGCM bool // KMA-GCM-AES{128,192,256} functions
HasGHASH bool // KIMD-GHASH function HasGHASH bool // KIMD-GHASH function
HasSHA1 bool // K{I,L}MD-SHA-1 functions HasSHA1 bool // K{I,L}MD-SHA-1 functions
HasSHA256 bool // K{I,L}MD-SHA-256 functions HasSHA256 bool // K{I,L}MD-SHA-256 functions
HasSHA512 bool // K{I,L}MD-SHA-512 functions HasSHA512 bool // K{I,L}MD-SHA-512 functions
HasVX bool // vector facility. Note: the runtime sets this when it processes auxv records. HasSHA3 bool // K{I,L}MD-SHA3-{224,256,384,512} and K{I,L}MD-SHAKE-{128,256} functions
HasVE1 bool // vector-enhancement 1 HasVX bool // vector facility. Note: the runtime sets this when it processes auxv records.
_ CacheLinePad HasVXE bool // vector-enhancements facility 1
_ CacheLinePad
} }
// Initialize examines the processor and sets the relevant variables above. // Initialize examines the processor and sets the relevant variables above.
......
...@@ -22,9 +22,15 @@ const ( ...@@ -22,9 +22,15 @@ const (
aes256 function = 20 // AES-256 aes256 function = 20 // AES-256
// K{I,L}MD function codes // K{I,L}MD function codes
sha1 function = 1 // SHA-1 sha1 function = 1 // SHA-1
sha256 function = 2 // SHA-256 sha256 function = 2 // SHA-256
sha512 function = 3 // SHA-512 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 // KLMD function codes
ghash function = 65 // GHASH ghash function = 65 // GHASH
...@@ -72,7 +78,7 @@ const ( ...@@ -72,7 +78,7 @@ const (
msa8 facility = 146 // message-security-assist extension 8 msa8 facility = 146 // message-security-assist extension 8
// vector facilities // vector facilities
ve1 facility = 135 // vector-enhancements 1 vxe facility = 135 // vector-enhancements 1
// Note: vx and highgprs are excluded because they require // Note: vx and highgprs are excluded because they require
// kernel support and so must be fetched from HWCAP. // kernel support and so must be fetched from HWCAP.
...@@ -110,26 +116,26 @@ func klmdQuery() queryResult ...@@ -110,26 +116,26 @@ func klmdQuery() queryResult
func doinit() { func doinit() {
options = []option{ options = []option{
{Name: "zarch", Feature: &S390X.HasZArch}, {Name: "zarch", Feature: &S390X.HasZARCH},
{Name: "stfle", Feature: &S390X.HasSTFLE}, {Name: "stfle", Feature: &S390X.HasSTFLE},
{Name: "ldisp", Feature: &S390X.HasLDisp}, {Name: "ldisp", Feature: &S390X.HasLDISP},
{Name: "msa", Feature: &S390X.HasMSA}, {Name: "msa", Feature: &S390X.HasMSA},
{Name: "eimm", Feature: &S390X.HasEImm}, {Name: "eimm", Feature: &S390X.HasEIMM},
{Name: "dfp", Feature: &S390X.HasDFP}, {Name: "dfp", Feature: &S390X.HasDFP},
{Name: "etf3eh", Feature: &S390X.HasETF3Enhanced}, {Name: "etf3eh", Feature: &S390X.HasETF3EH},
{Name: "vx", Feature: &S390X.HasVX}, {Name: "vx", Feature: &S390X.HasVX},
{Name: "ve1", Feature: &S390X.HasVE1}, {Name: "vxe", Feature: &S390X.HasVXE},
} }
aes := []function{aes128, aes192, aes256} aes := []function{aes128, aes192, aes256}
facilities := stfle() facilities := stfle()
S390X.HasZArch = facilities.Has(zarch) S390X.HasZARCH = facilities.Has(zarch)
S390X.HasSTFLE = facilities.Has(stflef) S390X.HasSTFLE = facilities.Has(stflef)
S390X.HasLDisp = facilities.Has(ldisp) S390X.HasLDISP = facilities.Has(ldisp)
S390X.HasEImm = facilities.Has(eimm) S390X.HasEIMM = facilities.Has(eimm)
S390X.HasDFP = facilities.Has(dfp) S390X.HasDFP = facilities.Has(dfp)
S390X.HasETF3Enhanced = facilities.Has(etf3eh) S390X.HasETF3EH = facilities.Has(etf3eh)
S390X.HasMSA = facilities.Has(msa) S390X.HasMSA = facilities.Has(msa)
if S390X.HasMSA { if S390X.HasMSA {
...@@ -153,8 +159,13 @@ func doinit() { ...@@ -153,8 +159,13 @@ func doinit() {
S390X.HasSHA256 = kimd.Has(sha256) && klmd.Has(sha256) S390X.HasSHA256 = kimd.Has(sha256) && klmd.Has(sha256)
S390X.HasSHA512 = kimd.Has(sha512) && klmd.Has(sha512) S390X.HasSHA512 = kimd.Has(sha512) && klmd.Has(sha512)
S390X.HasGHASH = kimd.Has(ghash) // KLMD-GHASH does not exist 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 { if S390X.HasVX {
S390X.HasVE1 = facilities.Has(ve1) S390X.HasVXE = facilities.Has(vxe)
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment