Skip to content

Commit 6abde90

Browse files
ionela-voinescuctmarinas
authored andcommitted
Documentation: arm64: document support for the AMU extension
The activity monitors extension is an optional extension introduced by the ARMv8.4 CPU architecture. Add initial documentation for the AMUv1 extension: - arm64/amu.txt: AMUv1 documentation - arm64/booting.txt: system registers initialisation Signed-off-by: Ionela Voinescu <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Will Deacon <[email protected]> Cc: Catalin Marinas <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent 4fcdf10 commit 6abde90

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

Documentation/arm64/amu.rst

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
=======================================================
2+
Activity Monitors Unit (AMU) extension in AArch64 Linux
3+
=======================================================
4+
5+
Author: Ionela Voinescu <[email protected]>
6+
7+
Date: 2019-09-10
8+
9+
This document briefly describes the provision of Activity Monitors Unit
10+
support in AArch64 Linux.
11+
12+
13+
Architecture overview
14+
---------------------
15+
16+
The activity monitors extension is an optional extension introduced by the
17+
ARMv8.4 CPU architecture.
18+
19+
The activity monitors unit, implemented in each CPU, provides performance
20+
counters intended for system management use. The AMU extension provides a
21+
system register interface to the counter registers and also supports an
22+
optional external memory-mapped interface.
23+
24+
Version 1 of the Activity Monitors architecture implements a counter group
25+
of four fixed and architecturally defined 64-bit event counters.
26+
- CPU cycle counter: increments at the frequency of the CPU.
27+
- Constant counter: increments at the fixed frequency of the system
28+
clock.
29+
- Instructions retired: increments with every architecturally executed
30+
instruction.
31+
- Memory stall cycles: counts instruction dispatch stall cycles caused by
32+
misses in the last level cache within the clock domain.
33+
34+
When in WFI or WFE these counters do not increment.
35+
36+
The Activity Monitors architecture provides space for up to 16 architected
37+
event counters. Future versions of the architecture may use this space to
38+
implement additional architected event counters.
39+
40+
Additionally, version 1 implements a counter group of up to 16 auxiliary
41+
64-bit event counters.
42+
43+
On cold reset all counters reset to 0.
44+
45+
46+
Basic support
47+
-------------
48+
49+
The kernel can safely run a mix of CPUs with and without support for the
50+
activity monitors extension. Therefore, when CONFIG_ARM64_AMU_EXTN is
51+
selected we unconditionally enable the capability to allow any late CPU
52+
(secondary or hotplugged) to detect and use the feature.
53+
54+
When the feature is detected on a CPU, we flag the availability of the
55+
feature but this does not guarantee the correct functionality of the
56+
counters, only the presence of the extension.
57+
58+
Firmware (code running at higher exception levels, e.g. arm-tf) support is
59+
needed to:
60+
- Enable access for lower exception levels (EL2 and EL1) to the AMU
61+
registers.
62+
- Enable the counters. If not enabled these will read as 0.
63+
- Save/restore the counters before/after the CPU is being put/brought up
64+
from the 'off' power state.
65+
66+
When using kernels that have this feature enabled but boot with broken
67+
firmware the user may experience panics or lockups when accessing the
68+
counter registers. Even if these symptoms are not observed, the values
69+
returned by the register reads might not correctly reflect reality. Most
70+
commonly, the counters will read as 0, indicating that they are not
71+
enabled.
72+
73+
If proper support is not provided in firmware it's best to disable
74+
CONFIG_ARM64_AMU_EXTN. To be noted that for security reasons, this does not
75+
bypass the setting of AMUSERENR_EL0 to trap accesses from EL0 (userspace) to
76+
EL1 (kernel). Therefore, firmware should still ensure accesses to AMU registers
77+
are not trapped in EL2/EL3.
78+
79+
The fixed counters of AMUv1 are accessible though the following system
80+
register definitions:
81+
- SYS_AMEVCNTR0_CORE_EL0
82+
- SYS_AMEVCNTR0_CONST_EL0
83+
- SYS_AMEVCNTR0_INST_RET_EL0
84+
- SYS_AMEVCNTR0_MEM_STALL_EL0
85+
86+
Auxiliary platform specific counters can be accessed using
87+
SYS_AMEVCNTR1_EL0(n), where n is a value between 0 and 15.
88+
89+
Details can be found in: arch/arm64/include/asm/sysreg.h.
90+
91+
92+
Userspace access
93+
----------------
94+
95+
Currently, access from userspace to the AMU registers is disabled due to:
96+
- Security reasons: they might expose information about code executed in
97+
secure mode.
98+
- Purpose: AMU counters are intended for system management use.
99+
100+
Also, the presence of the feature is not visible to userspace.
101+
102+
103+
Virtualization
104+
--------------
105+
106+
Currently, access from userspace (EL0) and kernelspace (EL1) on the KVM
107+
guest side is disabled due to:
108+
- Security reasons: they might expose information about code executed
109+
by other guests or the host.
110+
111+
Any attempt to access the AMU registers will result in an UNDEFINED
112+
exception being injected into the guest.

Documentation/arm64/booting.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,20 @@ Before jumping into the kernel, the following conditions must be met:
248248
- HCR_EL2.APK (bit 40) must be initialised to 0b1
249249
- HCR_EL2.API (bit 41) must be initialised to 0b1
250250

251+
For CPUs with Activity Monitors Unit v1 (AMUv1) extension present:
252+
- If EL3 is present:
253+
CPTR_EL3.TAM (bit 30) must be initialised to 0b0
254+
CPTR_EL2.TAM (bit 30) must be initialised to 0b0
255+
AMCNTENSET0_EL0 must be initialised to 0b1111
256+
AMCNTENSET1_EL0 must be initialised to a platform specific value
257+
having 0b1 set for the corresponding bit for each of the auxiliary
258+
counters present.
259+
- If the kernel is entered at EL1:
260+
AMCNTENSET0_EL0 must be initialised to 0b1111
261+
AMCNTENSET1_EL0 must be initialised to a platform specific value
262+
having 0b1 set for the corresponding bit for each of the auxiliary
263+
counters present.
264+
251265
The requirements described above for CPU mode, caches, MMUs, architected
252266
timers, coherency and system registers apply to all CPUs. All CPUs must
253267
enter the kernel in the same exception level.

Documentation/arm64/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ARM64 Architecture
66
:maxdepth: 1
77

88
acpi_object_usage
9+
amu
910
arm-acpi
1011
booting
1112
cpu-feature-registers

0 commit comments

Comments
 (0)