1 /* $NetBSD: aarch64.c,v 1.41 2026/11/25 07:11:25 skrll Exp $ */ 2 3 /* 4 * Copyright (c) 2018 Ryo Shimizu 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #include <sys/cdefs.h> 30 31 #ifndef lint 32 __RCSID("$NetBSD: aarch64.c,v 1.41 2026/11/25 07:11:25 skrll Exp $"); 33 #endif /* no lint */ 34 35 #include <sys/types.h> 36 #include <sys/cpuio.h> 37 #include <sys/sysctl.h> 38 #include <stdio.h> 39 #include <stdbool.h> 40 #include <stdlib.h> 41 #include <string.h> 42 #include <inttypes.h> 43 #include <err.h> 44 45 #include <arm/cputypes.h> 46 #include <aarch64/armreg.h> 47 48 #include "../cpuctl.h" 49 50 struct cpuidtab { 51 uint32_t cpu_partnum; 52 const char *cpu_name; 53 const char *cpu_class; 54 const char *cpu_architecture; 55 }; 56 57 struct impltab { 58 uint32_t impl_id; 59 const char *impl_name; 60 }; 61 62 struct fieldinfo { 63 unsigned int flags; 64 #define FIELDINFO_FLAGS_DEC 0x0001 65 #define FIELDINFO_FLAGS_4LOG2 0x0002 66 unsigned char bitpos; 67 unsigned char bitwidth; 68 const char *name; 69 const char * const *info; 70 }; 71 72 73 #define CPU_PARTMASK (CPU_ID_IMPLEMENTOR_MASK | CPU_ID_PARTNO_MASK) 74 const struct cpuidtab cpuids[] = { 75 { CPU_ID_CORTEXA35R0 & CPU_PARTMASK, "Cortex-A35", "Arm", "v8-A" }, 76 { CPU_ID_CORTEXA53R0 & CPU_PARTMASK, "Cortex-A53", "Arm", "v8-A" }, 77 { CPU_ID_CORTEXA57R0 & CPU_PARTMASK, "Cortex-A57", "Arm", "v8-A" }, 78 { CPU_ID_CORTEXA55R1 & CPU_PARTMASK, "Cortex-A55", "Arm", "v8.2-A+" }, 79 { CPU_ID_CORTEXA65R0 & CPU_PARTMASK, "Cortex-A65", "Arm", "v8.2-A+" }, 80 { CPU_ID_CORTEXA72R0 & CPU_PARTMASK, "Cortex-A72", "Arm", "v8-A" }, 81 { CPU_ID_CORTEXA73R0 & CPU_PARTMASK, "Cortex-A73", "Arm", "v8-A" }, 82 { CPU_ID_CORTEXA75R2 & CPU_PARTMASK, "Cortex-A75", "Arm", "v8.2-A+" }, 83 { CPU_ID_CORTEXA76R3 & CPU_PARTMASK, "Cortex-A76", "Arm", "v8.2-A+" }, 84 { CPU_ID_CORTEXA76AER1 & CPU_PARTMASK, "Cortex-A76AE", "Arm", "v8.2-A+" }, 85 { CPU_ID_CORTEXA77R0 & CPU_PARTMASK, "Cortex-A77", "Arm", "v8.2-A+" }, 86 { CPU_ID_CORTEXA520R0 & CPU_PARTMASK, "Cortex-A520", "Arm", "v9.2-A" }, 87 { CPU_ID_CORTEXA710R2 & CPU_PARTMASK, "Cortex-A710", "Arm", "v9.0-A" }, 88 { CPU_ID_CORTEXA720R0 & CPU_PARTMASK, "Cortex-A720", "Arm", "v9.2-A" }, 89 { CPU_ID_NVIDIADENVER2 & CPU_PARTMASK, "Denver2", "NVIDIA", "v8-A" }, 90 { CPU_ID_EMAG8180 & CPU_PARTMASK, "eMAG", "Ampere", "v8-A" }, 91 { CPU_ID_NEOVERSEE1R1 & CPU_PARTMASK, "Neoverse E1", "Arm", "v8.2-A+" }, 92 { CPU_ID_NEOVERSEN1R3 & CPU_PARTMASK, "Neoverse N1", "Arm", "v8.2-A+" }, 93 { CPU_ID_NEOVERSEV1R1 & CPU_PARTMASK, "Neoverse V1", "Arm", "v8.4-A+" }, 94 { CPU_ID_NEOVERSEN2R0 & CPU_PARTMASK, "Neoverse N2", "Arm", "v9.0-A" }, 95 { CPU_ID_THUNDERXRX, "ThunderX", "Cavium", "v8-A" }, 96 { CPU_ID_THUNDERX81XXRX, "ThunderX CN81XX", "Cavium", "v8-A" }, 97 { CPU_ID_THUNDERX83XXRX, "ThunderX CN83XX", "Cavium", "v8-A" }, 98 { CPU_ID_THUNDERX2RX, "ThunderX2", "Marvell", "v8.1-A" }, 99 { CPU_ID_APPLE_M1_ICESTORM & CPU_PARTMASK, "M1 Icestorm", "Apple", "Apple Silicon" }, 100 { CPU_ID_APPLE_M1_FIRESTORM & CPU_PARTMASK, "M1 Firestorm", "Apple", "Apple Silicon" }, 101 { CPU_ID_AMPERE1 & CPU_PARTMASK, "Ampere-1", "Ampere", "v8.6-A+" }, 102 { CPU_ID_AMPERE1A & CPU_PARTMASK, "Ampere-1A", "Ampere", "v8.6-A+" }, 103 { CPU_ID_A64FX & CPU_PARTMASK, "A64FX", "Fujitsu", "v8.2-A+" }, 104 { CPU_ID_ORYON & CPU_PARTMASK, "Oryon", "Qualcomm", "v8.7-A+" }, 105 }; 106 107 const struct impltab implids[] = { 108 { CPU_ID_ARM_LTD, "ARM Limited" }, 109 { CPU_ID_BROADCOM, "Broadcom Corporation" }, 110 { CPU_ID_CAVIUM, "Cavium Inc." }, 111 { CPU_ID_DEC, "Digital Equipment Corporation" }, 112 { CPU_ID_FUJITSU, "Fujitsu Ltd." }, 113 { CPU_ID_INFINEON, "Infineon Technologies AG" }, 114 { CPU_ID_MOTOROLA, "Motorola or Freescale Semiconductor Inc." }, 115 { CPU_ID_NVIDIA, "NVIDIA Corporation" }, 116 { CPU_ID_APM, "Applied Micro Circuits Corporation" }, 117 { CPU_ID_QUALCOMM, "Qualcomm Inc." }, 118 { CPU_ID_SAMSUNG, "SAMSUNG" }, 119 { CPU_ID_TI, "Texas Instruments" }, 120 { CPU_ID_MARVELL, "Marvell International Ltd." }, 121 { CPU_ID_APPLE, "Apple Inc." }, 122 { CPU_ID_FARADAY, "Faraday Technology Corporation" }, 123 { CPU_ID_INTEL, "Intel Corporation" }, 124 { CPU_ID_AMPERE, "Ampere" }, 125 }; 126 127 #define FIELDNAME(_bitpos, _bitwidth, _name) \ 128 .bitpos = _bitpos, \ 129 .bitwidth = _bitwidth, \ 130 .name = _name 131 132 #define FIELDINFO(_bitpos, _bitwidth, _name) \ 133 FIELDNAME(_bitpos, _bitwidth, _name), \ 134 .info = (const char *[1 << _bitwidth]) 135 136 137 /* ID_AA64PFR0_EL1 - AArch64 Processor Feature Register 0 */ 138 struct fieldinfo id_aa64pfr0_fieldinfo[] = { 139 { 140 FIELDINFO(0, 4, "EL0") { 141 [0] = "No EL0", 142 [1] = "AArch64", 143 [2] = "AArch64/AArch32", 144 } 145 }, 146 { 147 FIELDINFO(4, 4, "EL1") { 148 [0] = "No EL1", 149 [1] = "AArch64", 150 [2] = "AArch64/AArch32", 151 } 152 }, 153 { 154 FIELDINFO(8, 4, "EL2") { 155 [0] = "No EL2", 156 [1] = "AArch64", 157 [2] = "AArch64/AArch32", 158 } 159 }, 160 { 161 FIELDINFO(12, 4, "EL3") { 162 [0] = "No EL3", 163 [1] = "AArch64", 164 [2] = "AArch64/AArch32", 165 } 166 }, 167 { 168 FIELDINFO(16, 4, "FP") { 169 [0] = "Floating Point", 170 [1] = "Floating Point including half-precision support", 171 [15] = "No Floating Point" 172 } 173 }, 174 { 175 FIELDINFO(20, 4, "AdvSIMD") { 176 [0] = "Advanced SIMD", 177 [1] = "Advanced SIMD including half-precision support", 178 [15] = "No Advanced SIMD" 179 } 180 }, 181 { 182 FIELDINFO(24, 4, "GIC") { 183 [0] = "GIC CPU interface sysregs not implemented", 184 [1] = "GIC CPU interface sysregs v3.0/4.0 supported", 185 [3] = "GIC CPU interface sysregs v4.1 supported", 186 } 187 }, 188 { 189 FIELDINFO(28, 4, "RAS") { 190 [0] = "Reliability/Availability/Serviceability not supported", 191 [1] = "Reliability/Availability/Serviceability supported", 192 [2] = "Reliability/Availability/Serviceability Armv8.4 supported", 193 [3] = "Reliability/Availability/Serviceability Armv8.9 supported (FEAT_RASv2)", 194 }, 195 }, 196 { 197 FIELDINFO(32, 4, "SVE") { 198 [0] = "Scalable Vector Extensions not implemented", 199 [1] = "Scalable Vector Extensions implemented", 200 }, 201 }, 202 { 203 FIELDINFO(36, 4, "SEL2") { 204 [0] = "Secure EL2 not implemented", 205 [1] = "Secure EL2 implemented", 206 }, 207 }, 208 { 209 FIELDINFO(40, 4, "MPAM") { 210 [0] = "Memory Partitioning and Monitoring not implemented", 211 [1] = "Memory Partitioning and Monitoring implemented", 212 }, 213 }, 214 { 215 FIELDINFO(44, 4, "AMU") { 216 [0] = "Activity Monitors Extension not implemented", 217 [1] = "Activity Monitors Extension v1 Armv8.4", 218 [2] = "Activity Monitors Extension v1 Armv8.6", 219 }, 220 }, 221 { 222 FIELDINFO(48, 4, "DIT") { 223 [0] = "No Data-Independent Timing guarantees", 224 [1] = "Data-Independent Timing guaranteed by PSTATE.DIT", 225 }, 226 }, 227 { 228 FIELDINFO(52, 4, "RME") { 229 [0] = "Realm Management Extension not implemented.", 230 [1] = "RMEv1 is implemented.", 231 [2] = "RMEv1+GPC2 is implemented.", 232 [3] = "RMEv1+GPC2+GPC3 is implemented.", 233 } 234 }, 235 { 236 FIELDINFO(56, 4, "CSV2") { 237 [0] = "Branch prediction might be Spectred", 238 [1] = "Branch prediction maybe not Spectred", 239 [2] = "Branch prediction probably not Spectred", 240 }, 241 }, 242 { 243 FIELDINFO(60, 4, "CSV3") { 244 [0] = "Faults might be Spectred", 245 [1] = "Faults maybe not Spectred", 246 [2] = "Faults probably not Spectred", 247 }, 248 }, 249 { .bitwidth = 0 } /* end of table */ 250 }; 251 252 /* ID_AA64PFR1_EL1 - AArch64 Processor Feature Register 1 */ 253 struct fieldinfo id_aa64pfr1_fieldinfo[] = { 254 { 255 FIELDINFO(0, 4, "BT") { 256 [0] = "Branch Target Identification not implemented", 257 [1] = "Branch Target Identification implemented", 258 } 259 }, 260 { 261 FIELDINFO(4, 4, "SSBS") { 262 [0] = "Speculative Store Bypassing control not implemented", 263 [1] = "Speculative Store Bypassing control implemented", 264 [2] = "Speculative Store Bypassing control implemented, plus MSR/MRS", 265 } 266 }, 267 { 268 FIELDINFO(8, 4, "MTE") { 269 [0] = "Memory Tagging Extension not implemented", 270 [1] = "Instruction-only Memory Taggined Extension " 271 "implemented", 272 [2] = "Full Memory Tagging Extension implemented", 273 [3] = "Memory Tagging Extension implemented " 274 "with Tag Check Fault handling", 275 } 276 }, 277 { 278 FIELDINFO(12, 4, "RAS_frac") { 279 [0] = "Regular RAS", 280 [1] = "RAS plus registers", 281 } 282 }, 283 { 284 FIELDINFO(16, 4, "MPAM_frac") { 285 [0] = "MPAM not implemented, or v1.0", 286 [1] = "MPAM v0.1 or v1.1", 287 } 288 }, 289 { 290 FIELDINFO(24, 4, "SME") { 291 [0] = "SME architectural state and programmers' model are not implemented.", 292 [1] = "SME architectural state and programmers' model are implemented.", 293 [2] = "SME architectural state and programmers' model are implemented, plus ZT0 (FEAT_SME2).", 294 } 295 }, 296 { 297 FIELDINFO(28, 4, "RNDR_trap") { 298 [0] = "Trapping of RNDR and RNDRRS to EL3 is not supported.", 299 [1] = "Trapping of RNDR and RNDRRS to EL3 is supported. SCR_EL3.TRNDR is present.", 300 } 301 }, 302 { 303 FIELDINFO(32, 4, "CSV2_frac") { 304 [0] = "not disclosed", 305 [1] = "SCXTNUM_ELx registers not supported", 306 [2] = "SCXTNUM_ELx registers supported", 307 } 308 }, 309 { 310 FIELDINFO(36, 4, "NMI") { 311 [0] = "NMI not supported.", 312 [1] = "NMI supported.", 313 } 314 }, 315 { 316 FIELDINFO(40, 4, "MTE_frac") { 317 [0] = "Asynchronous reporting of a Tag Check Fault is supported.", 318 [15] = "Asynchronous reporting of a Tag Check Fault is not supported.", 319 } 320 }, 321 { 322 FIELDINFO(44, 4, "GCS") { 323 [0] = "Guarded Control Stack is not implemented.", 324 [1] = "Guarded Control Stack is implemented.", 325 } 326 }, 327 { 328 FIELDINFO(48, 4, "THE") { 329 [0] = "Translation Hardening Extension is not implemented.", 330 [1] = "Translation Hardening Extension (and RCW/RCWS) is implemented.", 331 } 332 }, 333 { 334 FIELDINFO(52, 4, "MTEX") { 335 [0] = "Canonical Tag checking and Memory tagging with Address tagging disabled are not supported. (FEAT_MTE2)", 336 [1] = "Canonical Tag checking and Memory tagging with Address tagging disabled are supported. (FEAT_MTE2)", 337 } 338 }, 339 { 340 FIELDINFO(56, 4, "DF2") { 341 [0] = "FEAT_DoubleFault2 is not implemented.", 342 [1] = "FEAT_DoubleFault2 is implemented.", 343 } 344 }, 345 { 346 FIELDINFO(60, 4, "PFAR") { 347 [0] = "Physical fault address registers are not implemented. (FEAT_PFAR)", 348 [1] = "Physical fault address registers are implemented. (FEAT_PFAR)", 349 } 350 }, 351 { .bitwidth = 0 } /* end of table */ 352 }; 353 354 /* ID_AA64ISAR0_EL1 - AArch64 Instruction Set Attribute Register 0 */ 355 struct fieldinfo id_aa64isar0_fieldinfo[] = { 356 { 357 FIELDINFO(4, 4, "AES") { 358 [0] = "No AES", 359 [1] = "AESE/AESD/AESMC/AESIMC", 360 [2] = "AESE/AESD/AESMC/AESIMC+PMULL/PMULL2", 361 } 362 }, 363 { 364 FIELDINFO(8, 4, "SHA1") { 365 [0] = "No SHA1", 366 [1] = "SHA1C/SHA1P/SHA1M/SHA1H/SHA1SU0/SHA1SU1", 367 } 368 }, 369 { 370 FIELDINFO(12, 4, "SHA2") { 371 [0] = "No SHA2", 372 [1] = "SHA256H/SHA256H2/SHA256SU0/SHA256SU1", 373 [2] = "SHA256H/SHA256H2/SHA256SU0/SHA256SU1/" 374 "SHA512H/SHA512H2/SHA512SU0/SHA512SU1", 375 } 376 }, 377 { 378 FIELDINFO(16, 4, "CRC32") { 379 [0] = "No CRC32", 380 [1] = "CRC32B/CRC32H/CRC32W/CRC32X/" 381 "CRC32CB/CRC32CH/CRC32CW/CRC32CX", 382 } 383 }, 384 { 385 FIELDINFO(20, 4, "Atomic") { 386 [0] = "No Atomic", 387 [2] = "LDADD/LDCLR/LDEOR/LDSET/LDSMAX/LDSMIN/" 388 "LDUMAX/LDUMIN/CAS/CASP/SWP", 389 [3] = "LDADD/LDCLR/LDEOR/LDSET/LDSMAX/LDSMIN/" 390 "LDUMAX/LDUMIN/CAS/CASP/SWP+" 391 "LDCLRP/LDSETP/SWPP.", 392 } 393 }, 394 { 395 FIELDINFO(28, 4, "RDM") { 396 [0] = "No RDMA", 397 [1] = "SQRDMLAH/SQRDMLSH", 398 } 399 }, 400 { 401 FIELDINFO(32, 4, "SHA3") { 402 [0] = "No SHA3", 403 [1] = "EOR3/RAX1/XAR/BCAX", 404 } 405 }, 406 { 407 FIELDINFO(36, 4, "SM3") { 408 [0] = "No SM3", 409 [1] = "SM3SS1/SM3TT1A/SM3TT1B/SM3TT2A/SM3TT2B/" 410 "SM3PARTW1/SM3PARTW2", 411 } 412 }, 413 { 414 FIELDINFO(40, 4, "SM4") { 415 [0] = "No SM4", 416 [1] = "SM4E/SM4EKEY", 417 } 418 }, 419 { 420 FIELDINFO(44, 4, "DP") { 421 [0] = "No Dot Product", 422 [1] = "UDOT/SDOT", 423 } 424 }, 425 { 426 FIELDINFO(48, 4, "FHM") { 427 [0] = "No FHM", 428 [1] = "FMLAL/FMLSL", 429 } 430 }, 431 { 432 FIELDINFO(52, 4, "TS") { 433 [0] = "No TS", 434 [1] = "CFINV/RMIF/SETF16/SETF8", 435 [2] = "CFINV/RMIF/SETF16/SETF8/AXFLAG/XAFLAG", 436 } 437 }, 438 { 439 FIELDINFO(56, 4, "TLB") { 440 [0] = "No outer shareable and TLB range maintenance " 441 "instructions", 442 [1] = "Outer shareable TLB maintenance instructions", 443 [2] = "Outer shareable and TLB range maintenance " 444 "instructions", 445 } 446 }, 447 { 448 FIELDINFO(60, 4, "RNDR") { 449 [0] = "No RNDR/RNDRRS", 450 [1] = "RNDR/RNDRRS", 451 }, 452 }, 453 { .bitwidth = 0 } /* end of table */ 454 }; 455 456 /* ID_AA64ISAR1_EL1 - AArch64 Instruction Set Attribute Register 1 */ 457 struct fieldinfo id_aa64isar1_fieldinfo[] = { 458 { 459 FIELDINFO(0, 4, "DPB") { 460 [0] = "No DC CVAP", 461 [1] = "DC CVAP", 462 [2] = "DC CVAP/DC CVADP", 463 } 464 }, 465 { 466 FIELDINFO(4, 4, "APA") { 467 [0] = "No Architected Address Authentication algorithm", 468 [1] = "QARMA with PAC", 469 [2] = "QARMA with EnhancedPAC", 470 [3] = "QARMA with EnhancedPAC2", 471 [4] = "QARMA with EnhancedPAC/PAC2", 472 [5] = "QARMA with EnhancedPAC/PAC2/FPACCombined", 473 [6] = "QARMA with EnhancedPAC/PAC2/FPACCombined/PAuthLR", 474 } 475 }, 476 { 477 FIELDINFO(8, 4, "API") { 478 [0] = "No Address Authentication algorithm", 479 [1] = "Address Authentication algorithm implemented", 480 [2] = "EnhancedPAC", 481 [3] = "EnhancedPAC2", 482 [4] = "EnhancedPAC2/FPAC", 483 [5] = "EnhancedPAC2/FPAC/FPACCombined", 484 [6] = "EnhancedPAC2/FPAC/FPACCombined/PAuthLR", 485 } 486 }, 487 { 488 FIELDINFO(12, 4, "JSCVT") { 489 [0] = "No FJCVTZS", 490 [1] = "FJCVTZS", 491 } 492 }, 493 { 494 FIELDINFO(16, 4, "FCMA") { 495 [0] = "No FCMA", 496 [1] = "FCMLA/FCADD", 497 } 498 }, 499 { 500 FIELDINFO(20, 4, "LRCPC") { 501 [0] = "no LRCPC", 502 [1] = "LDAPR{,B,H}", 503 [2] = "LDAPR{,B,H}+LDAPUR{,B,SB,H,SH,SW}/STUR{,B,H}", 504 [3] = "LDAPR{,B,H}/LDAPUR{,B,SB,H,SH,SW}/STUR{,B,H} + " 505 "post-index LDAPR, LDIAPP, STILP, pre-index STLR, etc" 506 } 507 }, 508 { 509 FIELDINFO(24, 4, "GPA") { 510 [0] = "No Architected Generic Authentication algorithm", 511 [1] = "QARMA with PACGA", 512 } 513 }, 514 { 515 FIELDINFO(28, 4, "GPI") { 516 [0] = "No Generic Authentication algorithm", 517 [1] = "Generic Authentication algorithm implemented", 518 } 519 }, 520 { 521 FIELDINFO(32, 4, "FRINTTS") { 522 [0] = "No FRINTTS", 523 [1] = "FRINT32Z/FRINT32X/FRINT64Z/FRINT64X", 524 } 525 }, 526 { 527 FIELDINFO(36, 4, "SB") { 528 [0] = "No SB", 529 [1] = "SB", 530 } 531 }, 532 { 533 FIELDINFO(40, 4, "SPECRES") { 534 [0] = "No SPECRES", 535 [1] = "CFP RCTX/DVP RCTX/CPP RCTX", 536 [2] = "CFP RCTX/DVP RCTX/CPP RCTX+COSP RCTX", 537 } 538 }, 539 { 540 FIELDINFO(44, 4, "BF16") { 541 [0] = "No BFloat16", 542 [1] = "BFCVT/BFCVTN/BFCVTN2/BFDOT/" 543 "BFMLALB/BFMLALT/BFMMLA", 544 [2] = "BFCVT/BFCVTN/BFCVTN2/BFDOT/" 545 "BFMLALB/BFMLALT/BFMMLA+", 546 "FPCR.EBF", 547 } 548 }, 549 { 550 FIELDINFO(48, 4, "DGH") { 551 [0] = "Data Gathering Hint not implemented", 552 [1] = "Data Gathering Hint implemented", 553 } 554 }, 555 { 556 FIELDINFO(52, 4, "I8MM") { 557 [0] = "No Int8 matrix", 558 [1] = "SMMLA/SUDOT/UMMLA/USMMLA/USDOT", 559 } 560 }, 561 { 562 FIELDINFO(56, 4, "XS") { 563 [0] = "No XS/nXS qualifier", 564 [1] = "XS attribute, TLBI and DSB " 565 "with nXS qualifier supported", 566 } 567 }, 568 { 569 FIELDINFO(60, 4, "LS64") { 570 [0] = "No LS64", 571 [1] = "LD64B/ST64B", 572 [2] = "LD64B/ST64B/ST64BV", 573 [3] = "LD64B/ST64B/ST64BV/ST64BV0/ACCDATA_EL1", 574 [4] = "LD64B/ST64B/ST64BV/ST64BV0/ACCDATA_EL1 + " 575 "atomic accesses to Write-back Cacheable, Shareable memory." 576 } 577 }, 578 { .bitwidth = 0 } /* end of table */ 579 }; 580 581 /* ID_AA64MMFR0_EL1 - AArch64 Memory Model Feature Register 0 */ 582 struct fieldinfo id_aa64mmfr0_fieldinfo[] = { 583 { 584 FIELDINFO(0, 4, "PARange") { 585 [0] = "32bits/4GB", 586 [1] = "36bits/64GB", 587 [2] = "40bits/1TB", 588 [3] = "42bits/4TB", 589 [4] = "44bits/16TB", 590 [5] = "48bits/256TB", 591 [6] = "52bits/4PB", 592 [7] = "56bits/64PB", 593 } 594 }, 595 { 596 FIELDINFO(4, 4, "ASIDBit") { 597 [0] = "8bits", 598 [2] = "16bits", 599 } 600 }, 601 { 602 FIELDINFO(8, 4, "BigEnd") { 603 [0] = "No mixed-endian", 604 [1] = "Mixed-endian", 605 } 606 }, 607 { 608 FIELDINFO(12, 4, "SNSMem") { 609 [0] = "No distinction B/W Secure and Non-secure Memory", 610 [1] = "Distinction B/W Secure and Non-secure Memory", 611 } 612 }, 613 { 614 FIELDINFO(16, 4, "BigEndEL0") { 615 [0] = "No mixed-endian at EL0", 616 [1] = "Mixed-endian at EL0", 617 } 618 }, 619 { 620 FIELDINFO(20, 4, "TGran16") { 621 [0] = "No 16KB granule", 622 [1] = "16KB granule", 623 [2] = "16KB granule/52-bit (FEAT_LPA2).", 624 } 625 }, 626 { 627 FIELDINFO(24, 4, "TGran64") { 628 [0] = "64KB granule", 629 [15] = "No 64KB granule" 630 } 631 }, 632 { 633 FIELDINFO(28, 4, "TGran4") { 634 [0] = "4KB granule", 635 [1] = "4KB granule/52-bit (FEAT_LPA2).", 636 [15] = "No 4KB granule" 637 } 638 }, 639 { 640 FIELDINFO(32, 4, "TGran16_2") { 641 [0] = "same as TGran16", 642 [1] = "No 16KB granule at stage2", 643 [2] = "16KB granule at stage2", 644 [3] = "16KB granule at stage2/52bit (FEAT_LPA2)", 645 } 646 }, 647 { 648 FIELDINFO(36, 4, "TGran64_2") { 649 [0] = "same as TGran64", 650 [1] = "No 64KB granule at stage2", 651 [2] = "64KB granule at stage2", 652 } 653 }, 654 { 655 FIELDINFO(40, 4, "TGran4_2") { 656 [0] = "same as TGran4", 657 [1] = "No 4KB granule at stage2", 658 [2] = "4KB granule at stage2", 659 [3] = "4KB granule at stage2/52-bit (FEAT_LPA2).", 660 } 661 }, 662 { 663 FIELDINFO(44, 4, "ExS") { 664 [0] = "All Exception entries and exits are context " 665 "synchronization events", 666 [1] = "Non-context synchronizing exception entry and " 667 "exit are supported", 668 } 669 }, 670 { 671 FIELDINFO(56, 4, "FGT") { 672 [0] = "fine-grained trap controls not implemented", 673 [1] = "fine-grained trap controls implemented", 674 } 675 }, 676 { 677 FIELDINFO(60, 4, "ECV") { 678 [0] = "Enhanced Counter Virtualization not implemented", 679 [1] = "Enhanced Counter Virtualization implemented", 680 [2] = "Enhanced Counter Virtualization + " 681 "CNTHCTL_EL2.ECV/CNTPOFF_EL2 implemented", 682 } 683 }, 684 685 { .bitwidth = 0 } /* end of table */ 686 }; 687 688 /* ID_AA64MMFR1_EL1 - AArch64 Memory Model Feature Register 1 */ 689 struct fieldinfo id_aa64mmfr1_fieldinfo[] = { 690 { 691 FIELDINFO(0, 4, "HAFDBS") { 692 [0] = "Access and Dirty flags not supported", 693 [1] = "Access flag supported", 694 [2] = "Access and Dirty flags supported", 695 [3] = "Access and Dirty flags supported + " 696 "Access for table descriptors.", 697 [4] = "Access and Dirty flags supported / " 698 "Access for table descriptors + " 699 "hardware tracking of Dirty state Structure.", 700 } 701 }, 702 { 703 FIELDINFO(4, 4, "VMIDBits") { 704 [0] = "8bits", 705 [2] = "16bits", 706 } 707 }, 708 { 709 FIELDINFO(8, 4, "VH") { 710 [0] = "Virtualization Host Extensions not supported", 711 [1] = "Virtualization Host Extensions supported", 712 } 713 }, 714 { 715 FIELDINFO(12, 4, "HPDS") { 716 [0] = "Disabling of hierarchical controls not supported", 717 [1] = "Disabling of hierarchical controls supported", 718 [2] = "Disabling of hierarchical controls supported, plus PTD", 719 } 720 }, 721 { 722 FIELDINFO(16, 4, "LO") { 723 [0] = "LORegions not supported", 724 [1] = "LORegions supported", 725 } 726 }, 727 { 728 FIELDINFO(20, 4, "PAN") { 729 [0] = "PAN not supported", 730 [1] = "PAN supported", 731 [2] = "PAN supported, and instructions supported", 732 [3] = "PAN supported, instructions supported" 733 ", and SCTLR_EL[12].EPAN bits supported", 734 } 735 }, 736 { 737 FIELDINFO(24, 4, "SpecSEI") { 738 [0] = "SError interrupt not supported", 739 [1] = "SError interrupt supported", 740 } 741 }, 742 { 743 FIELDINFO(28, 4, "XNX") { 744 [0] = "Distinction between EL0 and EL1 XN control " 745 "at stage2 not supported", 746 [1] = "Distinction between EL0 and EL1 XN control " 747 "at stage2 supported", 748 } 749 }, 750 { 751 FIELDINFO(32, 4, "TWED") { 752 [0] = "Configurable delayed trapping of WFE is not " 753 "supported", 754 [1] = "Configurable delayed trapping of WFE supported", 755 } 756 }, 757 { 758 FIELDINFO(36, 4, "ETS") { 759 [0] = "Enhanced Translation Synchronization not " 760 "supported", 761 [1] = "Enhanced Translation Synchronization not " 762 "supported", 763 [2] = "Enhanced Translation Synchronization supported. (FEAT_ETS2)", 764 [3] = "Enhanced Translation Synchronization supported. (FEAT_ETS3).", 765 } 766 }, 767 { 768 FIELDINFO(40, 4, "HCX") { 769 [0] = "HCRX_EL2 not supported", 770 [1] = "HCRX_EL2 supported", 771 } 772 }, 773 { 774 FIELDINFO(44, 4, "AFP") { 775 [0] = "FPCR.{AH,FIZ,NEP} fields not supported", 776 [1] = "FPCR.{AH,FIZ,NEP} fields supported", 777 } 778 }, 779 { 780 FIELDINFO(48, 4, "nTLBPA") { 781 [0] = "might include non-coherent caches", 782 [1] = "does not include non-coherent caches", 783 } 784 }, 785 { 786 FIELDINFO(52, 4, "TIDCP1") { 787 [0] = "Trapping control of implementation defined accesses not supported.", 788 [1] = "Trapping control of implementation defined accesses supported. (FEAT_TIDCP1)", 789 } 790 }, 791 { 792 FIELDINFO(56, 4, "CMOW") { 793 [0] = "Control for cache maintenance permission not supported.", 794 [1] = "Control for cache maintenance permission supported. (FEAT_CMOW)", 795 } 796 }, 797 { 798 FIELDINFO(60, 4, "ECBHB") { 799 [0] = "Exploitative control using branch history information not supported.", 800 [1] = "Exploitative control using branch history information is supported. (FEAT_ECBHB)", 801 } 802 }, 803 { .bitwidth = 0 } /* end of table */ 804 }; 805 806 /* ID_AA64DFR0_EL1 - AArch64 Debug Feature Register 0 */ 807 struct fieldinfo id_aa64dfr0_fieldinfo[] = { 808 { 809 FIELDINFO(0, 4, "DebugVer") { 810 [6] = "Armv8 debug architecture", 811 [7] = "Armv8 debug architecture " 812 "with Virtualization Host Extensions", 813 [8] = "Armv8.2 debug architecture", 814 [9] = "Armv8.4 debug architecture", 815 [10] = "Armv8.8 debug architecture", 816 [11] = "Armv8.9 debug architecture", 817 } 818 }, 819 { 820 FIELDINFO(4, 4, "TraceVer") { 821 [0] = "Trace supported", 822 [1] = "Trace not supported", 823 } 824 }, 825 { 826 FIELDINFO(8, 4, "PMUVer") { 827 [0] = "No Performance monitor", 828 [1] = "Performance monitor unit v3", 829 [4] = "Performance monitor unit v3 for Armv8.1", 830 [5] = "Performance monitor unit v3 for Armv8.4", 831 [6] = "Performance monitor unit v3 for Armv8.5", 832 [7] = "Performance monitor unit v3 for Armv8.7", 833 [8] = "Performance monitor unit v3 for Armv8.8", 834 [9] = "Performance monitor unit v3 for Armv8.9", 835 [15] = "implementation defined" 836 } 837 }, 838 // FIELDINFO(12, 4, "BRPs") special handling 839 { 840 FIELDINFO(16, 4, "PMSS") { 841 [0] = "PMU snapshot extension not implemented.", 842 [1] = "PMU snapshot extension implemented.", 843 } 844 }, 845 // FIELDINFO(20, 4, "WRPs") special handling 846 // FIELDINFO(28, 4, "CTX_CMPs") special handling 847 { 848 FIELDINFO(32, 4, "PMSVer") { 849 [0] = "Statistical Profiling Extension not implemented", 850 [1] = "Statistical Profiling Extension implemented", 851 [2] = "Statistical Profiling Extension for Armv8.5", 852 [3] = "Statistical Profiling Extension for Armv8.7", 853 [4] = "Statistical Profiling Extension for Armv8.8", 854 [5] = "Statistical Profiling Extension for Armv8.9", 855 [6] = "Statistical Profiling Extension for Armv9.6", 856 } 857 }, 858 { 859 FIELDINFO(36, 4, "DoubleLock") { 860 [0] = "OS Double Lock implemented", 861 [1] = "OS Double Lock not implemented", 862 } 863 }, 864 { 865 FIELDINFO(40, 4, "TraceFilt") { 866 [0] = "Armv8.4 Self-hosted Trace Extension not " 867 "implemented", 868 [1] = "Armv8.4 Self-hosted Trace Extension implemented", 869 } 870 }, 871 { 872 FIELDINFO(44, 4, "TraceBuffer") { 873 [0] = "Trace Buffer Extension not implemented.", 874 [1] = "Trace Buffer Extension implemented. (FEAT_TRBE)", 875 [2] = "Trace Buffer Extension implemented. (FEAT_TRBEv1p1)", 876 } 877 }, 878 { 879 FIELDINFO(48, 4, "MTPMU") { 880 [0] = "Multi-threaded PMU extension not implemented, " 881 "or implementation defined", 882 [1] = "Multi-threaded PMU extension implemented", 883 [15] = "Multi-threaded PMU extension not implemented" 884 } 885 }, 886 { 887 FIELDINFO(52, 4, "BRBE") { 888 [0] = "Branch Record Buffer Extension not implemented.", 889 [1] = "Branch Record Buffer Extension implemented. (FEAT_BRBE)", 890 [2] = "Branch Record Buffer Extension implemented. (FEAT_BRBEv1p1)", 891 } 892 }, 893 { 894 FIELDINFO(56, 4, "ExtTrcBuff") { 895 [0] = "Trace Buffer External Mode not implemented.", 896 [1] = "Trace Buffer External Mode implemented. (FEAT_TRBE_EXT)", 897 } 898 }, 899 { 900 FIELDINFO(60, 4, "HPMN0") { 901 [0] = "Zero PMU event counters for a Guest operating system not implemented.", 902 [1] = "Zero PMU event counters for a Guest operating system implemented. (FEAT_HPMN0)", 903 } 904 }, 905 { .bitwidth = 0 } /* end of table */ 906 }; 907 908 909 /* MVFR0_EL1 - Media and VFP Feature Register 0 */ 910 struct fieldinfo mvfr0_fieldinfo[] = { 911 { 912 FIELDINFO(0, 4, "SIMDreg") { 913 [0] = "No SIMD", 914 [1] = "16x64-bit SIMD", 915 [2] = "32x64-bit SIMD", 916 } 917 }, 918 { 919 FIELDINFO(4, 4, "FPSP") { 920 [0] = "No VFP support single precision", 921 [1] = "VFPv2 support single precision", 922 [2] = "VFPv2/VFPv3/VFPv4 support single precision", 923 } 924 }, 925 { 926 FIELDINFO(8, 4, "FPDP") { 927 [0] = "No VFP support double precision", 928 [1] = "VFPv2 support double precision", 929 [2] = "VFPv2/VFPv3/VFPv4 support double precision", 930 } 931 }, 932 { 933 FIELDINFO(12, 4, "FPTrap") { 934 [0] = "No floating point exception trapping support", 935 [1] = "VFPv2/VFPv3/VFPv4 support exception trapping", 936 } 937 }, 938 { 939 FIELDINFO(16, 4, "FPDivide") { 940 [0] = "VDIV not supported", 941 [1] = "VDIV supported", 942 } 943 }, 944 { 945 FIELDINFO(20, 4, "FPSqrt") { 946 [0] = "VSQRT not supported", 947 [1] = "VSQRT supported", 948 } 949 }, 950 { 951 FIELDINFO(24, 4, "FPShVec") { 952 [0] = "Short Vectors not supported", 953 [1] = "Short Vectors supported", 954 } 955 }, 956 { 957 FIELDINFO(28, 4, "FPRound") { 958 [0] = "Only Round to Nearest mode", 959 [1] = "All rounding modes", 960 } 961 }, 962 { .bitwidth = 0 } /* end of table */ 963 }; 964 965 /* MVFR1_EL1 - Media and VFP Feature Register 1 */ 966 struct fieldinfo mvfr1_fieldinfo[] = { 967 { 968 FIELDINFO(0, 4, "FPFtZ") { 969 [0] = "only the Flush-to-Zero", 970 [1] = "full Denormalized number arithmetic", 971 } 972 }, 973 { 974 FIELDINFO(4, 4, "FPDNan") { 975 [0] = "Default NaN", 976 [1] = "Propagation of NaN", 977 } 978 }, 979 { 980 FIELDINFO(8, 4, "SIMDLS") { 981 [0] = "No Advanced SIMD Load/Store", 982 [1] = "Advanced SIMD Load/Store", 983 } 984 }, 985 { 986 FIELDINFO(12, 4, "SIMDInt") { 987 [0] = "No Advanced SIMD Integer", 988 [1] = "Advanced SIMD Integer", 989 } 990 }, 991 { 992 FIELDINFO(16, 4, "SIMDSP") { 993 [0] = "No Advanced SIMD single precision", 994 [1] = "Advanced SIMD single precision", 995 } 996 }, 997 { 998 FIELDINFO(20, 4, "SIMDHP") { 999 [0] = "No Advanced SIMD half precision", 1000 [1] = "Advanced SIMD half precision conversion", 1001 [2] = "Advanced SIMD half precision conversion " 1002 "and arithmetic", 1003 } 1004 }, 1005 { 1006 FIELDINFO(24, 4, "FPHP") { 1007 [0] = "No half precision conversion", 1008 [1] = "half/single precision conversion", 1009 [2] = "half/single/double precision conversion", 1010 [3] = "half/single/double precision conversion, and " 1011 "half precision arithmetic", 1012 } 1013 }, 1014 { 1015 FIELDINFO(28, 4, "SIMDFMAC") { 1016 [0] = "No Fused Multiply-Accumulate", 1017 [1] = "Fused Multiply-Accumulate", 1018 } 1019 }, 1020 { .bitwidth = 0 } /* end of table */ 1021 }; 1022 1023 /* MVFR2_EL1 - Media and VFP Feature Register 2 */ 1024 struct fieldinfo mvfr2_fieldinfo[] = { 1025 { 1026 FIELDINFO(0, 4, "SIMDMisc") { 1027 [0] = "No miscellaneous features", 1028 [1] = "Conversion to Integer w/Directed Rounding modes", 1029 [2] = "Conversion to Integer w/Directed Rounding modes" 1030 ", Round to Integral floating point", 1031 [3] = "Conversion to Integer w/Directed Rounding modes" 1032 ", Round to Integral floating point" 1033 ", MaxNum and MinNum", 1034 } 1035 }, 1036 { 1037 FIELDINFO(4, 4, "FPMisc") { 1038 [0] = "No miscellaneous features", 1039 [1] = "Floating point selection", 1040 [2] = "Floating point selection" 1041 ", Conversion to Integer w/Directed Rounding modes", 1042 [3] = "Floating point selection" 1043 ", Conversion to Integer w/Directed Rounding modes" 1044 ", Round to Integral floating point", 1045 [4] = "Floating point selection" 1046 ", Conversion to Integer w/Directed Rounding modes" 1047 ", Round to Integral floating point" 1048 ", MaxNum and MinNum", 1049 } 1050 }, 1051 { .bitwidth = 0 } /* end of table */ 1052 }; 1053 1054 /* CLIDR_EL1 - Cache Level ID Register */ 1055 const char * const clidr_cachetype[8] = { /* 8=3bit */ 1056 [0] = "None", 1057 [1] = "Instruction cache", 1058 [2] = "Data cache", 1059 [3] = "Instruction and Data cache", 1060 [4] = "Unified cache", 1061 }; 1062 1063 struct fieldinfo clidr_fieldinfo[] = { 1064 { 1065 FIELDNAME(0, 3, "L1"), 1066 .info = clidr_cachetype 1067 }, 1068 { 1069 FIELDNAME(3, 3, "L2"), 1070 .info = clidr_cachetype 1071 }, 1072 { 1073 FIELDNAME(6, 3, "L3"), 1074 .info = clidr_cachetype 1075 }, 1076 { 1077 FIELDNAME(9, 3, "L4"), 1078 .info = clidr_cachetype 1079 }, 1080 { 1081 FIELDNAME(12, 3, "L5"), 1082 .info = clidr_cachetype 1083 }, 1084 { 1085 FIELDNAME(15, 3, "L6"), 1086 .info = clidr_cachetype 1087 }, 1088 { 1089 FIELDNAME(18, 3, "L7"), 1090 .info = clidr_cachetype 1091 }, 1092 { 1093 FIELDNAME(21, 3, "LoUU"), 1094 .flags = FIELDINFO_FLAGS_DEC 1095 }, 1096 { 1097 FIELDNAME(24, 3, "LoC"), 1098 .flags = FIELDINFO_FLAGS_DEC 1099 }, 1100 { 1101 FIELDNAME(27, 3, "LoUIS"), 1102 .flags = FIELDINFO_FLAGS_DEC 1103 }, 1104 { 1105 FIELDNAME(30, 3, "ICB"), 1106 .flags = FIELDINFO_FLAGS_DEC 1107 }, 1108 { .bitwidth = 0 } /* end of table */ 1109 }; 1110 1111 struct fieldinfo ctr_fieldinfo[] = { 1112 { 1113 FIELDNAME(0, 4, "IminLine"), 1114 .flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2 1115 }, 1116 { 1117 FIELDNAME(16, 4, "DminLine"), 1118 .flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2 1119 }, 1120 { 1121 FIELDINFO(14, 2, "L1 Icache policy") { 1122 [0] = "VMID aware PIPT (VPIPT)", 1123 [1] = "ASID-tagged VIVT (AIVIVT)", 1124 [2] = "VIPT", 1125 [3] = "PIPT", 1126 }, 1127 }, 1128 { 1129 FIELDNAME(20, 4, "ERG"), 1130 .flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2 1131 }, 1132 { 1133 FIELDNAME(24, 4, "CWG"), 1134 .flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2 1135 }, 1136 { 1137 FIELDNAME(28, 1, "DIC"), 1138 .flags = FIELDINFO_FLAGS_DEC 1139 }, 1140 { 1141 FIELDNAME(29, 1, "IDC"), 1142 .flags = FIELDINFO_FLAGS_DEC 1143 }, 1144 { .bitwidth = 0 } /* end of table */ 1145 }; 1146 1147 1148 static void 1149 print_fieldinfo(const char *cpuname, const char *setname, 1150 struct fieldinfo *fieldinfo, uint64_t data) 1151 { 1152 uint64_t v; 1153 const char *info; 1154 int i, flags; 1155 1156 #define WIDTHMASK(w) (0xffffffffffffffffULL >> (64 - (w))) 1157 1158 for (i = 0; fieldinfo[i].bitwidth != 0; i++) { 1159 v = (data >> fieldinfo[i].bitpos) & 1160 WIDTHMASK(fieldinfo[i].bitwidth); 1161 1162 flags = fieldinfo[i].flags; 1163 info = NULL; 1164 if (fieldinfo[i].info != NULL) 1165 info = fieldinfo[i].info[v]; 1166 1167 printf("%s: %s: %s: ", 1168 cpuname, setname, fieldinfo[i].name); 1169 1170 if (verbose) 1171 printf("0x%"PRIx64": ", v); 1172 1173 if (info == NULL) { 1174 if (flags & FIELDINFO_FLAGS_4LOG2) 1175 v = 4 * (1 << v); 1176 if (flags & FIELDINFO_FLAGS_DEC) 1177 printf("%"PRIu64"\n", v); 1178 else 1179 printf("0x%"PRIx64"\n", v); 1180 } else { 1181 printf("%s\n", info); 1182 } 1183 } 1184 } 1185 1186 /* MIDR_EL1 - Main ID Register */ 1187 static void 1188 identify_midr(const char *cpuname, uint32_t cpuid) 1189 { 1190 unsigned int i; 1191 uint32_t implid, cpupart, variant, revision; 1192 const char *implementer = NULL; 1193 static char implbuf[128]; 1194 1195 implid = cpuid & CPU_ID_IMPLEMENTOR_MASK; 1196 cpupart = cpuid & CPU_PARTMASK; 1197 variant = __SHIFTOUT(cpuid, CPU_ID_VARIANT_MASK); 1198 revision = __SHIFTOUT(cpuid, CPU_ID_REVISION_MASK); 1199 1200 for (i = 0; i < __arraycount(implids); i++) { 1201 if (implid == implids[i].impl_id) { 1202 implementer = implids[i].impl_name; 1203 } 1204 } 1205 if (implementer == NULL) { 1206 snprintf(implbuf, sizeof(implbuf), "unknown implementer: 0x%02x", 1207 implid >> 24); 1208 implementer = implbuf; 1209 } 1210 1211 for (i = 0; i < __arraycount(cpuids); i++) { 1212 if (cpupart == cpuids[i].cpu_partnum) { 1213 printf("%s: %s, %s r%dp%d (%s %s core)\n", 1214 cpuname, implementer, 1215 cpuids[i].cpu_name, variant, revision, 1216 cpuids[i].cpu_class, 1217 cpuids[i].cpu_architecture); 1218 return; 1219 } 1220 } 1221 printf("%s: unknown CPU ID: 0x%08x\n", cpuname, cpuid); 1222 } 1223 1224 /* REVIDR_EL1 - Revision ID Register */ 1225 static void 1226 identify_revidr(const char *cpuname, uint32_t revidr) 1227 { 1228 printf("%s: revision: 0x%08x\n", cpuname, revidr); 1229 } 1230 1231 /* MPIDR_EL1 - Multiprocessor Affinity Register */ 1232 static void 1233 identify_mpidr(const char *cpuname, uint64_t mpidr) 1234 { 1235 const char *setname = "multiprocessor affinity"; 1236 1237 printf("%s: %s: Affinity-Level: %"PRIu64"-%"PRIu64"-%"PRIu64"-%"PRIu64"\n", 1238 cpuname, setname, 1239 __SHIFTOUT(mpidr, MPIDR_AFF3), 1240 __SHIFTOUT(mpidr, MPIDR_AFF2), 1241 __SHIFTOUT(mpidr, MPIDR_AFF1), 1242 __SHIFTOUT(mpidr, MPIDR_AFF0)); 1243 1244 if ((mpidr & MPIDR_U) == 0) 1245 printf("%s: %s: Multiprocessor system\n", cpuname, setname); 1246 else 1247 printf("%s: %s: Uniprocessor system\n", cpuname, setname); 1248 1249 if ((mpidr & MPIDR_MT) == 0) 1250 printf("%s: %s: Core Independent\n", cpuname, setname); 1251 else 1252 printf("%s: %s: Multi-Threading\n", cpuname, setname); 1253 1254 } 1255 1256 /* ID_AA64DFR0_EL1 - Debug feature register 0 */ 1257 static void 1258 identify_dfr0(const char *cpuname, uint64_t dfr0, uint64_t dfr1) 1259 { 1260 const char *setname = "debug feature 0"; 1261 1262 if (__SHIFTOUT(dfr1, ID_AA64DFR1_EL1_CTX_CMPS) == 0) 1263 printf("%s: %s: CTX_CMPs: %lu context-aware breakpoints\n", 1264 cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_CTX_CMPS) + 1); 1265 else 1266 printf("%s: %s: CTX_CMPs: defined in ID_AA64DFR1_EL1\n", 1267 cpuname, setname); 1268 1269 if (__SHIFTOUT(dfr1, ID_AA64DFR1_EL1_WRPS) == 0) 1270 printf("%s: %s: WRPs: %lu watchpoints\n", 1271 cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_WRPS) + 1); 1272 else 1273 printf("%s: %s: WRPs: defined in ID_AA64DFR1_EL1\n", 1274 cpuname, setname); 1275 1276 if (__SHIFTOUT(dfr1, ID_AA64DFR1_EL1_BRPS) == 0) 1277 printf("%s: %s: BRPs: %lu breakpoints\n", 1278 cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_BRPS) + 1); 1279 else 1280 printf("%s: %s: BRPs: defined in ID_AA64DFR1_EL1\n", 1281 cpuname, setname); 1282 1283 print_fieldinfo(cpuname, setname, 1284 id_aa64dfr0_fieldinfo, dfr0); 1285 } 1286 1287 void 1288 identifycpu(int fd, const char *cpuname) 1289 { 1290 char path[128]; 1291 size_t len; 1292 #define SYSCTL_CPU_ID_MAXSIZE 64 1293 uint64_t sysctlbuf[SYSCTL_CPU_ID_MAXSIZE]; 1294 struct aarch64_sysctl_cpu_id *id = 1295 (struct aarch64_sysctl_cpu_id *)sysctlbuf; 1296 1297 snprintf(path, sizeof path, "machdep.%s.cpu_id", cpuname); 1298 len = sizeof(sysctlbuf); 1299 memset(sysctlbuf, 0, len); 1300 if (sysctlbyname(path, id, &len, 0, 0) == -1) 1301 err(1, "couldn't get %s", path); 1302 if (len != sizeof(struct aarch64_sysctl_cpu_id)) 1303 fprintf(stderr, "Warning: kernel version bumped?\n"); 1304 1305 if (verbose) { 1306 printf("%s: MIDR_EL1: 0x%08"PRIx64"\n", 1307 cpuname, id->ac_midr); 1308 printf("%s: MPIDR_EL1: 0x%016"PRIx64"\n", 1309 cpuname, id->ac_mpidr); 1310 printf("%s: ID_AA64DFR0_EL1: 0x%016"PRIx64"\n", 1311 cpuname, id->ac_aa64dfr0); 1312 printf("%s: ID_AA64DFR1_EL1: 0x%016"PRIx64"\n", 1313 cpuname, id->ac_aa64dfr1); 1314 printf("%s: ID_AA64ISAR0_EL1: 0x%016"PRIx64"\n", 1315 cpuname, id->ac_aa64isar0); 1316 printf("%s: ID_AA64ISAR1_EL1: 0x%016"PRIx64"\n", 1317 cpuname, id->ac_aa64isar1); 1318 printf("%s: ID_AA64MMFR0_EL1: 0x%016"PRIx64"\n", 1319 cpuname, id->ac_aa64mmfr0); 1320 printf("%s: ID_AA64MMFR1_EL1: 0x%016"PRIx64"\n", 1321 cpuname, id->ac_aa64mmfr1); 1322 printf("%s: ID_AA64MMFR2_EL1: 0x%016"PRIx64"\n", 1323 cpuname, id->ac_aa64mmfr2); 1324 printf("%s: ID_AA64PFR0_EL1: 0x%08"PRIx64"\n", 1325 cpuname, id->ac_aa64pfr0); 1326 printf("%s: ID_AA64PFR1_EL1: 0x%08"PRIx64"\n", 1327 cpuname, id->ac_aa64pfr1); 1328 printf("%s: ID_AA64ZFR0_EL1: 0x%016"PRIx64"\n", 1329 cpuname, id->ac_aa64zfr0); 1330 printf("%s: MVFR0_EL1: 0x%08"PRIx32"\n", 1331 cpuname, id->ac_mvfr0); 1332 printf("%s: MVFR1_EL1: 0x%08"PRIx32"\n", 1333 cpuname, id->ac_mvfr1); 1334 printf("%s: MVFR2_EL1: 0x%08"PRIx32"\n", 1335 cpuname, id->ac_mvfr2); 1336 printf("%s: CLIDR_EL1: 0x%016"PRIx64"\n", 1337 cpuname, id->ac_clidr); 1338 printf("%s: CTR_EL0: 0x%016"PRIx64"\n", 1339 cpuname, id->ac_ctr); 1340 } 1341 1342 identify_midr(cpuname, id->ac_midr); 1343 identify_revidr(cpuname, id->ac_revidr); 1344 identify_mpidr(cpuname, id->ac_mpidr); 1345 print_fieldinfo(cpuname, "isa features 0", 1346 id_aa64isar0_fieldinfo, id->ac_aa64isar0); 1347 print_fieldinfo(cpuname, "isa features 1", 1348 id_aa64isar1_fieldinfo, id->ac_aa64isar1); 1349 print_fieldinfo(cpuname, "memory model 0", 1350 id_aa64mmfr0_fieldinfo, id->ac_aa64mmfr0); 1351 print_fieldinfo(cpuname, "memory model 1", 1352 id_aa64mmfr1_fieldinfo, id->ac_aa64mmfr1); 1353 print_fieldinfo(cpuname, "processor feature 0", 1354 id_aa64pfr0_fieldinfo, id->ac_aa64pfr0); 1355 print_fieldinfo(cpuname, "processor feature 1", 1356 id_aa64pfr1_fieldinfo, id->ac_aa64pfr1); 1357 identify_dfr0(cpuname, id->ac_aa64dfr0, id->ac_aa64dfr1); 1358 1359 print_fieldinfo(cpuname, "media and VFP features 0", 1360 mvfr0_fieldinfo, id->ac_mvfr0); 1361 print_fieldinfo(cpuname, "media and VFP features 1", 1362 mvfr1_fieldinfo, id->ac_mvfr1); 1363 print_fieldinfo(cpuname, "media and VFP features 2", 1364 mvfr2_fieldinfo, id->ac_mvfr2); 1365 1366 if (len <= offsetof(struct aarch64_sysctl_cpu_id, ac_clidr)) 1367 return; 1368 print_fieldinfo(cpuname, "cache level", 1369 clidr_fieldinfo, id->ac_clidr); 1370 print_fieldinfo(cpuname, "cache type", 1371 ctr_fieldinfo, id->ac_ctr); 1372 } 1373 1374 bool 1375 identifycpu_bind(void) 1376 { 1377 return false; 1378 } 1379 1380 int 1381 ucodeupdate_check(int fd, struct cpu_ucode *uc) 1382 { 1383 return 0; 1384 } 1385