-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: Handle auxv data for ppc64 and ppc64le
This commit saves the values of AT_HWCAP and AT_HWCAP2 from the auxiliary vector, so they can be used later for runtime checking the ISA level and hardware capabilities to enable some instructions. It also defines a few hwcap/hwcap2 masks that will be commonly used for such runtime checks, and also provides a function for these verifications. These checks will be used more often as new POWER8/POWER9 optimizations are added to the ppc64x runtime, so they do not break compatibility with older processors.
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2016 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 runtime | ||
|
||
const ( | ||
_AT_HWCAP = 16 | ||
_AT_HWCAP2 = 26 | ||
|
||
// Golang currently requires POWER5 as a minimum for ppc64, so we need | ||
// to check for ISA 2.03 and beyond. | ||
// Since we support only POWER server processors, we will assume that | ||
// each processor generation implements the full ISA — i.e. POWER7 | ||
// implies VSX support, POWER8 implies HTM support, etc. The only | ||
// exception is the POWER6x (ISA 2.05 + mffgpr/mftgpr extension). | ||
_PPC_FEATURE_POWER5_PLUS = 0x00020000 // ISA 2.03 (POWER5+) | ||
_PPC_FEATURE_ARCH_2_05 = 0x00001000 // ISA 2.05 (POWER6) | ||
_PPC_FEATURE_POWER6_EXT = 0x00000200 // mffgpr/mftgpr extension (POWER6x) | ||
_PPC_FEATURE_ARCH_2_06 = 0x00000100 // ISA 2.06 (POWER7). | ||
_PPC_FEATURE2_ARCH_2_07 = 0x80000000 // ISA 2.07 (POWER8) | ||
_PPC_FEATURE2_ARCH_3_00 = 0x00800000 // ISA 3.0 (POWER9) | ||
) | ||
|
||
var hwcap uint32 | ||
var hwcap2 uint32 | ||
|
||
// Function for runtime capability checks. | ||
// mask = hwcap or hwcap2 | ||
// supports = feature mask (see __PPC_FEATURE* constants above) | ||
func checkppc64supports(mask uint32, supports uint32) bool { | ||
if (mask & supports) == 0 { | ||
return false | ||
} else { | ||
return true | ||
} | ||
} | ||
|
||
func archauxv(tag, val uintptr) { | ||
switch tag { | ||
case _AT_HWCAP: | ||
hwcap = uint32(val) | ||
case _AT_HWCAP2: | ||
hwcap2 = uint32(val) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2016 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 runtime | ||
|
||
const ( | ||
_AT_HWCAP2 = 26 | ||
|
||
// Golang currently requires POWER8 as a minimum for ppc64le. Therefore, | ||
// there is no need to check for any capabilities that were introduced | ||
// before ISA 2.07 (Altivec/VMX, VSX, DFP, etc). Hence, only HWCAP2 is | ||
// required and we start checking from ISA 3.0 and beyond. | ||
_PPC_FEATURE2_ARCH_3_00 = 0x00800000 // ISA 3.0 (POWER9) | ||
) | ||
|
||
var hwcap2 uint32 | ||
|
||
// Function for runtime capability checks. | ||
// supports = feature mask (see __PPC_FEATURE2 constants above) | ||
func checkppc64lesupports(supports uint32) bool { | ||
if (hwcap2 & supports) == 0 { | ||
return false | ||
} else { | ||
return true | ||
} | ||
} | ||
|
||
|
||
func archauxv(tag, val uintptr) { | ||
switch tag { | ||
case _AT_HWCAP2: | ||
hwcap2 = uint32(val) | ||
} | ||
} |