mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-10 18:53:38 +00:00
6be22809e5
* for-next/elf-hwcap-docs: : Update the arm64 ELF HWCAP documentation docs/arm64: cpu-feature-registers: Rewrite bitfields that don't follow [e, s] docs/arm64: cpu-feature-registers: Documents missing visible fields docs/arm64: elf_hwcaps: Document HWCAP_SB docs/arm64: elf_hwcaps: sort the HWCAP{, 2} documentation by ascending value * for-next/smccc-conduit-cleanup: : SMC calling convention conduit clean-up firmware: arm_sdei: use common SMCCC_CONDUIT_* firmware/psci: use common SMCCC_CONDUIT_* arm: spectre-v2: use arm_smccc_1_1_get_conduit() arm64: errata: use arm_smccc_1_1_get_conduit() arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit() * for-next/zone-dma: : Reintroduction of ZONE_DMA for Raspberry Pi 4 support arm64: mm: reserve CMA and crashkernel in ZONE_DMA32 dma/direct: turn ARCH_ZONE_DMA_BITS into a variable arm64: Make arm64_dma32_phys_limit static arm64: mm: Fix unused variable warning in zone_sizes_init mm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type' arm64: use both ZONE_DMA and ZONE_DMA32 arm64: rename variables used to calculate ZONE_DMA32's size arm64: mm: use arm64_dma_phys_limit instead of calling max_zone_dma_phys() * for-next/relax-icc_pmr_el1-sync: : Relax ICC_PMR_EL1 (GICv3) accesses when ICC_CTLR_EL1.PMHE is clear arm64: Document ICC_CTLR_EL3.PMHE setting requirements arm64: Relax ICC_PMR_EL1 accesses when ICC_CTLR_EL1.PMHE is clear * for-next/double-page-fault: : Avoid a double page fault in __copy_from_user_inatomic() if hw does not support auto Access Flag mm: fix double page fault on arm64 if PTE_AF is cleared x86/mm: implement arch_faults_on_old_pte() stub on x86 arm64: mm: implement arch_faults_on_old_pte() on arm64 arm64: cpufeature: introduce helper cpu_has_hw_af() * for-next/misc: : Various fixes and clean-ups arm64: kpti: Add NVIDIA's Carmel core to the KPTI whitelist arm64: mm: Remove MAX_USER_VA_BITS definition arm64: mm: simplify the page end calculation in __create_pgd_mapping() arm64: print additional fault message when executing non-exec memory arm64: psci: Reduce the waiting time for cpu_psci_cpu_kill() arm64: pgtable: Correct typo in comment arm64: docs: cpu-feature-registers: Document ID_AA64PFR1_EL1 arm64: cpufeature: Fix typos in comment arm64/mm: Poison initmem while freeing with free_reserved_area() arm64: use generic free_initrd_mem() arm64: simplify syscall wrapper ifdeffery * for-next/kselftest-arm64-signal: : arm64-specific kselftest support with signal-related test-cases kselftest: arm64: fake_sigreturn_misaligned_sp kselftest: arm64: fake_sigreturn_bad_size kselftest: arm64: fake_sigreturn_duplicated_fpsimd kselftest: arm64: fake_sigreturn_missing_fpsimd kselftest: arm64: fake_sigreturn_bad_size_for_magic0 kselftest: arm64: fake_sigreturn_bad_magic kselftest: arm64: add helper get_current_context kselftest: arm64: extend test_init functionalities kselftest: arm64: mangle_pstate_invalid_mode_el[123][ht] kselftest: arm64: mangle_pstate_invalid_daif_bits kselftest: arm64: mangle_pstate_invalid_compat_toggle and common utils kselftest: arm64: extend toplevel skeleton Makefile * for-next/kaslr-diagnostics: : Provide diagnostics on boot for KASLR arm64: kaslr: Check command line before looking for a seed arm64: kaslr: Announce KASLR status on boot
315 lines
13 KiB
ReStructuredText
315 lines
13 KiB
ReStructuredText
===========================
|
|
ARM64 CPU Feature Registers
|
|
===========================
|
|
|
|
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
|
|
-------------
|
|
|
|
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
|
|
---------------
|
|
|
|
a) Safety:
|
|
|
|
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.
|
|
|
|
b) Security:
|
|
|
|
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
|
|
|
|
The infrastructure doesn't expose any register which is
|
|
IMPLEMENTATION DEFINED as per ARMv8-A Architecture.
|
|
|
|
d) CPU Identification:
|
|
|
|
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
|
|
at::
|
|
|
|
/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.
|
|
|
|
The infrastructure emulates only the following system register space::
|
|
|
|
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
|
|
|
|
+------------------------------+---------+---------+
|
|
| Name | bits | visible |
|
|
+------------------------------+---------+---------+
|
|
| TS | [55-52] | y |
|
|
+------------------------------+---------+---------+
|
|
| FHM | [51-48] | y |
|
|
+------------------------------+---------+---------+
|
|
| DP | [47-44] | y |
|
|
+------------------------------+---------+---------+
|
|
| SM4 | [43-40] | y |
|
|
+------------------------------+---------+---------+
|
|
| SM3 | [39-36] | y |
|
|
+------------------------------+---------+---------+
|
|
| SHA3 | [35-32] | y |
|
|
+------------------------------+---------+---------+
|
|
| RDM | [31-28] | y |
|
|
+------------------------------+---------+---------+
|
|
| ATOMICS | [23-20] | y |
|
|
+------------------------------+---------+---------+
|
|
| CRC32 | [19-16] | y |
|
|
+------------------------------+---------+---------+
|
|
| SHA2 | [15-12] | y |
|
|
+------------------------------+---------+---------+
|
|
| SHA1 | [11-8] | y |
|
|
+------------------------------+---------+---------+
|
|
| AES | [7-4] | y |
|
|
+------------------------------+---------+---------+
|
|
|
|
|
|
2) ID_AA64PFR0_EL1 - Processor Feature Register 0
|
|
|
|
+------------------------------+---------+---------+
|
|
| Name | bits | visible |
|
|
+------------------------------+---------+---------+
|
|
| DIT | [51-48] | y |
|
|
+------------------------------+---------+---------+
|
|
| SVE | [35-32] | y |
|
|
+------------------------------+---------+---------+
|
|
| GIC | [27-24] | n |
|
|
+------------------------------+---------+---------+
|
|
| AdvSIMD | [23-20] | y |
|
|
+------------------------------+---------+---------+
|
|
| FP | [19-16] | y |
|
|
+------------------------------+---------+---------+
|
|
| EL3 | [15-12] | n |
|
|
+------------------------------+---------+---------+
|
|
| EL2 | [11-8] | n |
|
|
+------------------------------+---------+---------+
|
|
| EL1 | [7-4] | n |
|
|
+------------------------------+---------+---------+
|
|
| EL0 | [3-0] | n |
|
|
+------------------------------+---------+---------+
|
|
|
|
|
|
3) ID_AA64PFR1_EL1 - Processor Feature Register 1
|
|
+------------------------------+---------+---------+
|
|
| Name | bits | visible |
|
|
+------------------------------+---------+---------+
|
|
| SSBS | [7-4] | y |
|
|
+------------------------------+---------+---------+
|
|
|
|
|
|
4) MIDR_EL1 - Main ID Register
|
|
+------------------------------+---------+---------+
|
|
| Name | bits | visible |
|
|
+------------------------------+---------+---------+
|
|
| Implementer | [31-24] | y |
|
|
+------------------------------+---------+---------+
|
|
| Variant | [23-20] | y |
|
|
+------------------------------+---------+---------+
|
|
| Architecture | [19-16] | y |
|
|
+------------------------------+---------+---------+
|
|
| PartNum | [15-4] | y |
|
|
+------------------------------+---------+---------+
|
|
| Revision | [3-0] | y |
|
|
+------------------------------+---------+---------+
|
|
|
|
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.
|
|
|
|
5) ID_AA64ISAR1_EL1 - Instruction set attribute register 1
|
|
|
|
+------------------------------+---------+---------+
|
|
| Name | bits | visible |
|
|
+------------------------------+---------+---------+
|
|
| SB | [39-36] | y |
|
|
+------------------------------+---------+---------+
|
|
| FRINTTS | [35-32] | y |
|
|
+------------------------------+---------+---------+
|
|
| GPI | [31-28] | y |
|
|
+------------------------------+---------+---------+
|
|
| GPA | [27-24] | y |
|
|
+------------------------------+---------+---------+
|
|
| LRCPC | [23-20] | y |
|
|
+------------------------------+---------+---------+
|
|
| FCMA | [19-16] | y |
|
|
+------------------------------+---------+---------+
|
|
| JSCVT | [15-12] | y |
|
|
+------------------------------+---------+---------+
|
|
| API | [11-8] | y |
|
|
+------------------------------+---------+---------+
|
|
| APA | [7-4] | y |
|
|
+------------------------------+---------+---------+
|
|
| DPB | [3-0] | y |
|
|
+------------------------------+---------+---------+
|
|
|
|
6) ID_AA64MMFR2_EL1 - Memory model feature register 2
|
|
|
|
+------------------------------+---------+---------+
|
|
| Name | bits | visible |
|
|
+------------------------------+---------+---------+
|
|
| AT | [35-32] | y |
|
|
+------------------------------+---------+---------+
|
|
|
|
7) ID_AA64ZFR0_EL1 - SVE feature ID register 0
|
|
|
|
+------------------------------+---------+---------+
|
|
| Name | bits | visible |
|
|
+------------------------------+---------+---------+
|
|
| SM4 | [43-40] | y |
|
|
+------------------------------+---------+---------+
|
|
| SHA3 | [35-32] | y |
|
|
+------------------------------+---------+---------+
|
|
| BitPerm | [19-16] | y |
|
|
+------------------------------+---------+---------+
|
|
| AES | [7-4] | y |
|
|
+------------------------------+---------+---------+
|
|
| SVEVer | [3-0] | y |
|
|
+------------------------------+---------+---------+
|
|
|
|
Appendix I: Example
|
|
-------------------
|
|
|
|
::
|
|
|
|
/*
|
|
* 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) ({ \
|
|
unsigned long __val; \
|
|
asm("mrs %0, "#id : "=r" (__val)); \
|
|
printf("%-20s: 0x%016lx\n", #id, __val); \
|
|
})
|
|
|
|
int main(void)
|
|
{
|
|
|
|
if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
|
|
fputs("CPUID registers unavailable\n", 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);
|
|
|
|
#if 0
|
|
/* Unexposed register access causes SIGILL */
|
|
get_cpu_ftr(ID_MMFR0_EL1);
|
|
#endif
|
|
|
|
return 0;
|
|
}
|