Blame view
Documentation/arm64/cpu-feature-registers.rst
14.1 KB
b693d0b37 docs: arm64: conv... |
1 2 3 |
=========================== ARM64 CPU Feature Registers =========================== |
4aa8a472c arm64: Documentat... |
4 5 6 7 8 9 10 11 12 |
Author: Suzuki K Poulose <suzuki.poulose@arm.com> This file describes the ABI for exporting the AArch64 CPU ID/feature registers to userspace. The availability of this ABI is advertised via the HWCAP_CPUID in HWCAPs. 1. Motivation |
b693d0b37 docs: arm64: conv... |
13 |
------------- |
4aa8a472c arm64: Documentat... |
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
The ARM architecture defines a set of feature registers, which describe the capabilities of the CPU/system. Access to these system registers is restricted from EL0 and there is no reliable way for an application to extract this information to make better decisions at runtime. There is limited information available to the application via HWCAPs, however there are some issues with their usage. a) Any change to the HWCAPs requires an update to userspace (e.g libc) to detect the new changes, which can take a long time to appear in distributions. Exposing the registers allows applications to get the information without requiring updates to the toolchains. b) Access to HWCAPs is sometimes limited (e.g prior to libc, or when ld is initialised at startup time). c) HWCAPs cannot represent non-boolean information effectively. The architecture defines a canonical format for representing features in the ID registers; this is well defined and is capable of representing all valid architecture variations. 2. Requirements |
b693d0b37 docs: arm64: conv... |
37 38 39 |
--------------- a) Safety: |
4aa8a472c arm64: Documentat... |
40 |
|
4aa8a472c arm64: Documentat... |
41 42 43 44 45 46 47 48 49 50 |
Applications should be able to use the information provided by the infrastructure to run safely across the system. This has greater implications on a system with heterogeneous CPUs. The infrastructure exports a value that is safe across all the available CPU on the system. e.g, If at least one CPU doesn't implement CRC32 instructions, while others do, we should report that the CRC32 is not implemented. Otherwise an application could crash when scheduled on the CPU which doesn't support CRC32. |
b693d0b37 docs: arm64: conv... |
51 |
b) Security: |
4aa8a472c arm64: Documentat... |
52 53 54 55 56 57 58 59 60 61 |
Applications should only be able to receive information that is relevant to the normal operation in userspace. Hence, some of the fields are masked out(i.e, made invisible) and their values are set to indicate the feature is 'not supported'. See Section 4 for the list of visible features. Also, the kernel may manipulate the fields based on what it supports. e.g, If FP is not supported by the kernel, the values could indicate that the FP is not available (even when the CPU provides it). c) Implementation Defined Features |
b693d0b37 docs: arm64: conv... |
62 |
|
4aa8a472c arm64: Documentat... |
63 64 |
The infrastructure doesn't expose any register which is IMPLEMENTATION DEFINED as per ARMv8-A Architecture. |
b693d0b37 docs: arm64: conv... |
65 |
d) CPU Identification: |
4aa8a472c arm64: Documentat... |
66 67 68 69 70 71 72 73 |
MIDR_EL1 is exposed to help identify the processor. On a heterogeneous system, this could be racy (just like getcpu()). The process could be migrated to another CPU by the time it uses the register value, unless the CPU affinity is set. Hence, there is no guarantee that the value reflects the processor that it is currently executing on. The REVIDR is not exposed due to this constraint, as REVIDR makes sense only in conjunction with the MIDR. Alternately, MIDR_EL1 and REVIDR_EL1 are exposed via sysfs |
b693d0b37 docs: arm64: conv... |
74 |
at:: |
4aa8a472c arm64: Documentat... |
75 76 77 78 79 80 81 82 83 84 85 86 87 |
/sys/devices/system/cpu/cpu$ID/regs/identification/ \- midr \- revidr 3. Implementation -------------------- The infrastructure is built on the emulation of the 'MRS' instruction. Accessing a restricted system register from an application generates an exception and ends up in SIGILL being delivered to the process. The infrastructure hooks into the exception handler and emulates the operation if the source belongs to the supported system register space. |
b693d0b37 docs: arm64: conv... |
88 |
The infrastructure emulates only the following system register space:: |
4aa8a472c arm64: Documentat... |
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
Op0=3, Op1=0, CRn=0, CRm=0,4,5,6,7 (See Table C5-6 'System instruction encodings for non-Debug System register accesses' in ARMv8 ARM DDI 0487A.h, for the list of registers). The following rules are applied to the value returned by the infrastructure: a) The value of an 'IMPLEMENTATION DEFINED' field is set to 0. b) The value of a reserved field is populated with the reserved value as defined by the architecture. c) The value of a 'visible' field holds the system wide safe value for the particular feature (except for MIDR_EL1, see section 4). d) All other fields (i.e, invisible fields) are set to indicate the feature is missing (as defined by the architecture). 4. List of registers with visible features ------------------------------------------- 1) ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0 |
b693d0b37 docs: arm64: conv... |
110 111 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
112 |
| Name | bits | visible | |
b693d0b37 docs: arm64: conv... |
113 |
+------------------------------+---------+---------+ |
1a50ec0b3 arm64: Implement ... |
114 115 |
| RNDR | [63-60] | y | +------------------------------+---------+---------+ |
7206dc93a arm64: Expose Arm... |
116 |
| TS | [55-52] | y | |
b693d0b37 docs: arm64: conv... |
117 |
+------------------------------+---------+---------+ |
3b3b68109 arm64: v8.4: Supp... |
118 |
| FHM | [51-48] | y | |
b693d0b37 docs: arm64: conv... |
119 |
+------------------------------+---------+---------+ |
f5e035f86 arm64: Expose sup... |
120 |
| DP | [47-44] | y | |
b693d0b37 docs: arm64: conv... |
121 |
+------------------------------+---------+---------+ |
f5e035f86 arm64: Expose sup... |
122 |
| SM4 | [43-40] | y | |
b693d0b37 docs: arm64: conv... |
123 |
+------------------------------+---------+---------+ |
f5e035f86 arm64: Expose sup... |
124 |
| SM3 | [39-36] | y | |
b693d0b37 docs: arm64: conv... |
125 |
+------------------------------+---------+---------+ |
f5e035f86 arm64: Expose sup... |
126 |
| SHA3 | [35-32] | y | |
b693d0b37 docs: arm64: conv... |
127 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
128 |
| RDM | [31-28] | y | |
b693d0b37 docs: arm64: conv... |
129 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
130 |
| ATOMICS | [23-20] | y | |
b693d0b37 docs: arm64: conv... |
131 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
132 |
| CRC32 | [19-16] | y | |
b693d0b37 docs: arm64: conv... |
133 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
134 |
| SHA2 | [15-12] | y | |
b693d0b37 docs: arm64: conv... |
135 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
136 |
| SHA1 | [11-8] | y | |
b693d0b37 docs: arm64: conv... |
137 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
138 |
| AES | [7-4] | y | |
b693d0b37 docs: arm64: conv... |
139 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
140 141 142 |
2) ID_AA64PFR0_EL1 - Processor Feature Register 0 |
b693d0b37 docs: arm64: conv... |
143 144 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
145 |
| Name | bits | visible | |
b693d0b37 docs: arm64: conv... |
146 |
+------------------------------+---------+---------+ |
7206dc93a arm64: Expose Arm... |
147 |
| DIT | [51-48] | y | |
b693d0b37 docs: arm64: conv... |
148 |
+------------------------------+---------+---------+ |
43994d824 arm64/sve: Detect... |
149 |
| SVE | [35-32] | y | |
b693d0b37 docs: arm64: conv... |
150 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
151 |
| GIC | [27-24] | n | |
b693d0b37 docs: arm64: conv... |
152 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
153 |
| AdvSIMD | [23-20] | y | |
b693d0b37 docs: arm64: conv... |
154 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
155 |
| FP | [19-16] | y | |
b693d0b37 docs: arm64: conv... |
156 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
157 |
| EL3 | [15-12] | n | |
b693d0b37 docs: arm64: conv... |
158 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
159 |
| EL2 | [11-8] | n | |
b693d0b37 docs: arm64: conv... |
160 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
161 |
| EL1 | [7-4] | n | |
b693d0b37 docs: arm64: conv... |
162 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
163 |
| EL0 | [3-0] | n | |
b693d0b37 docs: arm64: conv... |
164 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
165 |
|
ade12b863 arm64: docs: cpu-... |
166 |
3) ID_AA64PFR1_EL1 - Processor Feature Register 1 |
581fce373 arm64: Documentat... |
167 |
|
ade12b863 arm64: docs: cpu-... |
168 169 170 |
+------------------------------+---------+---------+ | Name | bits | visible | +------------------------------+---------+---------+ |
df9d7a22d arm64: mte: Add M... |
171 172 |
| MTE | [11-8] | y | +------------------------------+---------+---------+ |
ade12b863 arm64: docs: cpu-... |
173 174 |
| SSBS | [7-4] | y | +------------------------------+---------+---------+ |
8ef8f360c arm64: Basic Bran... |
175 176 |
| BT | [3-0] | y | +------------------------------+---------+---------+ |
b693d0b37 docs: arm64: conv... |
177 |
|
b693d0b37 docs: arm64: conv... |
178 |
|
ade12b863 arm64: docs: cpu-... |
179 |
4) MIDR_EL1 - Main ID Register |
581fce373 arm64: Documentat... |
180 |
|
b693d0b37 docs: arm64: conv... |
181 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
182 |
| Name | bits | visible | |
b693d0b37 docs: arm64: conv... |
183 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
184 |
| Implementer | [31-24] | y | |
b693d0b37 docs: arm64: conv... |
185 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
186 |
| Variant | [23-20] | y | |
b693d0b37 docs: arm64: conv... |
187 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
188 |
| Architecture | [19-16] | y | |
b693d0b37 docs: arm64: conv... |
189 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
190 |
| PartNum | [15-4] | y | |
b693d0b37 docs: arm64: conv... |
191 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
192 |
| Revision | [3-0] | y | |
b693d0b37 docs: arm64: conv... |
193 |
+------------------------------+---------+---------+ |
4aa8a472c arm64: Documentat... |
194 195 196 197 |
NOTE: The 'visible' fields of MIDR_EL1 will contain the value as available on the CPU where it is fetched and is not a system wide safe value. |
ade12b863 arm64: docs: cpu-... |
198 |
5) ID_AA64ISAR1_EL1 - Instruction set attribute register 1 |
c8c3798d2 arm64: v8.3: Supp... |
199 |
|
b693d0b37 docs: arm64: conv... |
200 |
+------------------------------+---------+---------+ |
c8c3798d2 arm64: v8.3: Supp... |
201 |
| Name | bits | visible | |
b693d0b37 docs: arm64: conv... |
202 |
+------------------------------+---------+---------+ |
d4209d8b7 arm64: cpufeature... |
203 204 205 206 207 208 |
| I8MM | [55-52] | y | +------------------------------+---------+---------+ | DGH | [51-48] | y | +------------------------------+---------+---------+ | BF16 | [47-44] | y | +------------------------------+---------+---------+ |
478016c38 docs/arm64: cpu-f... |
209 |
| SB | [39-36] | y | |
a8613e707 docs/arm64: cpu-f... |
210 |
+------------------------------+---------+---------+ |
478016c38 docs/arm64: cpu-f... |
211 |
| FRINTTS | [35-32] | y | |
a8613e707 docs/arm64: cpu-f... |
212 |
+------------------------------+---------+---------+ |
fbedc599e arm64: docs: docu... |
213 |
| GPI | [31-28] | y | |
b693d0b37 docs: arm64: conv... |
214 |
+------------------------------+---------+---------+ |
fbedc599e arm64: docs: docu... |
215 |
| GPA | [27-24] | y | |
b693d0b37 docs: arm64: conv... |
216 |
+------------------------------+---------+---------+ |
c651aae5a arm64: v8.3: Supp... |
217 |
| LRCPC | [23-20] | y | |
b693d0b37 docs: arm64: conv... |
218 |
+------------------------------+---------+---------+ |
cb567e79f arm64: v8.3: Supp... |
219 |
| FCMA | [19-16] | y | |
b693d0b37 docs: arm64: conv... |
220 |
+------------------------------+---------+---------+ |
c8c3798d2 arm64: v8.3: Supp... |
221 |
| JSCVT | [15-12] | y | |
b693d0b37 docs: arm64: conv... |
222 |
+------------------------------+---------+---------+ |
fbedc599e arm64: docs: docu... |
223 |
| API | [11-8] | y | |
b693d0b37 docs: arm64: conv... |
224 |
+------------------------------+---------+---------+ |
fbedc599e arm64: docs: docu... |
225 |
| APA | [7-4] | y | |
b693d0b37 docs: arm64: conv... |
226 |
+------------------------------+---------+---------+ |
7aac405eb arm64: Expose DC ... |
227 |
| DPB | [3-0] | y | |
b693d0b37 docs: arm64: conv... |
228 |
+------------------------------+---------+---------+ |
c8c3798d2 arm64: v8.3: Supp... |
229 |
|
ade12b863 arm64: docs: cpu-... |
230 |
6) ID_AA64MMFR2_EL1 - Memory model feature register 2 |
7206dc93a arm64: Expose Arm... |
231 |
|
b693d0b37 docs: arm64: conv... |
232 |
+------------------------------+---------+---------+ |
7206dc93a arm64: Expose Arm... |
233 |
| Name | bits | visible | |
b693d0b37 docs: arm64: conv... |
234 |
+------------------------------+---------+---------+ |
7206dc93a arm64: Expose Arm... |
235 |
| AT | [35-32] | y | |
b693d0b37 docs: arm64: conv... |
236 |
+------------------------------+---------+---------+ |
7206dc93a arm64: Expose Arm... |
237 |
|
ade12b863 arm64: docs: cpu-... |
238 |
7) ID_AA64ZFR0_EL1 - SVE feature ID register 0 |
06a916fec arm64: Expose SVE... |
239 |
|
b693d0b37 docs: arm64: conv... |
240 |
+------------------------------+---------+---------+ |
06a916fec arm64: Expose SVE... |
241 |
| Name | bits | visible | |
b693d0b37 docs: arm64: conv... |
242 |
+------------------------------+---------+---------+ |
d4209d8b7 arm64: cpufeature... |
243 244 245 246 247 248 |
| F64MM | [59-56] | y | +------------------------------+---------+---------+ | F32MM | [55-52] | y | +------------------------------+---------+---------+ | I8MM | [47-44] | y | +------------------------------+---------+---------+ |
06a916fec arm64: Expose SVE... |
249 |
| SM4 | [43-40] | y | |
b693d0b37 docs: arm64: conv... |
250 |
+------------------------------+---------+---------+ |
06a916fec arm64: Expose SVE... |
251 |
| SHA3 | [35-32] | y | |
b693d0b37 docs: arm64: conv... |
252 |
+------------------------------+---------+---------+ |
d4209d8b7 arm64: cpufeature... |
253 254 |
| BF16 | [23-20] | y | +------------------------------+---------+---------+ |
06a916fec arm64: Expose SVE... |
255 |
| BitPerm | [19-16] | y | |
b693d0b37 docs: arm64: conv... |
256 |
+------------------------------+---------+---------+ |
06a916fec arm64: Expose SVE... |
257 |
| AES | [7-4] | y | |
b693d0b37 docs: arm64: conv... |
258 |
+------------------------------+---------+---------+ |
06a916fec arm64: Expose SVE... |
259 |
| SVEVer | [3-0] | y | |
b693d0b37 docs: arm64: conv... |
260 |
+------------------------------+---------+---------+ |
06a916fec arm64: Expose SVE... |
261 |
|
4aa8a472c arm64: Documentat... |
262 |
Appendix I: Example |
b693d0b37 docs: arm64: conv... |
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
------------------- :: /* * Sample program to demonstrate the MRS emulation ABI. * * Copyright (C) 2015-2016, ARM Ltd * * Author: Suzuki K Poulose <suzuki.poulose@arm.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <asm/hwcap.h> #include <stdio.h> #include <sys/auxv.h> #define get_cpu_ftr(id) ({ \ |
4aa8a472c arm64: Documentat... |
297 298 299 300 301 |
unsigned long __val; \ asm("mrs %0, "#id : "=r" (__val)); \ printf("%-20s: 0x%016lx ", #id, __val); \ }) |
b693d0b37 docs: arm64: conv... |
302 303 |
int main(void) { |
4aa8a472c arm64: Documentat... |
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) { fputs("CPUID registers unavailable ", stderr); return 1; } get_cpu_ftr(ID_AA64ISAR0_EL1); get_cpu_ftr(ID_AA64ISAR1_EL1); get_cpu_ftr(ID_AA64MMFR0_EL1); get_cpu_ftr(ID_AA64MMFR1_EL1); get_cpu_ftr(ID_AA64PFR0_EL1); get_cpu_ftr(ID_AA64PFR1_EL1); get_cpu_ftr(ID_AA64DFR0_EL1); get_cpu_ftr(ID_AA64DFR1_EL1); get_cpu_ftr(MIDR_EL1); get_cpu_ftr(MPIDR_EL1); get_cpu_ftr(REVIDR_EL1); |
b693d0b37 docs: arm64: conv... |
323 |
#if 0 |
4aa8a472c arm64: Documentat... |
324 325 |
/* Unexposed register access causes SIGILL */ get_cpu_ftr(ID_MMFR0_EL1); |
b693d0b37 docs: arm64: conv... |
326 |
#endif |
4aa8a472c arm64: Documentat... |
327 328 |
return 0; |
b693d0b37 docs: arm64: conv... |
329 |
} |