1e4624435SJonathan Corbet=========================== 2e4624435SJonathan CorbetARM64 CPU Feature Registers 3e4624435SJonathan Corbet=========================== 4e4624435SJonathan Corbet 5e4624435SJonathan CorbetAuthor: Suzuki K Poulose <suzuki.poulose@arm.com> 6e4624435SJonathan Corbet 7e4624435SJonathan Corbet 8e4624435SJonathan CorbetThis file describes the ABI for exporting the AArch64 CPU ID/feature 9e4624435SJonathan Corbetregisters to userspace. The availability of this ABI is advertised 10e4624435SJonathan Corbetvia the HWCAP_CPUID in HWCAPs. 11e4624435SJonathan Corbet 12e4624435SJonathan Corbet1. Motivation 13e4624435SJonathan Corbet------------- 14e4624435SJonathan Corbet 15e4624435SJonathan CorbetThe ARM architecture defines a set of feature registers, which describe 16e4624435SJonathan Corbetthe capabilities of the CPU/system. Access to these system registers is 17e4624435SJonathan Corbetrestricted from EL0 and there is no reliable way for an application to 18e4624435SJonathan Corbetextract this information to make better decisions at runtime. There is 19e4624435SJonathan Corbetlimited information available to the application via HWCAPs, however 20e4624435SJonathan Corbetthere are some issues with their usage. 21e4624435SJonathan Corbet 22e4624435SJonathan Corbet a) Any change to the HWCAPs requires an update to userspace (e.g libc) 23e4624435SJonathan Corbet to detect the new changes, which can take a long time to appear in 24e4624435SJonathan Corbet distributions. Exposing the registers allows applications to get the 25e4624435SJonathan Corbet information without requiring updates to the toolchains. 26e4624435SJonathan Corbet 27e4624435SJonathan Corbet b) Access to HWCAPs is sometimes limited (e.g prior to libc, or 28e4624435SJonathan Corbet when ld is initialised at startup time). 29e4624435SJonathan Corbet 30e4624435SJonathan Corbet c) HWCAPs cannot represent non-boolean information effectively. The 31e4624435SJonathan Corbet architecture defines a canonical format for representing features 32e4624435SJonathan Corbet in the ID registers; this is well defined and is capable of 33e4624435SJonathan Corbet representing all valid architecture variations. 34e4624435SJonathan Corbet 35e4624435SJonathan Corbet 36e4624435SJonathan Corbet2. Requirements 37e4624435SJonathan Corbet--------------- 38e4624435SJonathan Corbet 39e4624435SJonathan Corbet a) Safety: 40e4624435SJonathan Corbet 41e4624435SJonathan Corbet Applications should be able to use the information provided by the 42e4624435SJonathan Corbet infrastructure to run safely across the system. This has greater 43e4624435SJonathan Corbet implications on a system with heterogeneous CPUs. 44e4624435SJonathan Corbet The infrastructure exports a value that is safe across all the 45e4624435SJonathan Corbet available CPU on the system. 46e4624435SJonathan Corbet 47e4624435SJonathan Corbet e.g, If at least one CPU doesn't implement CRC32 instructions, while 48e4624435SJonathan Corbet others do, we should report that the CRC32 is not implemented. 49e4624435SJonathan Corbet Otherwise an application could crash when scheduled on the CPU 50e4624435SJonathan Corbet which doesn't support CRC32. 51e4624435SJonathan Corbet 52e4624435SJonathan Corbet b) Security: 53e4624435SJonathan Corbet 54e4624435SJonathan Corbet Applications should only be able to receive information that is 55e4624435SJonathan Corbet relevant to the normal operation in userspace. Hence, some of the 56e4624435SJonathan Corbet fields are masked out(i.e, made invisible) and their values are set to 57e4624435SJonathan Corbet indicate the feature is 'not supported'. See Section 4 for the list 58e4624435SJonathan Corbet of visible features. Also, the kernel may manipulate the fields 59e4624435SJonathan Corbet based on what it supports. e.g, If FP is not supported by the 60e4624435SJonathan Corbet kernel, the values could indicate that the FP is not available 61e4624435SJonathan Corbet (even when the CPU provides it). 62e4624435SJonathan Corbet 63e4624435SJonathan Corbet c) Implementation Defined Features 64e4624435SJonathan Corbet 65e4624435SJonathan Corbet The infrastructure doesn't expose any register which is 66e4624435SJonathan Corbet IMPLEMENTATION DEFINED as per ARMv8-A Architecture. 67e4624435SJonathan Corbet 68e4624435SJonathan Corbet d) CPU Identification: 69e4624435SJonathan Corbet 70e4624435SJonathan Corbet MIDR_EL1 is exposed to help identify the processor. On a 71e4624435SJonathan Corbet heterogeneous system, this could be racy (just like getcpu()). The 72e4624435SJonathan Corbet process could be migrated to another CPU by the time it uses the 73e4624435SJonathan Corbet register value, unless the CPU affinity is set. Hence, there is no 74e4624435SJonathan Corbet guarantee that the value reflects the processor that it is 75e4624435SJonathan Corbet currently executing on. The REVIDR is not exposed due to this 76e4624435SJonathan Corbet constraint, as REVIDR makes sense only in conjunction with the 77e4624435SJonathan Corbet MIDR. Alternately, MIDR_EL1 and REVIDR_EL1 are exposed via sysfs 78e4624435SJonathan Corbet at:: 79e4624435SJonathan Corbet 80e4624435SJonathan Corbet /sys/devices/system/cpu/cpu$ID/regs/identification/ 81e4624435SJonathan Corbet \- midr 82e4624435SJonathan Corbet \- revidr 83e4624435SJonathan Corbet 84e4624435SJonathan Corbet3. Implementation 85e4624435SJonathan Corbet-------------------- 86e4624435SJonathan Corbet 87e4624435SJonathan CorbetThe infrastructure is built on the emulation of the 'MRS' instruction. 88e4624435SJonathan CorbetAccessing a restricted system register from an application generates an 89e4624435SJonathan Corbetexception and ends up in SIGILL being delivered to the process. 90e4624435SJonathan CorbetThe infrastructure hooks into the exception handler and emulates the 91e4624435SJonathan Corbetoperation if the source belongs to the supported system register space. 92e4624435SJonathan Corbet 93e4624435SJonathan CorbetThe infrastructure emulates only the following system register space:: 94e4624435SJonathan Corbet 95e4624435SJonathan Corbet Op0=3, Op1=0, CRn=0, CRm=0,2,3,4,5,6,7 96e4624435SJonathan Corbet 97e4624435SJonathan Corbet(See Table C5-6 'System instruction encodings for non-Debug System 98e4624435SJonathan Corbetregister accesses' in ARMv8 ARM DDI 0487A.h, for the list of 99e4624435SJonathan Corbetregisters). 100e4624435SJonathan Corbet 101e4624435SJonathan CorbetThe following rules are applied to the value returned by the 102e4624435SJonathan Corbetinfrastructure: 103e4624435SJonathan Corbet 104e4624435SJonathan Corbet a) The value of an 'IMPLEMENTATION DEFINED' field is set to 0. 105e4624435SJonathan Corbet b) The value of a reserved field is populated with the reserved 106e4624435SJonathan Corbet value as defined by the architecture. 107e4624435SJonathan Corbet c) The value of a 'visible' field holds the system wide safe value 108e4624435SJonathan Corbet for the particular feature (except for MIDR_EL1, see section 4). 109e4624435SJonathan Corbet d) All other fields (i.e, invisible fields) are set to indicate 110e4624435SJonathan Corbet the feature is missing (as defined by the architecture). 111e4624435SJonathan Corbet 112e4624435SJonathan Corbet4. List of registers with visible features 113e4624435SJonathan Corbet------------------------------------------- 114e4624435SJonathan Corbet 115e4624435SJonathan Corbet 1) ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0 116e4624435SJonathan Corbet 117e4624435SJonathan Corbet +------------------------------+---------+---------+ 118e4624435SJonathan Corbet | Name | bits | visible | 119e4624435SJonathan Corbet +------------------------------+---------+---------+ 120e4624435SJonathan Corbet | RNDR | [63-60] | y | 121e4624435SJonathan Corbet +------------------------------+---------+---------+ 122e4624435SJonathan Corbet | TS | [55-52] | y | 123e4624435SJonathan Corbet +------------------------------+---------+---------+ 124e4624435SJonathan Corbet | FHM | [51-48] | y | 125e4624435SJonathan Corbet +------------------------------+---------+---------+ 126e4624435SJonathan Corbet | DP | [47-44] | y | 127e4624435SJonathan Corbet +------------------------------+---------+---------+ 128e4624435SJonathan Corbet | SM4 | [43-40] | y | 129e4624435SJonathan Corbet +------------------------------+---------+---------+ 130e4624435SJonathan Corbet | SM3 | [39-36] | y | 131e4624435SJonathan Corbet +------------------------------+---------+---------+ 132e4624435SJonathan Corbet | SHA3 | [35-32] | y | 133e4624435SJonathan Corbet +------------------------------+---------+---------+ 134e4624435SJonathan Corbet | RDM | [31-28] | y | 135e4624435SJonathan Corbet +------------------------------+---------+---------+ 136e4624435SJonathan Corbet | ATOMICS | [23-20] | y | 137e4624435SJonathan Corbet +------------------------------+---------+---------+ 138e4624435SJonathan Corbet | CRC32 | [19-16] | y | 139e4624435SJonathan Corbet +------------------------------+---------+---------+ 140e4624435SJonathan Corbet | SHA2 | [15-12] | y | 141e4624435SJonathan Corbet +------------------------------+---------+---------+ 142e4624435SJonathan Corbet | SHA1 | [11-8] | y | 143e4624435SJonathan Corbet +------------------------------+---------+---------+ 144e4624435SJonathan Corbet | AES | [7-4] | y | 145e4624435SJonathan Corbet +------------------------------+---------+---------+ 146e4624435SJonathan Corbet 147e4624435SJonathan Corbet 148e4624435SJonathan Corbet 2) ID_AA64PFR0_EL1 - Processor Feature Register 0 149e4624435SJonathan Corbet 150e4624435SJonathan Corbet +------------------------------+---------+---------+ 151e4624435SJonathan Corbet | Name | bits | visible | 152e4624435SJonathan Corbet +------------------------------+---------+---------+ 153e4624435SJonathan Corbet | DIT | [51-48] | y | 154e4624435SJonathan Corbet +------------------------------+---------+---------+ 155e4624435SJonathan Corbet | SVE | [35-32] | y | 156e4624435SJonathan Corbet +------------------------------+---------+---------+ 157e4624435SJonathan Corbet | GIC | [27-24] | n | 158e4624435SJonathan Corbet +------------------------------+---------+---------+ 159e4624435SJonathan Corbet | AdvSIMD | [23-20] | y | 160e4624435SJonathan Corbet +------------------------------+---------+---------+ 161e4624435SJonathan Corbet | FP | [19-16] | y | 162e4624435SJonathan Corbet +------------------------------+---------+---------+ 163e4624435SJonathan Corbet | EL3 | [15-12] | n | 164e4624435SJonathan Corbet +------------------------------+---------+---------+ 165e4624435SJonathan Corbet | EL2 | [11-8] | n | 166e4624435SJonathan Corbet +------------------------------+---------+---------+ 167e4624435SJonathan Corbet | EL1 | [7-4] | n | 168e4624435SJonathan Corbet +------------------------------+---------+---------+ 169e4624435SJonathan Corbet | EL0 | [3-0] | n | 170e4624435SJonathan Corbet +------------------------------+---------+---------+ 171e4624435SJonathan Corbet 172e4624435SJonathan Corbet 173e4624435SJonathan Corbet 3) ID_AA64PFR1_EL1 - Processor Feature Register 1 174e4624435SJonathan Corbet 175e4624435SJonathan Corbet +------------------------------+---------+---------+ 176e4624435SJonathan Corbet | Name | bits | visible | 177e4624435SJonathan Corbet +------------------------------+---------+---------+ 178046b212aSMark Brown | SME | [27-24] | y | 179046b212aSMark Brown +------------------------------+---------+---------+ 180e4624435SJonathan Corbet | MTE | [11-8] | y | 181e4624435SJonathan Corbet +------------------------------+---------+---------+ 182e4624435SJonathan Corbet | SSBS | [7-4] | y | 183e4624435SJonathan Corbet +------------------------------+---------+---------+ 184e4624435SJonathan Corbet | BT | [3-0] | y | 185e4624435SJonathan Corbet +------------------------------+---------+---------+ 186e4624435SJonathan Corbet 187e4624435SJonathan Corbet 188e4624435SJonathan Corbet 4) MIDR_EL1 - Main ID Register 189e4624435SJonathan Corbet 190e4624435SJonathan Corbet +------------------------------+---------+---------+ 191e4624435SJonathan Corbet | Name | bits | visible | 192e4624435SJonathan Corbet +------------------------------+---------+---------+ 193e4624435SJonathan Corbet | Implementer | [31-24] | y | 194e4624435SJonathan Corbet +------------------------------+---------+---------+ 195e4624435SJonathan Corbet | Variant | [23-20] | y | 196e4624435SJonathan Corbet +------------------------------+---------+---------+ 197e4624435SJonathan Corbet | Architecture | [19-16] | y | 198e4624435SJonathan Corbet +------------------------------+---------+---------+ 199e4624435SJonathan Corbet | PartNum | [15-4] | y | 200e4624435SJonathan Corbet +------------------------------+---------+---------+ 201e4624435SJonathan Corbet | Revision | [3-0] | y | 202e4624435SJonathan Corbet +------------------------------+---------+---------+ 203e4624435SJonathan Corbet 204e4624435SJonathan Corbet NOTE: The 'visible' fields of MIDR_EL1 will contain the value 205e4624435SJonathan Corbet as available on the CPU where it is fetched and is not a system 206e4624435SJonathan Corbet wide safe value. 207e4624435SJonathan Corbet 208e4624435SJonathan Corbet 5) ID_AA64ISAR1_EL1 - Instruction set attribute register 1 209e4624435SJonathan Corbet 210e4624435SJonathan Corbet +------------------------------+---------+---------+ 211e4624435SJonathan Corbet | Name | bits | visible | 212e4624435SJonathan Corbet +------------------------------+---------+---------+ 213e4624435SJonathan Corbet | I8MM | [55-52] | y | 214e4624435SJonathan Corbet +------------------------------+---------+---------+ 215e4624435SJonathan Corbet | DGH | [51-48] | y | 216e4624435SJonathan Corbet +------------------------------+---------+---------+ 217e4624435SJonathan Corbet | BF16 | [47-44] | y | 218e4624435SJonathan Corbet +------------------------------+---------+---------+ 219e4624435SJonathan Corbet | SB | [39-36] | y | 220e4624435SJonathan Corbet +------------------------------+---------+---------+ 221e4624435SJonathan Corbet | FRINTTS | [35-32] | y | 222e4624435SJonathan Corbet +------------------------------+---------+---------+ 223e4624435SJonathan Corbet | GPI | [31-28] | y | 224e4624435SJonathan Corbet +------------------------------+---------+---------+ 225e4624435SJonathan Corbet | GPA | [27-24] | y | 226e4624435SJonathan Corbet +------------------------------+---------+---------+ 227e4624435SJonathan Corbet | LRCPC | [23-20] | y | 228e4624435SJonathan Corbet +------------------------------+---------+---------+ 229e4624435SJonathan Corbet | FCMA | [19-16] | y | 230e4624435SJonathan Corbet +------------------------------+---------+---------+ 231e4624435SJonathan Corbet | JSCVT | [15-12] | y | 232e4624435SJonathan Corbet +------------------------------+---------+---------+ 233e4624435SJonathan Corbet | API | [11-8] | y | 234e4624435SJonathan Corbet +------------------------------+---------+---------+ 235e4624435SJonathan Corbet | APA | [7-4] | y | 236e4624435SJonathan Corbet +------------------------------+---------+---------+ 237e4624435SJonathan Corbet | DPB | [3-0] | y | 238e4624435SJonathan Corbet +------------------------------+---------+---------+ 239e4624435SJonathan Corbet 240e4624435SJonathan Corbet 6) ID_AA64MMFR0_EL1 - Memory model feature register 0 241e4624435SJonathan Corbet 242e4624435SJonathan Corbet +------------------------------+---------+---------+ 243e4624435SJonathan Corbet | Name | bits | visible | 244e4624435SJonathan Corbet +------------------------------+---------+---------+ 245e4624435SJonathan Corbet | ECV | [63-60] | y | 246e4624435SJonathan Corbet +------------------------------+---------+---------+ 247e4624435SJonathan Corbet 248e4624435SJonathan Corbet 7) ID_AA64MMFR2_EL1 - Memory model feature register 2 249e4624435SJonathan Corbet 250e4624435SJonathan Corbet +------------------------------+---------+---------+ 251e4624435SJonathan Corbet | Name | bits | visible | 252e4624435SJonathan Corbet +------------------------------+---------+---------+ 253e4624435SJonathan Corbet | AT | [35-32] | y | 254e4624435SJonathan Corbet +------------------------------+---------+---------+ 255e4624435SJonathan Corbet 256e4624435SJonathan Corbet 8) ID_AA64ZFR0_EL1 - SVE feature ID register 0 257e4624435SJonathan Corbet 258e4624435SJonathan Corbet +------------------------------+---------+---------+ 259e4624435SJonathan Corbet | Name | bits | visible | 260e4624435SJonathan Corbet +------------------------------+---------+---------+ 261e4624435SJonathan Corbet | F64MM | [59-56] | y | 262e4624435SJonathan Corbet +------------------------------+---------+---------+ 263e4624435SJonathan Corbet | F32MM | [55-52] | y | 264e4624435SJonathan Corbet +------------------------------+---------+---------+ 265e4624435SJonathan Corbet | I8MM | [47-44] | y | 266e4624435SJonathan Corbet +------------------------------+---------+---------+ 267e4624435SJonathan Corbet | SM4 | [43-40] | y | 268e4624435SJonathan Corbet +------------------------------+---------+---------+ 269e4624435SJonathan Corbet | SHA3 | [35-32] | y | 270e4624435SJonathan Corbet +------------------------------+---------+---------+ 271e4624435SJonathan Corbet | BF16 | [23-20] | y | 272e4624435SJonathan Corbet +------------------------------+---------+---------+ 273e4624435SJonathan Corbet | BitPerm | [19-16] | y | 274e4624435SJonathan Corbet +------------------------------+---------+---------+ 275e4624435SJonathan Corbet | AES | [7-4] | y | 276e4624435SJonathan Corbet +------------------------------+---------+---------+ 277e4624435SJonathan Corbet | SVEVer | [3-0] | y | 278e4624435SJonathan Corbet +------------------------------+---------+---------+ 279e4624435SJonathan Corbet 280e4624435SJonathan Corbet 8) ID_AA64MMFR1_EL1 - Memory model feature register 1 281e4624435SJonathan Corbet 282e4624435SJonathan Corbet +------------------------------+---------+---------+ 283e4624435SJonathan Corbet | Name | bits | visible | 284e4624435SJonathan Corbet +------------------------------+---------+---------+ 285e4624435SJonathan Corbet | AFP | [47-44] | y | 286e4624435SJonathan Corbet +------------------------------+---------+---------+ 287e4624435SJonathan Corbet 288e4624435SJonathan Corbet 9) ID_AA64ISAR2_EL1 - Instruction set attribute register 2 289e4624435SJonathan Corbet 290e4624435SJonathan Corbet +------------------------------+---------+---------+ 291e4624435SJonathan Corbet | Name | bits | visible | 292e4624435SJonathan Corbet +------------------------------+---------+---------+ 293*44a5b6b5SMark Brown | CSSC | [55-52] | y | 294*44a5b6b5SMark Brown +------------------------------+---------+---------+ 295*44a5b6b5SMark Brown | RPRFM | [51-48] | y | 296*44a5b6b5SMark Brown +------------------------------+---------+---------+ 297*44a5b6b5SMark Brown | BC | [23-20] | y | 298*44a5b6b5SMark Brown +------------------------------+---------+---------+ 2996aeadf78SLinus Torvalds | MOPS | [19-16] | y | 3006aeadf78SLinus Torvalds +------------------------------+---------+---------+ 301*44a5b6b5SMark Brown | APA3 | [15-12] | y | 302*44a5b6b5SMark Brown +------------------------------+---------+---------+ 303*44a5b6b5SMark Brown | GPA3 | [11-8] | y | 304*44a5b6b5SMark Brown +------------------------------+---------+---------+ 305e4624435SJonathan Corbet | RPRES | [7-4] | y | 306e4624435SJonathan Corbet +------------------------------+---------+---------+ 307e4624435SJonathan Corbet | WFXT | [3-0] | y | 308e4624435SJonathan Corbet +------------------------------+---------+---------+ 309e4624435SJonathan Corbet 310e4624435SJonathan Corbet 10) MVFR0_EL1 - AArch32 Media and VFP Feature Register 0 311e4624435SJonathan Corbet 312e4624435SJonathan Corbet +------------------------------+---------+---------+ 313e4624435SJonathan Corbet | Name | bits | visible | 314e4624435SJonathan Corbet +------------------------------+---------+---------+ 315e4624435SJonathan Corbet | FPDP | [11-8] | y | 316e4624435SJonathan Corbet +------------------------------+---------+---------+ 317e4624435SJonathan Corbet 318e4624435SJonathan Corbet 11) MVFR1_EL1 - AArch32 Media and VFP Feature Register 1 319e4624435SJonathan Corbet 320e4624435SJonathan Corbet +------------------------------+---------+---------+ 321e4624435SJonathan Corbet | Name | bits | visible | 322e4624435SJonathan Corbet +------------------------------+---------+---------+ 323e4624435SJonathan Corbet | SIMDFMAC | [31-28] | y | 324e4624435SJonathan Corbet +------------------------------+---------+---------+ 325e4624435SJonathan Corbet | SIMDSP | [19-16] | y | 326e4624435SJonathan Corbet +------------------------------+---------+---------+ 327e4624435SJonathan Corbet | SIMDInt | [15-12] | y | 328e4624435SJonathan Corbet +------------------------------+---------+---------+ 329e4624435SJonathan Corbet | SIMDLS | [11-8] | y | 330e4624435SJonathan Corbet +------------------------------+---------+---------+ 331e4624435SJonathan Corbet 332e4624435SJonathan Corbet 12) ID_ISAR5_EL1 - AArch32 Instruction Set Attribute Register 5 333e4624435SJonathan Corbet 334e4624435SJonathan Corbet +------------------------------+---------+---------+ 335e4624435SJonathan Corbet | Name | bits | visible | 336e4624435SJonathan Corbet +------------------------------+---------+---------+ 337e4624435SJonathan Corbet | CRC32 | [19-16] | y | 338e4624435SJonathan Corbet +------------------------------+---------+---------+ 339e4624435SJonathan Corbet | SHA2 | [15-12] | y | 340e4624435SJonathan Corbet +------------------------------+---------+---------+ 341e4624435SJonathan Corbet | SHA1 | [11-8] | y | 342e4624435SJonathan Corbet +------------------------------+---------+---------+ 343e4624435SJonathan Corbet | AES | [7-4] | y | 344e4624435SJonathan Corbet +------------------------------+---------+---------+ 345e4624435SJonathan Corbet 346e4624435SJonathan Corbet 347e4624435SJonathan CorbetAppendix I: Example 348e4624435SJonathan Corbet------------------- 349e4624435SJonathan Corbet 350e4624435SJonathan Corbet:: 351e4624435SJonathan Corbet 352e4624435SJonathan Corbet /* 353e4624435SJonathan Corbet * Sample program to demonstrate the MRS emulation ABI. 354e4624435SJonathan Corbet * 355e4624435SJonathan Corbet * Copyright (C) 2015-2016, ARM Ltd 356e4624435SJonathan Corbet * 357e4624435SJonathan Corbet * Author: Suzuki K Poulose <suzuki.poulose@arm.com> 358e4624435SJonathan Corbet * 359e4624435SJonathan Corbet * This program is free software; you can redistribute it and/or modify 360e4624435SJonathan Corbet * it under the terms of the GNU General Public License version 2 as 361e4624435SJonathan Corbet * published by the Free Software Foundation. 362e4624435SJonathan Corbet * 363e4624435SJonathan Corbet * This program is distributed in the hope that it will be useful, 364e4624435SJonathan Corbet * but WITHOUT ANY WARRANTY; without even the implied warranty of 365e4624435SJonathan Corbet * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 366e4624435SJonathan Corbet * GNU General Public License for more details. 367e4624435SJonathan Corbet * This program is free software; you can redistribute it and/or modify 368e4624435SJonathan Corbet * it under the terms of the GNU General Public License version 2 as 369e4624435SJonathan Corbet * published by the Free Software Foundation. 370e4624435SJonathan Corbet * 371e4624435SJonathan Corbet * This program is distributed in the hope that it will be useful, 372e4624435SJonathan Corbet * but WITHOUT ANY WARRANTY; without even the implied warranty of 373e4624435SJonathan Corbet * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 374e4624435SJonathan Corbet * GNU General Public License for more details. 375e4624435SJonathan Corbet */ 376e4624435SJonathan Corbet 377e4624435SJonathan Corbet #include <asm/hwcap.h> 378e4624435SJonathan Corbet #include <stdio.h> 379e4624435SJonathan Corbet #include <sys/auxv.h> 380e4624435SJonathan Corbet 381e4624435SJonathan Corbet #define get_cpu_ftr(id) ({ \ 382e4624435SJonathan Corbet unsigned long __val; \ 383e4624435SJonathan Corbet asm("mrs %0, "#id : "=r" (__val)); \ 384e4624435SJonathan Corbet printf("%-20s: 0x%016lx\n", #id, __val); \ 385e4624435SJonathan Corbet }) 386e4624435SJonathan Corbet 387e4624435SJonathan Corbet int main(void) 388e4624435SJonathan Corbet { 389e4624435SJonathan Corbet 390e4624435SJonathan Corbet if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) { 391e4624435SJonathan Corbet fputs("CPUID registers unavailable\n", stderr); 392e4624435SJonathan Corbet return 1; 393e4624435SJonathan Corbet } 394e4624435SJonathan Corbet 395e4624435SJonathan Corbet get_cpu_ftr(ID_AA64ISAR0_EL1); 396e4624435SJonathan Corbet get_cpu_ftr(ID_AA64ISAR1_EL1); 397e4624435SJonathan Corbet get_cpu_ftr(ID_AA64MMFR0_EL1); 398e4624435SJonathan Corbet get_cpu_ftr(ID_AA64MMFR1_EL1); 399e4624435SJonathan Corbet get_cpu_ftr(ID_AA64PFR0_EL1); 400e4624435SJonathan Corbet get_cpu_ftr(ID_AA64PFR1_EL1); 401e4624435SJonathan Corbet get_cpu_ftr(ID_AA64DFR0_EL1); 402e4624435SJonathan Corbet get_cpu_ftr(ID_AA64DFR1_EL1); 403e4624435SJonathan Corbet 404e4624435SJonathan Corbet get_cpu_ftr(MIDR_EL1); 405e4624435SJonathan Corbet get_cpu_ftr(MPIDR_EL1); 406e4624435SJonathan Corbet get_cpu_ftr(REVIDR_EL1); 407e4624435SJonathan Corbet 408e4624435SJonathan Corbet #if 0 409e4624435SJonathan Corbet /* Unexposed register access causes SIGILL */ 410e4624435SJonathan Corbet get_cpu_ftr(ID_MMFR0_EL1); 411e4624435SJonathan Corbet #endif 412e4624435SJonathan Corbet 413e4624435SJonathan Corbet return 0; 414e4624435SJonathan Corbet } 415