HasCRC32 bool
HasATOMICS bool
HasCPUID bool
+ HasDIT bool
IsNeoverse bool
_ CacheLinePad
}
func getisar0() uint64
+func getpfr0() uint64
+
func getMIDR() uint64
func extractBits(data uint64, start, end uint) uint {
return (uint)(data>>start) & ((1 << (end - start + 1)) - 1)
}
-func parseARM64SystemRegisters(isar0 uint64) {
+func parseARM64SystemRegisters(isar0, pfr0 uint64) {
// ID_AA64ISAR0_EL1
switch extractBits(isar0, 4, 7) {
case 1:
case 2:
ARM64.HasATOMICS = true
}
+
+ switch extractBits(pfr0, 48, 51) {
+ case 1:
+ ARM64.HasDIT = true
+ }
}
MOVD R0, ret+0(FP)
RET
+// func getpfr0() uint64
+TEXT ·getpfr0(SB),NOSPLIT,$0-8
+ // get Processor Feature Register 0 into R0
+ MRS ID_AA64PFR0_EL1, R0
+ MOVD R0, ret+0(FP)
+ RET
+
// func getMIDR() uint64
TEXT ·getMIDR(SB), NOSPLIT, $0-8
MRS MIDR_EL1, R0
ARM64.HasATOMICS = sysctlEnabled([]byte("hw.optional.armv8_1_atomics\x00"))
ARM64.HasCRC32 = sysctlEnabled([]byte("hw.optional.armv8_crc32\x00"))
ARM64.HasSHA512 = sysctlEnabled([]byte("hw.optional.armv8_2_sha512\x00"))
+ ARM64.HasDIT = sysctlEnabled([]byte("hw.optional.arm.FEAT_DIT\x00"))
// There are no hw.optional sysctl values for the below features on Mac OS 11.0
// to detect their supported state dynamically. Assume the CPU features that
func osInit() {
// Retrieve info from system register ID_AA64ISAR0_EL1.
isar0 := getisar0()
+ prf0 := getpfr0()
- parseARM64SystemRegisters(isar0)
+ parseARM64SystemRegisters(isar0, prf0)
}
hwcap_ATOMICS = 1 << 8
hwcap_CPUID = 1 << 11
hwcap_SHA512 = 1 << 21
+ hwcap_DIT = 1 << 24
)
func hwcapInit(os string) {
ARM64.HasCRC32 = isSet(HWCap, hwcap_CRC32)
ARM64.HasCPUID = isSet(HWCap, hwcap_CPUID)
ARM64.HasSHA512 = isSet(HWCap, hwcap_SHA512)
+ ARM64.HasDIT = isSet(HWCap, hwcap_DIT)
// The Samsung S9+ kernel reports support for atomics, but not all cores
// actually support them, resulting in SIGILL. See issue #28431.
// From OpenBSD's machine/cpu.h.
_CPU_ID_AA64ISAR0 = 2
_CPU_ID_AA64ISAR1 = 3
+ _CPU_ID_AA64PFR0 = 8
)
//go:noescape
if !ok {
return
}
- parseARM64SystemRegisters(isar0)
+ // Get ID_AA64PFR0 from sysctl.
+ pfr0, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64PFR0})
+ if !ok {
+ return
+ }
+
+ parseARM64SystemRegisters(isar0, pfr0)
}