aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/go/_std_1.22/src/internal/cpu
diff options
context:
space:
mode:
authormaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 12:29:46 +0300
committermaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 13:14:22 +0300
commit9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch)
treea8fb3181d5947c0d78cf402aa56e686130179049 /contrib/go/_std_1.22/src/internal/cpu
parenta44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff)
downloadydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz
publishFullContrib: true for ydb
<HIDDEN_URL> commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/go/_std_1.22/src/internal/cpu')
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_arm.go48
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_android.go11
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_freebsd.go14
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_openbsd.go28
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_other.go13
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_loong64.go13
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_mips.go10
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_mips64x.go32
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_mipsle.go10
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x.go35
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_aix.go25
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_linux.go33
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_other.go13
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_riscv64.go10
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_s390x.go205
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_s390x.s63
-rw-r--r--contrib/go/_std_1.22/src/internal/cpu/cpu_wasm.go10
17 files changed, 573 insertions, 0 deletions
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_arm.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm.go
new file mode 100644
index 0000000000..080e788112
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm.go
@@ -0,0 +1,48 @@
+// Copyright 2017 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
+
+const CacheLinePadSize = 32
+
+// arm doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
+// These are initialized by archauxv() and should not be changed after they are
+// initialized.
+var HWCap uint
+var HWCap2 uint
+var Platform string
+
+// HWCAP/HWCAP2 bits. These are exposed by Linux and FreeBSD.
+const (
+ hwcap_VFPv4 = 1 << 16
+ hwcap_IDIVA = 1 << 17
+ hwcap_LPAE = 1 << 20
+)
+
+func doinit() {
+ options = []option{
+ {Name: "vfpv4", Feature: &ARM.HasVFPv4},
+ {Name: "idiva", Feature: &ARM.HasIDIVA},
+ {Name: "v7atomics", Feature: &ARM.HasV7Atomics},
+ }
+
+ // HWCAP feature bits
+ ARM.HasVFPv4 = isSet(HWCap, hwcap_VFPv4)
+ ARM.HasIDIVA = isSet(HWCap, hwcap_IDIVA)
+ // lpae is required to make the 64-bit instructions LDRD and STRD (and variants) atomic.
+ // See ARMv7 manual section B1.6.
+ // We also need at least a v7 chip, for the DMB instruction.
+ ARM.HasV7Atomics = isSet(HWCap, hwcap_LPAE) && isV7(Platform)
+}
+
+func isSet(hwc uint, value uint) bool {
+ return hwc&value != 0
+}
+
+func isV7(s string) bool {
+ if s == "aarch64" {
+ return true
+ }
+ return s >= "v7" // will be something like v5, v7, v8, v8l
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_android.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_android.go
new file mode 100644
index 0000000000..fbdf7baca2
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_android.go
@@ -0,0 +1,11 @@
+// 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.
+
+//go:build arm64
+
+package cpu
+
+func osInit() {
+ hwcapInit("android")
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_freebsd.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_freebsd.go
new file mode 100644
index 0000000000..96ed359ca0
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_freebsd.go
@@ -0,0 +1,14 @@
+// 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.
+
+//go:build arm64
+
+package cpu
+
+func osInit() {
+ // Retrieve info from system register ID_AA64ISAR0_EL1.
+ isar0 := getisar0()
+
+ parseARM64SystemRegisters(isar0)
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_openbsd.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_openbsd.go
new file mode 100644
index 0000000000..12593098eb
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_openbsd.go
@@ -0,0 +1,28 @@
+// Copyright 2022 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.
+
+//go:build arm64
+
+package cpu
+
+const (
+ // From OpenBSD's sys/sysctl.h.
+ _CTL_MACHDEP = 7
+
+ // From OpenBSD's machine/cpu.h.
+ _CPU_ID_AA64ISAR0 = 2
+ _CPU_ID_AA64ISAR1 = 3
+)
+
+//go:noescape
+func sysctlUint64(mib []uint32) (uint64, bool)
+
+func osInit() {
+ // Get ID_AA64ISAR0 from sysctl.
+ isar0, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64ISAR0})
+ if !ok {
+ return
+ }
+ parseARM64SystemRegisters(isar0)
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_other.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_other.go
new file mode 100644
index 0000000000..44592cfced
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_arm64_other.go
@@ -0,0 +1,13 @@
+// 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.
+
+//go:build arm64 && !linux && !freebsd && !android && (!darwin || ios) && !openbsd
+
+package cpu
+
+func osInit() {
+ // Other operating systems do not support reading HWCap from auxiliary vector,
+ // reading privileged aarch64 system registers or sysctl in user space to detect
+ // CPU features at runtime.
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_loong64.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_loong64.go
new file mode 100644
index 0000000000..1c90c24fe3
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_loong64.go
@@ -0,0 +1,13 @@
+// Copyright 2022 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.
+
+//go:build loong64
+
+package cpu
+
+// CacheLinePadSize is used to prevent false sharing of cache lines.
+// We choose 64 because Loongson 3A5000 the L1 Dcache is 4-way 256-line 64-byte-per-line.
+const CacheLinePadSize = 64
+
+func doinit() {}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_mips.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_mips.go
new file mode 100644
index 0000000000..14a9c975ea
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_mips.go
@@ -0,0 +1,10 @@
+// Copyright 2017 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
+
+const CacheLinePadSize = 32
+
+func doinit() {
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_mips64x.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_mips64x.go
new file mode 100644
index 0000000000..c452ffd8b3
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_mips64x.go
@@ -0,0 +1,32 @@
+// Copyright 2019 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.
+
+//go:build mips64 || mips64le
+
+package cpu
+
+const CacheLinePadSize = 32
+
+// This is initialized by archauxv and should not be changed after it is
+// initialized.
+var HWCap uint
+
+// HWCAP bits. These are exposed by the Linux kernel 5.4.
+const (
+ // CPU features
+ hwcap_MIPS_MSA = 1 << 1
+)
+
+func doinit() {
+ options = []option{
+ {Name: "msa", Feature: &MIPS64X.HasMSA},
+ }
+
+ // HWCAP feature bits
+ MIPS64X.HasMSA = isSet(HWCap, hwcap_MIPS_MSA)
+}
+
+func isSet(hwc uint, value uint) bool {
+ return hwc&value != 0
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_mipsle.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_mipsle.go
new file mode 100644
index 0000000000..14a9c975ea
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_mipsle.go
@@ -0,0 +1,10 @@
+// Copyright 2017 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
+
+const CacheLinePadSize = 32
+
+func doinit() {
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x.go
new file mode 100644
index 0000000000..c4a08fe1bd
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x.go
@@ -0,0 +1,35 @@
+// Copyright 2017 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.
+
+//go:build ppc64 || ppc64le
+
+package cpu
+
+const CacheLinePadSize = 128
+
+func doinit() {
+ options = []option{
+ {Name: "darn", Feature: &PPC64.HasDARN},
+ {Name: "scv", Feature: &PPC64.HasSCV},
+ {Name: "power9", Feature: &PPC64.IsPOWER9},
+ }
+
+ osinit()
+}
+
+func isSet(hwc uint, value uint) bool {
+ return hwc&value != 0
+}
+
+func Name() string {
+ switch {
+ case PPC64.IsPOWER10:
+ return "POWER10"
+ case PPC64.IsPOWER9:
+ return "POWER9"
+ case PPC64.IsPOWER8:
+ return "POWER8"
+ }
+ return ""
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_aix.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_aix.go
new file mode 100644
index 0000000000..f05ed6fad8
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_aix.go
@@ -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.
+
+//go:build ppc64 || ppc64le
+
+package cpu
+
+const (
+ // getsystemcfg constants
+ _SC_IMPL = 2
+ _IMPL_POWER8 = 0x10000
+ _IMPL_POWER9 = 0x20000
+ _IMPL_POWER10 = 0x40000
+)
+
+func osinit() {
+ impl := getsystemcfg(_SC_IMPL)
+ PPC64.IsPOWER8 = isSet(impl, _IMPL_POWER8)
+ PPC64.IsPOWER9 = isSet(impl, _IMPL_POWER9)
+ PPC64.IsPOWER10 = isSet(impl, _IMPL_POWER10)
+}
+
+// getsystemcfg is defined in runtime/os2_aix.go
+func getsystemcfg(label uint) uint
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_linux.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_linux.go
new file mode 100644
index 0000000000..9df82ca8a5
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_linux.go
@@ -0,0 +1,33 @@
+// 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.
+
+//go:build ppc64 || ppc64le
+
+package cpu
+
+// ppc64 doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
+// These are initialized by archauxv and should not be changed after they are
+// initialized.
+var HWCap uint
+var HWCap2 uint
+
+// HWCAP bits. These are exposed by Linux.
+const (
+ // ISA Level
+ hwcap2_ARCH_2_07 = 0x80000000
+ hwcap2_ARCH_3_00 = 0x00800000
+ hwcap2_ARCH_3_1 = 0x00040000
+
+ // CPU features
+ hwcap2_DARN = 0x00200000
+ hwcap2_SCV = 0x00100000
+)
+
+func osinit() {
+ PPC64.IsPOWER8 = isSet(HWCap2, hwcap2_ARCH_2_07)
+ PPC64.IsPOWER9 = isSet(HWCap2, hwcap2_ARCH_3_00)
+ PPC64.IsPOWER10 = isSet(HWCap2, hwcap2_ARCH_3_1)
+ PPC64.HasDARN = isSet(HWCap2, hwcap2_DARN)
+ PPC64.HasSCV = isSet(HWCap2, hwcap2_SCV)
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_other.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_other.go
new file mode 100644
index 0000000000..d5b629dbeb
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_ppc64x_other.go
@@ -0,0 +1,13 @@
+// Copyright 2023 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.
+
+//go:build (ppc64 || ppc64le) && !aix && !linux
+
+package cpu
+
+func osinit() {
+ // Other operating systems do not support reading HWCap from auxiliary vector,
+ // reading privileged system registers or sysctl in user space to detect CPU
+ // features at runtime.
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_riscv64.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_riscv64.go
new file mode 100644
index 0000000000..2173fe8886
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_riscv64.go
@@ -0,0 +1,10 @@
+// Copyright 2019 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
+
+const CacheLinePadSize = 64
+
+func doinit() {
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_s390x.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_s390x.go
new file mode 100644
index 0000000000..45d8ed27f0
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_s390x.go
@@ -0,0 +1,205 @@
+// Copyright 2017 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
+
+const CacheLinePadSize = 256
+
+var HWCap uint
+
+// 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 function code for the named 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
+)
+
+const (
+ // KDSA function codes
+ ecdsaVerifyP256 function = 1 // NIST P256
+ ecdsaVerifyP384 function = 2 // NIST P384
+ ecdsaVerifyP521 function = 3 // NIST P521
+ ecdsaSignP256 function = 9 // NIST P256
+ ecdsaSignP384 function = 10 // NIST P384
+ ecdsaSignP521 function = 11 // NIST P521
+ eddsaVerifyEd25519 function = 32 // Curve25519
+ eddsaVerifyEd448 function = 36 // Curve448
+ eddsaSignEd25519 function = 40 // Curve25519
+ eddsaSignEd448 function = 44 // Curve448
+)
+
+// 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 (
+ // 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
+ vxe facility = 135 // vector-enhancements 1
+
+ // Note: vx requires kernel support
+ // and so must be fetched from HWCAP.
+
+ hwcap_VX = 1 << 11 // vector facility
+)
+
+// 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
+}
+
+// The following feature detection functions are defined in cpu_s390x.s.
+// They are likely to be expensive to call so the results should be cached.
+func stfle() facilityList
+func kmQuery() queryResult
+func kmcQuery() queryResult
+func kmctrQuery() queryResult
+func kmaQuery() queryResult
+func kimdQuery() queryResult
+func klmdQuery() queryResult
+func kdsaQuery() queryResult
+
+func doinit() {
+ options = []option{
+ {Name: "zarch", Feature: &S390X.HasZARCH},
+ {Name: "stfle", Feature: &S390X.HasSTFLE},
+ {Name: "ldisp", Feature: &S390X.HasLDISP},
+ {Name: "msa", Feature: &S390X.HasMSA},
+ {Name: "eimm", Feature: &S390X.HasEIMM},
+ {Name: "dfp", Feature: &S390X.HasDFP},
+ {Name: "etf3eh", Feature: &S390X.HasETF3EH},
+ {Name: "vx", Feature: &S390X.HasVX},
+ {Name: "vxe", Feature: &S390X.HasVXE},
+ {Name: "kdsa", Feature: &S390X.HasKDSA},
+ }
+
+ aes := []function{aes128, aes192, aes256}
+ facilities := stfle()
+
+ S390X.HasZARCH = facilities.Has(zarch)
+ S390X.HasSTFLE = facilities.Has(stflef)
+ S390X.HasLDISP = facilities.Has(ldisp)
+ S390X.HasEIMM = facilities.Has(eimm)
+ S390X.HasDFP = facilities.Has(dfp)
+ S390X.HasETF3EH = facilities.Has(etf3eh)
+ S390X.HasMSA = facilities.Has(msa)
+
+ if S390X.HasMSA {
+ // cipher message
+ km, kmc := kmQuery(), kmcQuery()
+ S390X.HasAES = km.Has(aes...)
+ S390X.HasAESCBC = kmc.Has(aes...)
+ 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...)
+ S390X.HasKDSA = facilities.Has(msa9) // elliptic curves
+ if S390X.HasKDSA {
+ kdsa := kdsaQuery()
+ S390X.HasECDSA = kdsa.Has(ecdsaVerifyP256, ecdsaSignP256, ecdsaVerifyP384, ecdsaSignP384, ecdsaVerifyP521, ecdsaSignP521)
+ S390X.HasEDDSA = kdsa.Has(eddsaVerifyEd25519, eddsaSignEd25519, eddsaVerifyEd448, eddsaSignEd448)
+ }
+ }
+
+ S390X.HasVX = isSet(HWCap, hwcap_VX)
+
+ if S390X.HasVX {
+ S390X.HasVXE = facilities.Has(vxe)
+ }
+}
+
+func isSet(hwc uint, value uint) bool {
+ return hwc&value != 0
+}
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_s390x.s b/contrib/go/_std_1.22/src/internal/cpu/cpu_s390x.s
new file mode 100644
index 0000000000..4ffbbde38d
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_s390x.s
@@ -0,0 +1,63 @@
+// Copyright 2018 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.
+
+#include "textflag.h"
+
+// func stfle() facilityList
+TEXT ·stfle(SB), NOSPLIT|NOFRAME, $0-32
+ MOVD $ret+0(FP), R1
+ MOVD $3, R0 // last doubleword index to store
+ XC $32, (R1), (R1) // clear 4 doublewords (32 bytes)
+ WORD $0xb2b01000 // store facility list extended (STFLE)
+ RET
+
+// func kmQuery() queryResult
+TEXT ·kmQuery(SB), NOSPLIT|NOFRAME, $0-16
+ MOVD $0, R0 // set function code to 0 (KM-Query)
+ MOVD $ret+0(FP), R1 // address of 16-byte return value
+ KM R2, R4 // cipher message (KM)
+ RET
+
+// func kmcQuery() queryResult
+TEXT ·kmcQuery(SB), NOSPLIT|NOFRAME, $0-16
+ MOVD $0, R0 // set function code to 0 (KMC-Query)
+ MOVD $ret+0(FP), R1 // address of 16-byte return value
+ KMC R2, R4 // cipher message with chaining (KMC)
+ RET
+
+// func kmctrQuery() queryResult
+TEXT ·kmctrQuery(SB), NOSPLIT|NOFRAME, $0-16
+ MOVD $0, R0 // set function code to 0 (KMCTR-Query)
+ MOVD $ret+0(FP), R1 // address of 16-byte return value
+ KMCTR R2, R4, R4 // cipher message with counter (KMCTR)
+ RET
+
+// func kmaQuery() queryResult
+TEXT ·kmaQuery(SB), NOSPLIT|NOFRAME, $0-16
+ MOVD $0, R0 // set function code to 0 (KMA-Query)
+ MOVD $ret+0(FP), R1 // address of 16-byte return value
+ KMA R2, R6, R4 // cipher message with authentication (KMA)
+ RET
+
+// func kimdQuery() queryResult
+TEXT ·kimdQuery(SB), NOSPLIT|NOFRAME, $0-16
+ MOVD $0, R0 // set function code to 0 (KIMD-Query)
+ MOVD $ret+0(FP), R1 // address of 16-byte return value
+ KIMD R2, R4 // compute intermediate message digest (KIMD)
+ RET
+
+// func klmdQuery() queryResult
+TEXT ·klmdQuery(SB), NOSPLIT|NOFRAME, $0-16
+ MOVD $0, R0 // set function code to 0 (KLMD-Query)
+ MOVD $ret+0(FP), R1 // address of 16-byte return value
+ KLMD R2, R4 // compute last message digest (KLMD)
+ RET
+
+// func kdsaQuery() queryResult
+TEXT ·kdsaQuery(SB), NOSPLIT|NOFRAME, $0-16
+ MOVD $0, R0 // set function code to 0 (KLMD-Query)
+ MOVD $ret+0(FP), R1 // address of 16-byte return value
+ KDSA R0, R4 // compute digital signature authentication
+ RET
+
diff --git a/contrib/go/_std_1.22/src/internal/cpu/cpu_wasm.go b/contrib/go/_std_1.22/src/internal/cpu/cpu_wasm.go
new file mode 100644
index 0000000000..2310ad6a48
--- /dev/null
+++ b/contrib/go/_std_1.22/src/internal/cpu/cpu_wasm.go
@@ -0,0 +1,10 @@
+// Copyright 2018 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
+
+const CacheLinePadSize = 64
+
+func doinit() {
+}