OSDN Git Service

scsi: target/iblock: fix WRITE SAME zeroing
[tomoyo/tomoyo-test1.git] / Documentation / arm64 / amu.rst
1 =======================================================
2 Activity Monitors Unit (AMU) extension in AArch64 Linux
3 =======================================================
4
5 Author: Ionela Voinescu <ionela.voinescu@arm.com>
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.