Bailu Lin | 2472943 | 2020-11-23 18:38:14 -0800 | [diff] [blame] | 1 | .. _elf_hwcaps_index: |
| 2 | |
Mauro Carvalho Chehab | b693d0b | 2019-06-12 14:52:38 -0300 | [diff] [blame] | 3 | ================ |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 4 | ARM64 ELF hwcaps |
| 5 | ================ |
| 6 | |
| 7 | This document describes the usage and semantics of the arm64 ELF hwcaps. |
| 8 | |
| 9 | |
| 10 | 1. Introduction |
| 11 | --------------- |
| 12 | |
| 13 | Some hardware or software features are only available on some CPU |
| 14 | implementations, and/or with certain kernel configurations, but have no |
| 15 | architected discovery mechanism available to userspace code at EL0. The |
| 16 | kernel exposes the presence of these features to userspace through a set |
| 17 | of flags called hwcaps, exposed in the auxilliary vector. |
| 18 | |
Andrew Murray | aaba098 | 2019-04-09 10:52:40 +0100 | [diff] [blame] | 19 | Userspace software can test for features by acquiring the AT_HWCAP or |
| 20 | AT_HWCAP2 entry of the auxiliary vector, and testing whether the relevant |
Mauro Carvalho Chehab | b693d0b | 2019-06-12 14:52:38 -0300 | [diff] [blame] | 21 | flags are set, e.g.:: |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 22 | |
Mauro Carvalho Chehab | b693d0b | 2019-06-12 14:52:38 -0300 | [diff] [blame] | 23 | bool floating_point_is_present(void) |
| 24 | { |
| 25 | unsigned long hwcaps = getauxval(AT_HWCAP); |
| 26 | if (hwcaps & HWCAP_FP) |
| 27 | return true; |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 28 | |
Mauro Carvalho Chehab | b693d0b | 2019-06-12 14:52:38 -0300 | [diff] [blame] | 29 | return false; |
| 30 | } |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 31 | |
| 32 | Where software relies on a feature described by a hwcap, it should check |
| 33 | the relevant hwcap flag to verify that the feature is present before |
| 34 | attempting to make use of the feature. |
| 35 | |
| 36 | Features cannot be probed reliably through other means. When a feature |
| 37 | is not available, attempting to use it may result in unpredictable |
| 38 | behaviour, and is not guaranteed to result in any reliable indication |
| 39 | that the feature is unavailable, such as a SIGILL. |
| 40 | |
| 41 | |
| 42 | 2. Interpretation of hwcaps |
| 43 | --------------------------- |
| 44 | |
| 45 | The majority of hwcaps are intended to indicate the presence of features |
| 46 | which are described by architected ID registers inaccessible to |
| 47 | userspace code at EL0. These hwcaps are defined in terms of ID register |
| 48 | fields, and should be interpreted with reference to the definition of |
| 49 | these fields in the ARM Architecture Reference Manual (ARM ARM). |
| 50 | |
Mauro Carvalho Chehab | b693d0b | 2019-06-12 14:52:38 -0300 | [diff] [blame] | 51 | Such hwcaps are described below in the form:: |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 52 | |
| 53 | Functionality implied by idreg.field == val. |
| 54 | |
| 55 | Such hwcaps indicate the availability of functionality that the ARM ARM |
| 56 | defines as being present when idreg.field has value val, but do not |
| 57 | indicate that idreg.field is precisely equal to val, nor do they |
| 58 | indicate the absence of functionality implied by other values of |
| 59 | idreg.field. |
| 60 | |
| 61 | Other hwcaps may indicate the presence of features which cannot be |
| 62 | described by ID registers alone. These may be described without |
| 63 | reference to ID registers, and may refer to other documentation. |
| 64 | |
| 65 | |
| 66 | 3. The hwcaps exposed in AT_HWCAP |
| 67 | --------------------------------- |
| 68 | |
| 69 | HWCAP_FP |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 70 | Functionality implied by ID_AA64PFR0_EL1.FP == 0b0000. |
| 71 | |
| 72 | HWCAP_ASIMD |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 73 | Functionality implied by ID_AA64PFR0_EL1.AdvSIMD == 0b0000. |
| 74 | |
| 75 | HWCAP_EVTSTRM |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 76 | The generic timer is configured to generate events at a frequency of |
Catalin Marinas | 5d8505f | 2021-05-05 14:28:45 +0100 | [diff] [blame] | 77 | approximately 10KHz. |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 78 | |
| 79 | HWCAP_AES |
Giacomo Travaglini | 4bfbe5e | 2018-10-01 15:24:47 +0100 | [diff] [blame] | 80 | Functionality implied by ID_AA64ISAR0_EL1.AES == 0b0001. |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 81 | |
| 82 | HWCAP_PMULL |
Giacomo Travaglini | 4bfbe5e | 2018-10-01 15:24:47 +0100 | [diff] [blame] | 83 | Functionality implied by ID_AA64ISAR0_EL1.AES == 0b0010. |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 84 | |
| 85 | HWCAP_SHA1 |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 86 | Functionality implied by ID_AA64ISAR0_EL1.SHA1 == 0b0001. |
| 87 | |
| 88 | HWCAP_SHA2 |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 89 | Functionality implied by ID_AA64ISAR0_EL1.SHA2 == 0b0001. |
| 90 | |
| 91 | HWCAP_CRC32 |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 92 | Functionality implied by ID_AA64ISAR0_EL1.CRC32 == 0b0001. |
| 93 | |
| 94 | HWCAP_ATOMICS |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 95 | Functionality implied by ID_AA64ISAR0_EL1.Atomic == 0b0010. |
| 96 | |
| 97 | HWCAP_FPHP |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 98 | Functionality implied by ID_AA64PFR0_EL1.FP == 0b0001. |
| 99 | |
| 100 | HWCAP_ASIMDHP |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 101 | Functionality implied by ID_AA64PFR0_EL1.AdvSIMD == 0b0001. |
| 102 | |
| 103 | HWCAP_CPUID |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 104 | EL0 access to certain ID registers is available, to the extent |
Mauro Carvalho Chehab | b693d0b | 2019-06-12 14:52:38 -0300 | [diff] [blame] | 105 | described by Documentation/arm64/cpu-feature-registers.rst. |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 106 | |
| 107 | These ID registers may imply the availability of features. |
| 108 | |
| 109 | HWCAP_ASIMDRDM |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 110 | Functionality implied by ID_AA64ISAR0_EL1.RDM == 0b0001. |
| 111 | |
| 112 | HWCAP_JSCVT |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 113 | Functionality implied by ID_AA64ISAR1_EL1.JSCVT == 0b0001. |
| 114 | |
| 115 | HWCAP_FCMA |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 116 | Functionality implied by ID_AA64ISAR1_EL1.FCMA == 0b0001. |
| 117 | |
| 118 | HWCAP_LRCPC |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 119 | Functionality implied by ID_AA64ISAR1_EL1.LRCPC == 0b0001. |
| 120 | |
| 121 | HWCAP_DCPOP |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 122 | Functionality implied by ID_AA64ISAR1_EL1.DPB == 0b0001. |
| 123 | |
| 124 | HWCAP_SHA3 |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 125 | Functionality implied by ID_AA64ISAR0_EL1.SHA3 == 0b0001. |
| 126 | |
| 127 | HWCAP_SM3 |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 128 | Functionality implied by ID_AA64ISAR0_EL1.SM3 == 0b0001. |
| 129 | |
| 130 | HWCAP_SM4 |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 131 | Functionality implied by ID_AA64ISAR0_EL1.SM4 == 0b0001. |
| 132 | |
| 133 | HWCAP_ASIMDDP |
Mark Rutland | 611a7bc7 | 2017-10-11 14:01:03 +0100 | [diff] [blame] | 134 | Functionality implied by ID_AA64ISAR0_EL1.DP == 0b0001. |
| 135 | |
| 136 | HWCAP_SHA512 |
Giacomo Travaglini | 4bfbe5e | 2018-10-01 15:24:47 +0100 | [diff] [blame] | 137 | Functionality implied by ID_AA64ISAR0_EL1.SHA2 == 0b0010. |
Dave Martin | 43994d8 | 2017-10-31 15:51:19 +0000 | [diff] [blame] | 138 | |
| 139 | HWCAP_SVE |
Dave Martin | 43994d8 | 2017-10-31 15:51:19 +0000 | [diff] [blame] | 140 | Functionality implied by ID_AA64PFR0_EL1.SVE == 0b0001. |
Dongjiu Geng | 3b3b681 | 2017-12-13 18:13:56 +0800 | [diff] [blame] | 141 | |
Julien Grall | 3a25e46 | 2019-10-03 12:12:09 +0100 | [diff] [blame] | 142 | HWCAP_ASIMDFHM |
| 143 | Functionality implied by ID_AA64ISAR0_EL1.FHM == 0b0001. |
| 144 | |
| 145 | HWCAP_DIT |
| 146 | Functionality implied by ID_AA64PFR0_EL1.DIT == 0b0001. |
| 147 | |
| 148 | HWCAP_USCAT |
| 149 | Functionality implied by ID_AA64MMFR2_EL1.AT == 0b0001. |
| 150 | |
| 151 | HWCAP_ILRCPC |
| 152 | Functionality implied by ID_AA64ISAR1_EL1.LRCPC == 0b0010. |
| 153 | |
| 154 | HWCAP_FLAGM |
| 155 | Functionality implied by ID_AA64ISAR0_EL1.TS == 0b0001. |
| 156 | |
| 157 | HWCAP_SSBS |
| 158 | Functionality implied by ID_AA64PFR1_EL1.SSBS == 0b0010. |
| 159 | |
Julien Grall | 0f6e4c4 | 2019-10-03 12:12:10 +0100 | [diff] [blame] | 160 | HWCAP_SB |
| 161 | Functionality implied by ID_AA64ISAR1_EL1.SB == 0b0001. |
| 162 | |
Julien Grall | 3a25e46 | 2019-10-03 12:12:09 +0100 | [diff] [blame] | 163 | HWCAP_PACA |
| 164 | Functionality implied by ID_AA64ISAR1_EL1.APA == 0b0001 or |
| 165 | ID_AA64ISAR1_EL1.API == 0b0001, as described by |
| 166 | Documentation/arm64/pointer-authentication.rst. |
| 167 | |
| 168 | HWCAP_PACG |
| 169 | Functionality implied by ID_AA64ISAR1_EL1.GPA == 0b0001 or |
| 170 | ID_AA64ISAR1_EL1.GPI == 0b0001, as described by |
| 171 | Documentation/arm64/pointer-authentication.rst. |
| 172 | |
| 173 | HWCAP2_DCPODP |
| 174 | |
| 175 | Functionality implied by ID_AA64ISAR1_EL1.DPB == 0b0010. |
| 176 | |
Dave Martin | 06a916f | 2019-04-18 18:41:38 +0100 | [diff] [blame] | 177 | HWCAP2_SVE2 |
| 178 | |
| 179 | Functionality implied by ID_AA64ZFR0_EL1.SVEVer == 0b0001. |
| 180 | |
| 181 | HWCAP2_SVEAES |
| 182 | |
| 183 | Functionality implied by ID_AA64ZFR0_EL1.AES == 0b0001. |
| 184 | |
| 185 | HWCAP2_SVEPMULL |
| 186 | |
| 187 | Functionality implied by ID_AA64ZFR0_EL1.AES == 0b0010. |
| 188 | |
| 189 | HWCAP2_SVEBITPERM |
| 190 | |
| 191 | Functionality implied by ID_AA64ZFR0_EL1.BitPerm == 0b0001. |
| 192 | |
| 193 | HWCAP2_SVESHA3 |
| 194 | |
| 195 | Functionality implied by ID_AA64ZFR0_EL1.SHA3 == 0b0001. |
| 196 | |
| 197 | HWCAP2_SVESM4 |
| 198 | |
| 199 | Functionality implied by ID_AA64ZFR0_EL1.SM4 == 0b0001. |
| 200 | |
Mark Brown | 1201937 | 2019-06-18 19:10:54 +0100 | [diff] [blame] | 201 | HWCAP2_FLAGM2 |
| 202 | |
| 203 | Functionality implied by ID_AA64ISAR0_EL1.TS == 0b0010. |
| 204 | |
Mark Brown | ca9503f | 2019-06-18 19:10:55 +0100 | [diff] [blame] | 205 | HWCAP2_FRINT |
| 206 | |
| 207 | Functionality implied by ID_AA64ISAR1_EL1.FRINTTS == 0b0001. |
| 208 | |
Steven Price | d4209d8 | 2019-12-16 11:33:37 +0000 | [diff] [blame] | 209 | HWCAP2_SVEI8MM |
| 210 | |
| 211 | Functionality implied by ID_AA64ZFR0_EL1.I8MM == 0b0001. |
| 212 | |
| 213 | HWCAP2_SVEF32MM |
| 214 | |
| 215 | Functionality implied by ID_AA64ZFR0_EL1.F32MM == 0b0001. |
| 216 | |
| 217 | HWCAP2_SVEF64MM |
| 218 | |
| 219 | Functionality implied by ID_AA64ZFR0_EL1.F64MM == 0b0001. |
| 220 | |
| 221 | HWCAP2_SVEBF16 |
| 222 | |
| 223 | Functionality implied by ID_AA64ZFR0_EL1.BF16 == 0b0001. |
| 224 | |
| 225 | HWCAP2_I8MM |
| 226 | |
| 227 | Functionality implied by ID_AA64ISAR1_EL1.I8MM == 0b0001. |
| 228 | |
| 229 | HWCAP2_BF16 |
| 230 | |
| 231 | Functionality implied by ID_AA64ISAR1_EL1.BF16 == 0b0001. |
| 232 | |
| 233 | HWCAP2_DGH |
| 234 | |
| 235 | Functionality implied by ID_AA64ISAR1_EL1.DGH == 0b0001. |
Andrew Murray | aaba098 | 2019-04-09 10:52:40 +0100 | [diff] [blame] | 236 | |
Richard Henderson | 1a50ec0 | 2020-01-21 12:58:52 +0000 | [diff] [blame] | 237 | HWCAP2_RNG |
| 238 | |
| 239 | Functionality implied by ID_AA64ISAR0_EL1.RNDR == 0b0001. |
| 240 | |
Dave Martin | 8ef8f360 | 2020-03-16 16:50:45 +0000 | [diff] [blame] | 241 | HWCAP2_BTI |
| 242 | |
| 243 | Functionality implied by ID_AA64PFR0_EL1.BT == 0b0001. |
| 244 | |
Vincenzo Frascino | df9d7a2 | 2019-09-06 10:52:39 +0100 | [diff] [blame] | 245 | HWCAP2_MTE |
| 246 | |
| 247 | Functionality implied by ID_AA64PFR1_EL1.MTE == 0b0010, as described |
| 248 | by Documentation/arm64/memory-tagging-extension.rst. |
Dave Martin | 8ef8f360 | 2020-03-16 16:50:45 +0000 | [diff] [blame] | 249 | |
Marc Zyngier | fee29f0 | 2021-10-17 13:42:25 +0100 | [diff] [blame] | 250 | HWCAP2_ECV |
| 251 | |
| 252 | Functionality implied by ID_AA64MMFR0_EL1.ECV == 0b0001. |
| 253 | |
Joey Gouly | 5c13f04 | 2021-12-10 16:54:30 +0000 | [diff] [blame] | 254 | HWCAP2_AFP |
| 255 | |
| 256 | Functionality implied by ID_AA64MFR1_EL1.AFP == 0b0001. |
| 257 | |
Joey Gouly | 1175011 | 2021-12-10 16:54:32 +0000 | [diff] [blame] | 258 | HWCAP2_RPRES |
| 259 | |
| 260 | Functionality implied by ID_AA64ISAR2_EL1.RPRES == 0b0001. |
| 261 | |
Andrew Murray | aaba098 | 2019-04-09 10:52:40 +0100 | [diff] [blame] | 262 | 4. Unused AT_HWCAP bits |
| 263 | ----------------------- |
| 264 | |
| 265 | For interoperation with userspace, the kernel guarantees that bits 62 |
| 266 | and 63 of AT_HWCAP will always be returned as 0. |