]> Cypherpunks repositories - gostls13.git/commitdiff
internal/cpu: report CPU if known on PPC64
authorPaul E. Murphy <murp@ibm.com>
Thu, 5 May 2022 15:27:24 +0000 (10:27 -0500)
committerPaul Murphy <murp@ibm.com>
Tue, 10 May 2022 20:05:43 +0000 (20:05 +0000)
The PPC64 maintainers are testing on P10 hardware, so it is helpful
to report the correct cpu, even if this information is not used
elsewhere yet.

Note, AIX will report the current CPU of the host system, so a
POWER10 will not set the IsPOWER9 flag. This is existing behavior,
and should be fixed in a separate patch.

Change-Id: Iebe23dd96ebe03c8a1c70d1ed2dc1506bad3c330
Reviewed-on: https://go-review.googlesource.com/c/go/+/404394
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/internal/cpu/cpu.go
src/internal/cpu/cpu_no_name.go
src/internal/cpu/cpu_ppc64x.go
src/internal/cpu/cpu_ppc64x_aix.go
src/internal/cpu/cpu_ppc64x_linux.go

index 30745344e1c816e5986f386c0c112ebb981f98b2..ae23b59617a4febfa023f5c6ea656e5be721d219 100644 (file)
@@ -81,12 +81,13 @@ var MIPS64X struct {
 // those as well. The minimum processor requirement is POWER8 (ISA 2.07).
 // The struct is padded to avoid false sharing.
 var PPC64 struct {
-       _        CacheLinePad
-       HasDARN  bool // Hardware random number generator (requires kernel enablement)
-       HasSCV   bool // Syscall vectored (requires kernel enablement)
-       IsPOWER8 bool // ISA v2.07 (POWER8)
-       IsPOWER9 bool // ISA v3.00 (POWER9)
-       _        CacheLinePad
+       _         CacheLinePad
+       HasDARN   bool // Hardware random number generator (requires kernel enablement)
+       HasSCV    bool // Syscall vectored (requires kernel enablement)
+       IsPOWER8  bool // ISA v2.07 (POWER8)
+       IsPOWER9  bool // ISA v3.00 (POWER9)
+       IsPOWER10 bool // ISA v3.1  (POWER10)
+       _         CacheLinePad
 }
 
 var S390X struct {
index 37de951ba6d783cd5e66b9a5f6e33496e132429e..2adfa1b70994f33a24404a81eb8dd7d09879b6da 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !386 && !amd64
+//go:build !386 && !amd64 && !ppc64 && !ppc64le
 
 package cpu
 
index 83687d6ed3438f8f933bc7b58b6b9122d761262b..c4a08fe1bd9504a00e605c119831c976ed5dc73f 100644 (file)
@@ -21,3 +21,15 @@ func doinit() {
 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 ""
+}
index d518edcf490b7e23f09eb583715d845ca85a068b..f05ed6fad8a5e9cdf9a99fd325a40892244c95c3 100644 (file)
@@ -8,13 +8,17 @@ package cpu
 
 const (
        // getsystemcfg constants
-       _SC_IMPL     = 2
-       _IMPL_POWER9 = 0x20000
+       _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
index 0fe8667843334e8627b594b81b044906a1f38114..9df82ca8a50bb9cb218ae9373c3f94d0cdf91529 100644 (file)
@@ -17,6 +17,7 @@ const (
        // ISA Level
        hwcap2_ARCH_2_07 = 0x80000000
        hwcap2_ARCH_3_00 = 0x00800000
+       hwcap2_ARCH_3_1  = 0x00040000
 
        // CPU features
        hwcap2_DARN = 0x00200000
@@ -26,6 +27,7 @@ const (
 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)
 }