Update vendor (#1297)
This commit is contained in:
		
							
								
								
									
										60
									
								
								vendor/golang.org/x/sys/cpu/cpu.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										60
									
								
								vendor/golang.org/x/sys/cpu/cpu.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,26 +29,46 @@ type CacheLinePad struct{ _ [cacheLineSize]byte } | ||||
| // and HasAVX2 are only set if the OS supports XMM and YMM | ||||
| // registers in addition to the CPUID feature bit being set. | ||||
| var X86 struct { | ||||
| 	_            CacheLinePad | ||||
| 	HasAES       bool // AES hardware implementation (AES NI) | ||||
| 	HasADX       bool // Multi-precision add-carry instruction extensions | ||||
| 	HasAVX       bool // Advanced vector extension | ||||
| 	HasAVX2      bool // Advanced vector extension 2 | ||||
| 	HasBMI1      bool // Bit manipulation instruction set 1 | ||||
| 	HasBMI2      bool // Bit manipulation instruction set 2 | ||||
| 	HasERMS      bool // Enhanced REP for MOVSB and STOSB | ||||
| 	HasFMA       bool // Fused-multiply-add instructions | ||||
| 	HasOSXSAVE   bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers. | ||||
| 	HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM | ||||
| 	HasPOPCNT    bool // Hamming weight instruction POPCNT. | ||||
| 	HasRDRAND    bool // RDRAND instruction (on-chip random number generator) | ||||
| 	HasRDSEED    bool // RDSEED instruction (on-chip random number generator) | ||||
| 	HasSSE2      bool // Streaming SIMD extension 2 (always available on amd64) | ||||
| 	HasSSE3      bool // Streaming SIMD extension 3 | ||||
| 	HasSSSE3     bool // Supplemental streaming SIMD extension 3 | ||||
| 	HasSSE41     bool // Streaming SIMD extension 4 and 4.1 | ||||
| 	HasSSE42     bool // Streaming SIMD extension 4 and 4.2 | ||||
| 	_            CacheLinePad | ||||
| 	_                   CacheLinePad | ||||
| 	HasAES              bool // AES hardware implementation (AES NI) | ||||
| 	HasADX              bool // Multi-precision add-carry instruction extensions | ||||
| 	HasAVX              bool // Advanced vector extension | ||||
| 	HasAVX2             bool // Advanced vector extension 2 | ||||
| 	HasAVX512           bool // Advanced vector extension 512 | ||||
| 	HasAVX512F          bool // Advanced vector extension 512 Foundation Instructions | ||||
| 	HasAVX512CD         bool // Advanced vector extension 512 Conflict Detection Instructions | ||||
| 	HasAVX512ER         bool // Advanced vector extension 512 Exponential and Reciprocal Instructions | ||||
| 	HasAVX512PF         bool // Advanced vector extension 512 Prefetch Instructions Instructions | ||||
| 	HasAVX512VL         bool // Advanced vector extension 512 Vector Length Extensions | ||||
| 	HasAVX512BW         bool // Advanced vector extension 512 Byte and Word Instructions | ||||
| 	HasAVX512DQ         bool // Advanced vector extension 512 Doubleword and Quadword Instructions | ||||
| 	HasAVX512IFMA       bool // Advanced vector extension 512 Integer Fused Multiply Add | ||||
| 	HasAVX512VBMI       bool // Advanced vector extension 512 Vector Byte Manipulation Instructions | ||||
| 	HasAVX5124VNNIW     bool // Advanced vector extension 512 Vector Neural Network Instructions Word variable precision | ||||
| 	HasAVX5124FMAPS     bool // Advanced vector extension 512 Fused Multiply Accumulation Packed Single precision | ||||
| 	HasAVX512VPOPCNTDQ  bool // Advanced vector extension 512 Double and quad word population count instructions | ||||
| 	HasAVX512VPCLMULQDQ bool // Advanced vector extension 512 Vector carry-less multiply operations | ||||
| 	HasAVX512VNNI       bool // Advanced vector extension 512 Vector Neural Network Instructions | ||||
| 	HasAVX512GFNI       bool // Advanced vector extension 512 Galois field New Instructions | ||||
| 	HasAVX512VAES       bool // Advanced vector extension 512 Vector AES instructions | ||||
| 	HasAVX512VBMI2      bool // Advanced vector extension 512 Vector Byte Manipulation Instructions 2 | ||||
| 	HasAVX512BITALG     bool // Advanced vector extension 512 Bit Algorithms | ||||
| 	HasAVX512BF16       bool // Advanced vector extension 512 BFloat16 Instructions | ||||
| 	HasBMI1             bool // Bit manipulation instruction set 1 | ||||
| 	HasBMI2             bool // Bit manipulation instruction set 2 | ||||
| 	HasERMS             bool // Enhanced REP for MOVSB and STOSB | ||||
| 	HasFMA              bool // Fused-multiply-add instructions | ||||
| 	HasOSXSAVE          bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers. | ||||
| 	HasPCLMULQDQ        bool // PCLMULQDQ instruction - most often used for AES-GCM | ||||
| 	HasPOPCNT           bool // Hamming weight instruction POPCNT. | ||||
| 	HasRDRAND           bool // RDRAND instruction (on-chip random number generator) | ||||
| 	HasRDSEED           bool // RDSEED instruction (on-chip random number generator) | ||||
| 	HasSSE2             bool // Streaming SIMD extension 2 (always available on amd64) | ||||
| 	HasSSE3             bool // Streaming SIMD extension 3 | ||||
| 	HasSSSE3            bool // Supplemental streaming SIMD extension 3 | ||||
| 	HasSSE41            bool // Streaming SIMD extension 4 and 4.1 | ||||
| 	HasSSE42            bool // Streaming SIMD extension 4 and 4.2 | ||||
| 	_                   CacheLinePad | ||||
| } | ||||
|  | ||||
| // ARM64 contains the supported CPU features of the | ||||
|   | ||||
							
								
								
									
										39
									
								
								vendor/golang.org/x/sys/cpu/cpu_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								vendor/golang.org/x/sys/cpu/cpu_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -39,31 +39,34 @@ func initOptions() { | ||||
|  | ||||
| func archInit() { | ||||
| 	switch runtime.GOOS { | ||||
| 	case "android", "darwin", "netbsd": | ||||
| 		// Android and iOS don't seem to allow reading these registers. | ||||
| 		// | ||||
| 		// NetBSD: | ||||
| 		// ID_AA64ISAR0_EL1 is a privileged register and cannot be read from EL0. | ||||
| 		// It can be read via sysctl(3). Example for future implementers: | ||||
| 		// https://nxr.netbsd.org/xref/src/usr.sbin/cpuctl/arch/aarch64.c | ||||
| 		// | ||||
| 		// Fake the minimal features expected by | ||||
| 		// TestARM64minimalFeatures. | ||||
| 		ARM64.HasASIMD = true | ||||
| 		ARM64.HasFP = true | ||||
| 	case "linux": | ||||
| 	case "freebsd": | ||||
| 		readARM64Registers() | ||||
| 	case "linux", "netbsd": | ||||
| 		doinit() | ||||
| 	default: | ||||
| 		readARM64Registers() | ||||
| 		// Most platforms don't seem to allow reading these registers. | ||||
| 		// | ||||
| 		// OpenBSD: | ||||
| 		// See https://golang.org/issue/31746 | ||||
| 		setMinimalFeatures() | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // setMinimalFeatures fakes the minimal ARM64 features expected by | ||||
| // TestARM64minimalFeatures. | ||||
| func setMinimalFeatures() { | ||||
| 	ARM64.HasASIMD = true | ||||
| 	ARM64.HasFP = true | ||||
| } | ||||
|  | ||||
| func readARM64Registers() { | ||||
| 	Initialized = true | ||||
|  | ||||
| 	// ID_AA64ISAR0_EL1 | ||||
| 	isar0 := getisar0() | ||||
| 	parseARM64SystemRegisters(getisar0(), getisar1(), getpfr0()) | ||||
| } | ||||
|  | ||||
| func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { | ||||
| 	// ID_AA64ISAR0_EL1 | ||||
| 	switch extractBits(isar0, 4, 7) { | ||||
| 	case 1: | ||||
| 		ARM64.HasAES = true | ||||
| @@ -121,8 +124,6 @@ func readARM64Registers() { | ||||
| 	} | ||||
|  | ||||
| 	// ID_AA64ISAR1_EL1 | ||||
| 	isar1 := getisar1() | ||||
|  | ||||
| 	switch extractBits(isar1, 0, 3) { | ||||
| 	case 1: | ||||
| 		ARM64.HasDCPOP = true | ||||
| @@ -144,8 +145,6 @@ func readARM64Registers() { | ||||
| 	} | ||||
|  | ||||
| 	// ID_AA64PFR0_EL1 | ||||
| 	pfr0 := getpfr0() | ||||
|  | ||||
| 	switch extractBits(pfr0, 16, 19) { | ||||
| 	case 0: | ||||
| 		ARM64.HasFP = true | ||||
|   | ||||
							
								
								
									
										121
									
								
								vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										121
									
								
								vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -17,86 +17,7 @@ const ( | ||||
| 	hwcap_VXE    = 8192 | ||||
| ) | ||||
|  | ||||
| // bitIsSet reports whether the bit at index is set. The bit index | ||||
| // is in big endian order, so bit index 0 is the leftmost bit. | ||||
| func bitIsSet(bits []uint64, index uint) bool { | ||||
| 	return bits[index/64]&((1<<63)>>(index%64)) != 0 | ||||
| } | ||||
|  | ||||
| // function is the code for the named cryptographic function. | ||||
| type function uint8 | ||||
|  | ||||
| const ( | ||||
| 	// KM{,A,C,CTR} function codes | ||||
| 	aes128 function = 18 // AES-128 | ||||
| 	aes192 function = 19 // AES-192 | ||||
| 	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 | ||||
| 	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 | ||||
| ) | ||||
|  | ||||
| // queryResult contains the result of a Query function | ||||
| // call. Bits are numbered in big endian order so the | ||||
| // leftmost bit (the MSB) is at index 0. | ||||
| type queryResult struct { | ||||
| 	bits [2]uint64 | ||||
| } | ||||
|  | ||||
| // Has reports whether the given functions are present. | ||||
| func (q *queryResult) Has(fns ...function) bool { | ||||
| 	if len(fns) == 0 { | ||||
| 		panic("no function codes provided") | ||||
| 	} | ||||
| 	for _, f := range fns { | ||||
| 		if !bitIsSet(q.bits[:], uint(f)) { | ||||
| 			return false | ||||
| 		} | ||||
| 	} | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // facility is a bit index for the named facility. | ||||
| type facility uint8 | ||||
|  | ||||
| const ( | ||||
| 	// cryptography facilities | ||||
| 	msa4 facility = 77  // message-security-assist extension 4 | ||||
| 	msa8 facility = 146 // message-security-assist extension 8 | ||||
| ) | ||||
|  | ||||
| // facilityList contains the result of an STFLE call. | ||||
| // Bits are numbered in big endian order so the | ||||
| // leftmost bit (the MSB) is at index 0. | ||||
| type facilityList struct { | ||||
| 	bits [4]uint64 | ||||
| } | ||||
|  | ||||
| // Has reports whether the given facilities are present. | ||||
| func (s *facilityList) Has(fs ...facility) bool { | ||||
| 	if len(fs) == 0 { | ||||
| 		panic("no facility bits provided") | ||||
| 	} | ||||
| 	for _, f := range fs { | ||||
| 		if !bitIsSet(s.bits[:], uint(f)) { | ||||
| 			return false | ||||
| 		} | ||||
| 	} | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| func doinit() { | ||||
| func initS390Xbase() { | ||||
| 	// test HWCAP bit vector | ||||
| 	has := func(featureMask uint) bool { | ||||
| 		return hwCap&featureMask == featureMask | ||||
| @@ -116,44 +37,4 @@ func doinit() { | ||||
| 	if S390X.HasVX { | ||||
| 		S390X.HasVXE = has(hwcap_VXE) | ||||
| 	} | ||||
|  | ||||
| 	// We need implementations of stfle, km and so on | ||||
| 	// to detect cryptographic features. | ||||
| 	if !haveAsmFunctions() { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	// optional cryptographic functions | ||||
| 	if S390X.HasMSA { | ||||
| 		aes := []function{aes128, aes192, aes256} | ||||
|  | ||||
| 		// cipher message | ||||
| 		km, kmc := kmQuery(), kmcQuery() | ||||
| 		S390X.HasAES = km.Has(aes...) | ||||
| 		S390X.HasAESCBC = kmc.Has(aes...) | ||||
| 		if S390X.HasSTFLE { | ||||
| 			facilities := stfle() | ||||
| 			if facilities.Has(msa4) { | ||||
| 				kmctr := kmctrQuery() | ||||
| 				S390X.HasAESCTR = kmctr.Has(aes...) | ||||
| 			} | ||||
| 			if facilities.Has(msa8) { | ||||
| 				kma := kmaQuery() | ||||
| 				S390X.HasAESGCM = kma.Has(aes...) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// compute message digest | ||||
| 		kimd := kimdQuery() // intermediate (no padding) | ||||
| 		klmd := klmdQuery() // last (padding) | ||||
| 		S390X.HasSHA1 = kimd.Has(sha1) && klmd.Has(sha1) | ||||
| 		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...) | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										173
									
								
								vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										173
									
								
								vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,173 @@ | ||||
| // Copyright 2020 The Go Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package cpu | ||||
|  | ||||
| import ( | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | ||||
| // Minimal copy of functionality from x/sys/unix so the cpu package can call | ||||
| // sysctl without depending on x/sys/unix. | ||||
|  | ||||
| const ( | ||||
| 	_CTL_QUERY = -2 | ||||
|  | ||||
| 	_SYSCTL_VERS_1 = 0x1000000 | ||||
| ) | ||||
|  | ||||
| var _zero uintptr | ||||
|  | ||||
| func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { | ||||
| 	var _p0 unsafe.Pointer | ||||
| 	if len(mib) > 0 { | ||||
| 		_p0 = unsafe.Pointer(&mib[0]) | ||||
| 	} else { | ||||
| 		_p0 = unsafe.Pointer(&_zero) | ||||
| 	} | ||||
| 	_, _, errno := syscall.Syscall6( | ||||
| 		syscall.SYS___SYSCTL, | ||||
| 		uintptr(_p0), | ||||
| 		uintptr(len(mib)), | ||||
| 		uintptr(unsafe.Pointer(old)), | ||||
| 		uintptr(unsafe.Pointer(oldlen)), | ||||
| 		uintptr(unsafe.Pointer(new)), | ||||
| 		uintptr(newlen)) | ||||
| 	if errno != 0 { | ||||
| 		return errno | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type sysctlNode struct { | ||||
| 	Flags          uint32 | ||||
| 	Num            int32 | ||||
| 	Name           [32]int8 | ||||
| 	Ver            uint32 | ||||
| 	__rsvd         uint32 | ||||
| 	Un             [16]byte | ||||
| 	_sysctl_size   [8]byte | ||||
| 	_sysctl_func   [8]byte | ||||
| 	_sysctl_parent [8]byte | ||||
| 	_sysctl_desc   [8]byte | ||||
| } | ||||
|  | ||||
| func sysctlNodes(mib []int32) ([]sysctlNode, error) { | ||||
| 	var olen uintptr | ||||
|  | ||||
| 	// Get a list of all sysctl nodes below the given MIB by performing | ||||
| 	// a sysctl for the given MIB with CTL_QUERY appended. | ||||
| 	mib = append(mib, _CTL_QUERY) | ||||
| 	qnode := sysctlNode{Flags: _SYSCTL_VERS_1} | ||||
| 	qp := (*byte)(unsafe.Pointer(&qnode)) | ||||
| 	sz := unsafe.Sizeof(qnode) | ||||
| 	if err := sysctl(mib, nil, &olen, qp, sz); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	// Now that we know the size, get the actual nodes. | ||||
| 	nodes := make([]sysctlNode, olen/sz) | ||||
| 	np := (*byte)(unsafe.Pointer(&nodes[0])) | ||||
| 	if err := sysctl(mib, np, &olen, qp, sz); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func nametomib(name string) ([]int32, error) { | ||||
| 	// Split name into components. | ||||
| 	var parts []string | ||||
| 	last := 0 | ||||
| 	for i := 0; i < len(name); i++ { | ||||
| 		if name[i] == '.' { | ||||
| 			parts = append(parts, name[last:i]) | ||||
| 			last = i + 1 | ||||
| 		} | ||||
| 	} | ||||
| 	parts = append(parts, name[last:]) | ||||
|  | ||||
| 	mib := []int32{} | ||||
| 	// Discover the nodes and construct the MIB OID. | ||||
| 	for partno, part := range parts { | ||||
| 		nodes, err := sysctlNodes(mib) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		for _, node := range nodes { | ||||
| 			n := make([]byte, 0) | ||||
| 			for i := range node.Name { | ||||
| 				if node.Name[i] != 0 { | ||||
| 					n = append(n, byte(node.Name[i])) | ||||
| 				} | ||||
| 			} | ||||
| 			if string(n) == part { | ||||
| 				mib = append(mib, int32(node.Num)) | ||||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 		if len(mib) != partno+1 { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return mib, nil | ||||
| } | ||||
|  | ||||
| // aarch64SysctlCPUID is struct aarch64_sysctl_cpu_id from NetBSD's <aarch64/armreg.h> | ||||
| type aarch64SysctlCPUID struct { | ||||
| 	midr      uint64 /* Main ID Register */ | ||||
| 	revidr    uint64 /* Revision ID Register */ | ||||
| 	mpidr     uint64 /* Multiprocessor Affinity Register */ | ||||
| 	aa64dfr0  uint64 /* A64 Debug Feature Register 0 */ | ||||
| 	aa64dfr1  uint64 /* A64 Debug Feature Register 1 */ | ||||
| 	aa64isar0 uint64 /* A64 Instruction Set Attribute Register 0 */ | ||||
| 	aa64isar1 uint64 /* A64 Instruction Set Attribute Register 1 */ | ||||
| 	aa64mmfr0 uint64 /* A64 Memory Model Feature Register 0 */ | ||||
| 	aa64mmfr1 uint64 /* A64 Memory Model Feature Register 1 */ | ||||
| 	aa64mmfr2 uint64 /* A64 Memory Model Feature Register 2 */ | ||||
| 	aa64pfr0  uint64 /* A64 Processor Feature Register 0 */ | ||||
| 	aa64pfr1  uint64 /* A64 Processor Feature Register 1 */ | ||||
| 	aa64zfr0  uint64 /* A64 SVE Feature ID Register 0 */ | ||||
| 	mvfr0     uint32 /* Media and VFP Feature Register 0 */ | ||||
| 	mvfr1     uint32 /* Media and VFP Feature Register 1 */ | ||||
| 	mvfr2     uint32 /* Media and VFP Feature Register 2 */ | ||||
| 	pad       uint32 | ||||
| 	clidr     uint64 /* Cache Level ID Register */ | ||||
| 	ctr       uint64 /* Cache Type Register */ | ||||
| } | ||||
|  | ||||
| func sysctlCPUID(name string) (*aarch64SysctlCPUID, error) { | ||||
| 	mib, err := nametomib(name) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	out := aarch64SysctlCPUID{} | ||||
| 	n := unsafe.Sizeof(out) | ||||
| 	_, _, errno := syscall.Syscall6( | ||||
| 		syscall.SYS___SYSCTL, | ||||
| 		uintptr(unsafe.Pointer(&mib[0])), | ||||
| 		uintptr(len(mib)), | ||||
| 		uintptr(unsafe.Pointer(&out)), | ||||
| 		uintptr(unsafe.Pointer(&n)), | ||||
| 		uintptr(0), | ||||
| 		uintptr(0)) | ||||
| 	if errno != 0 { | ||||
| 		return nil, errno | ||||
| 	} | ||||
| 	return &out, nil | ||||
| } | ||||
|  | ||||
| func doinit() { | ||||
| 	cpuid, err := sysctlCPUID("machdep.cpu0.cpu_id") | ||||
| 	if err != nil { | ||||
| 		setMinimalFeatures() | ||||
| 		return | ||||
| 	} | ||||
| 	parseARM64SystemRegisters(cpuid.aa64isar0, cpuid.aa64isar1, cpuid.aa64pfr0) | ||||
|  | ||||
| 	Initialized = true | ||||
| } | ||||
							
								
								
									
										3
									
								
								vendor/golang.org/x/sys/cpu/cpu_other_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/golang.org/x/sys/cpu/cpu_other_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -2,7 +2,8 @@ | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| // +build !linux,arm64 | ||||
| // +build !linux,!netbsd | ||||
| // +build arm64 | ||||
|  | ||||
| package cpu | ||||
|  | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| // Copyright 2020 The Go Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| // +build !linux | ||||
| // +build mips64 mips64le | ||||
|  | ||||
| package cpu | ||||
|  | ||||
| func archInit() { | ||||
| 	Initialized = true | ||||
| } | ||||
							
								
								
									
										150
									
								
								vendor/golang.org/x/sys/cpu/cpu_s390x.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										150
									
								
								vendor/golang.org/x/sys/cpu/cpu_s390x.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -8,10 +8,10 @@ const cacheLineSize = 256 | ||||
|  | ||||
| func initOptions() { | ||||
| 	options = []option{ | ||||
| 		{Name: "zarch", Feature: &S390X.HasZARCH}, | ||||
| 		{Name: "stfle", Feature: &S390X.HasSTFLE}, | ||||
| 		{Name: "ldisp", Feature: &S390X.HasLDISP}, | ||||
| 		{Name: "eimm", Feature: &S390X.HasEIMM}, | ||||
| 		{Name: "zarch", Feature: &S390X.HasZARCH, Required: true}, | ||||
| 		{Name: "stfle", Feature: &S390X.HasSTFLE, Required: true}, | ||||
| 		{Name: "ldisp", Feature: &S390X.HasLDISP, Required: true}, | ||||
| 		{Name: "eimm", Feature: &S390X.HasEIMM, Required: true}, | ||||
| 		{Name: "dfp", Feature: &S390X.HasDFP}, | ||||
| 		{Name: "etf3eh", Feature: &S390X.HasETF3EH}, | ||||
| 		{Name: "msa", Feature: &S390X.HasMSA}, | ||||
| @@ -28,3 +28,145 @@ func initOptions() { | ||||
| 		{Name: "vxe", Feature: &S390X.HasVXE}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // bitIsSet reports whether the bit at index is set. The bit index | ||||
| // is in big endian order, so bit index 0 is the leftmost bit. | ||||
| func bitIsSet(bits []uint64, index uint) bool { | ||||
| 	return bits[index/64]&((1<<63)>>(index%64)) != 0 | ||||
| } | ||||
|  | ||||
| // facility is a bit index for the named facility. | ||||
| type facility uint8 | ||||
|  | ||||
| const ( | ||||
| 	// mandatory facilities | ||||
| 	zarch  facility = 1  // z architecture mode is active | ||||
| 	stflef facility = 7  // store-facility-list-extended | ||||
| 	ldisp  facility = 18 // long-displacement | ||||
| 	eimm   facility = 21 // extended-immediate | ||||
|  | ||||
| 	// miscellaneous facilities | ||||
| 	dfp    facility = 42 // decimal-floating-point | ||||
| 	etf3eh facility = 30 // extended-translation 3 enhancement | ||||
|  | ||||
| 	// cryptography facilities | ||||
| 	msa  facility = 17  // message-security-assist | ||||
| 	msa3 facility = 76  // message-security-assist extension 3 | ||||
| 	msa4 facility = 77  // message-security-assist extension 4 | ||||
| 	msa5 facility = 57  // message-security-assist extension 5 | ||||
| 	msa8 facility = 146 // message-security-assist extension 8 | ||||
| 	msa9 facility = 155 // message-security-assist extension 9 | ||||
|  | ||||
| 	// vector facilities | ||||
| 	vx   facility = 129 // vector facility | ||||
| 	vxe  facility = 135 // vector-enhancements 1 | ||||
| 	vxe2 facility = 148 // vector-enhancements 2 | ||||
| ) | ||||
|  | ||||
| // facilityList contains the result of an STFLE call. | ||||
| // Bits are numbered in big endian order so the | ||||
| // leftmost bit (the MSB) is at index 0. | ||||
| type facilityList struct { | ||||
| 	bits [4]uint64 | ||||
| } | ||||
|  | ||||
| // Has reports whether the given facilities are present. | ||||
| func (s *facilityList) Has(fs ...facility) bool { | ||||
| 	if len(fs) == 0 { | ||||
| 		panic("no facility bits provided") | ||||
| 	} | ||||
| 	for _, f := range fs { | ||||
| 		if !bitIsSet(s.bits[:], uint(f)) { | ||||
| 			return false | ||||
| 		} | ||||
| 	} | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // function is the code for the named cryptographic function. | ||||
| type function uint8 | ||||
|  | ||||
| const ( | ||||
| 	// KM{,A,C,CTR} function codes | ||||
| 	aes128 function = 18 // AES-128 | ||||
| 	aes192 function = 19 // AES-192 | ||||
| 	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 | ||||
| 	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 | ||||
| ) | ||||
|  | ||||
| // queryResult contains the result of a Query function | ||||
| // call. Bits are numbered in big endian order so the | ||||
| // leftmost bit (the MSB) is at index 0. | ||||
| type queryResult struct { | ||||
| 	bits [2]uint64 | ||||
| } | ||||
|  | ||||
| // Has reports whether the given functions are present. | ||||
| func (q *queryResult) Has(fns ...function) bool { | ||||
| 	if len(fns) == 0 { | ||||
| 		panic("no function codes provided") | ||||
| 	} | ||||
| 	for _, f := range fns { | ||||
| 		if !bitIsSet(q.bits[:], uint(f)) { | ||||
| 			return false | ||||
| 		} | ||||
| 	} | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| func doinit() { | ||||
| 	initS390Xbase() | ||||
|  | ||||
| 	// We need implementations of stfle, km and so on | ||||
| 	// to detect cryptographic features. | ||||
| 	if !haveAsmFunctions() { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	// optional cryptographic functions | ||||
| 	if S390X.HasMSA { | ||||
| 		aes := []function{aes128, aes192, aes256} | ||||
|  | ||||
| 		// cipher message | ||||
| 		km, kmc := kmQuery(), kmcQuery() | ||||
| 		S390X.HasAES = km.Has(aes...) | ||||
| 		S390X.HasAESCBC = kmc.Has(aes...) | ||||
| 		if S390X.HasSTFLE { | ||||
| 			facilities := stfle() | ||||
| 			if facilities.Has(msa4) { | ||||
| 				kmctr := kmctrQuery() | ||||
| 				S390X.HasAESCTR = kmctr.Has(aes...) | ||||
| 			} | ||||
| 			if facilities.Has(msa8) { | ||||
| 				kma := kmaQuery() | ||||
| 				S390X.HasAESGCM = kma.Has(aes...) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// compute message digest | ||||
| 		kimd := kimdQuery() // intermediate (no padding) | ||||
| 		klmd := klmdQuery() // last (padding) | ||||
| 		S390X.HasSHA1 = kimd.Has(sha1) && klmd.Has(sha1) | ||||
| 		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...) | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										51
									
								
								vendor/golang.org/x/sys/cpu/cpu_x86.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								vendor/golang.org/x/sys/cpu/cpu_x86.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -16,6 +16,26 @@ func initOptions() { | ||||
| 		{Name: "aes", Feature: &X86.HasAES}, | ||||
| 		{Name: "avx", Feature: &X86.HasAVX}, | ||||
| 		{Name: "avx2", Feature: &X86.HasAVX2}, | ||||
| 		{Name: "avx512", Feature: &X86.HasAVX512}, | ||||
| 		{Name: "avx512f", Feature: &X86.HasAVX512F}, | ||||
| 		{Name: "avx512cd", Feature: &X86.HasAVX512CD}, | ||||
| 		{Name: "avx512er", Feature: &X86.HasAVX512ER}, | ||||
| 		{Name: "avx512pf", Feature: &X86.HasAVX512PF}, | ||||
| 		{Name: "avx512vl", Feature: &X86.HasAVX512VL}, | ||||
| 		{Name: "avx512bw", Feature: &X86.HasAVX512BW}, | ||||
| 		{Name: "avx512dq", Feature: &X86.HasAVX512DQ}, | ||||
| 		{Name: "avx512ifma", Feature: &X86.HasAVX512IFMA}, | ||||
| 		{Name: "avx512vbmi", Feature: &X86.HasAVX512VBMI}, | ||||
| 		{Name: "avx512vnniw", Feature: &X86.HasAVX5124VNNIW}, | ||||
| 		{Name: "avx5124fmaps", Feature: &X86.HasAVX5124FMAPS}, | ||||
| 		{Name: "avx512vpopcntdq", Feature: &X86.HasAVX512VPOPCNTDQ}, | ||||
| 		{Name: "avx512vpclmulqdq", Feature: &X86.HasAVX512VPCLMULQDQ}, | ||||
| 		{Name: "avx512vnni", Feature: &X86.HasAVX512VNNI}, | ||||
| 		{Name: "avx512gfni", Feature: &X86.HasAVX512GFNI}, | ||||
| 		{Name: "avx512vaes", Feature: &X86.HasAVX512VAES}, | ||||
| 		{Name: "avx512vbmi2", Feature: &X86.HasAVX512VBMI2}, | ||||
| 		{Name: "avx512bitalg", Feature: &X86.HasAVX512BITALG}, | ||||
| 		{Name: "avx512bf16", Feature: &X86.HasAVX512BF16}, | ||||
| 		{Name: "bmi1", Feature: &X86.HasBMI1}, | ||||
| 		{Name: "bmi2", Feature: &X86.HasBMI2}, | ||||
| 		{Name: "erms", Feature: &X86.HasERMS}, | ||||
| @@ -59,12 +79,15 @@ func archInit() { | ||||
| 	X86.HasOSXSAVE = isSet(27, ecx1) | ||||
| 	X86.HasRDRAND = isSet(30, ecx1) | ||||
|  | ||||
| 	osSupportsAVX := false | ||||
| 	var osSupportsAVX, osSupportsAVX512 bool | ||||
| 	// For XGETBV, OSXSAVE bit is required and sufficient. | ||||
| 	if X86.HasOSXSAVE { | ||||
| 		eax, _ := xgetbv() | ||||
| 		// Check if XMM and YMM registers have OS support. | ||||
| 		osSupportsAVX = isSet(1, eax) && isSet(2, eax) | ||||
|  | ||||
| 		// Check if OPMASK and ZMM registers have OS support. | ||||
| 		osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax) | ||||
| 	} | ||||
|  | ||||
| 	X86.HasAVX = isSet(28, ecx1) && osSupportsAVX | ||||
| @@ -73,7 +96,7 @@ func archInit() { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	_, ebx7, _, _ := cpuid(7, 0) | ||||
| 	_, ebx7, ecx7, edx7 := cpuid(7, 0) | ||||
| 	X86.HasBMI1 = isSet(3, ebx7) | ||||
| 	X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX | ||||
| 	X86.HasBMI2 = isSet(8, ebx7) | ||||
| @@ -81,6 +104,30 @@ func archInit() { | ||||
| 	X86.HasRDSEED = isSet(18, ebx7) | ||||
| 	X86.HasADX = isSet(19, ebx7) | ||||
|  | ||||
| 	X86.HasAVX512 = isSet(16, ebx7) && osSupportsAVX512 // Because avx-512 foundation is the core required extension | ||||
| 	if X86.HasAVX512 { | ||||
| 		X86.HasAVX512F = true | ||||
| 		X86.HasAVX512CD = isSet(28, ebx7) | ||||
| 		X86.HasAVX512ER = isSet(27, ebx7) | ||||
| 		X86.HasAVX512PF = isSet(26, ebx7) | ||||
| 		X86.HasAVX512VL = isSet(31, ebx7) | ||||
| 		X86.HasAVX512BW = isSet(30, ebx7) | ||||
| 		X86.HasAVX512DQ = isSet(17, ebx7) | ||||
| 		X86.HasAVX512IFMA = isSet(21, ebx7) | ||||
| 		X86.HasAVX512VBMI = isSet(1, ecx7) | ||||
| 		X86.HasAVX5124VNNIW = isSet(2, edx7) | ||||
| 		X86.HasAVX5124FMAPS = isSet(3, edx7) | ||||
| 		X86.HasAVX512VPOPCNTDQ = isSet(14, ecx7) | ||||
| 		X86.HasAVX512VPCLMULQDQ = isSet(10, ecx7) | ||||
| 		X86.HasAVX512VNNI = isSet(11, ecx7) | ||||
| 		X86.HasAVX512GFNI = isSet(8, ecx7) | ||||
| 		X86.HasAVX512VAES = isSet(9, ecx7) | ||||
| 		X86.HasAVX512VBMI2 = isSet(6, ecx7) | ||||
| 		X86.HasAVX512BITALG = isSet(12, ecx7) | ||||
|  | ||||
| 		eax71, _, _, _ := cpuid(7, 1) | ||||
| 		X86.HasAVX512BF16 = isSet(5, eax71) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func isSet(bitpos uint, value uint32) bool { | ||||
|   | ||||
							
								
								
									
										10
									
								
								vendor/golang.org/x/sys/cpu/cpu_zos.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								vendor/golang.org/x/sys/cpu/cpu_zos.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| // Copyright 2020 The Go Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package cpu | ||||
|  | ||||
| func archInit() { | ||||
| 	doinit() | ||||
| 	Initialized = true | ||||
| } | ||||
							
								
								
									
										25
									
								
								vendor/golang.org/x/sys/cpu/cpu_zos_s390x.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								vendor/golang.org/x/sys/cpu/cpu_zos_s390x.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| // Copyright 2020 The Go Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package cpu | ||||
|  | ||||
| func initS390Xbase() { | ||||
| 	// get the facilities list | ||||
| 	facilities := stfle() | ||||
|  | ||||
| 	// mandatory | ||||
| 	S390X.HasZARCH = facilities.Has(zarch) | ||||
| 	S390X.HasSTFLE = facilities.Has(stflef) | ||||
| 	S390X.HasLDISP = facilities.Has(ldisp) | ||||
| 	S390X.HasEIMM = facilities.Has(eimm) | ||||
|  | ||||
| 	// optional | ||||
| 	S390X.HasETF3EH = facilities.Has(etf3eh) | ||||
| 	S390X.HasDFP = facilities.Has(dfp) | ||||
| 	S390X.HasMSA = facilities.Has(msa) | ||||
| 	S390X.HasVX = facilities.Has(vx) | ||||
| 	if S390X.HasVX { | ||||
| 		S390X.HasVXE = facilities.Has(vxe) | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Wim
					Wim