1*54fd6939SJiyong ParkPerformance Monitoring Unit 2*54fd6939SJiyong Park=========================== 3*54fd6939SJiyong Park 4*54fd6939SJiyong ParkThe Performance Monitoring Unit (PMU) allows recording of architectural and 5*54fd6939SJiyong Parkmicroarchitectural events for profiling purposes. 6*54fd6939SJiyong Park 7*54fd6939SJiyong ParkThis document gives an overview of the PMU counter configuration to assist with 8*54fd6939SJiyong Parkimplementation and to complement the PMU security guidelines given in the 9*54fd6939SJiyong Park:ref:`Secure Development Guidelines` document. 10*54fd6939SJiyong Park 11*54fd6939SJiyong Park.. note:: 12*54fd6939SJiyong Park This section applies to Armv8-A implementations which have version 3 13*54fd6939SJiyong Park of the Performance Monitors Extension (PMUv3). 14*54fd6939SJiyong Park 15*54fd6939SJiyong ParkPMU Counters 16*54fd6939SJiyong Park------------ 17*54fd6939SJiyong Park 18*54fd6939SJiyong ParkThe PMU makes 32 counters available at all privilege levels: 19*54fd6939SJiyong Park 20*54fd6939SJiyong Park- 31 programmable event counters: ``PMEVCNTR<n>``, where ``n`` is ``0`` to 21*54fd6939SJiyong Park ``30``. 22*54fd6939SJiyong Park- A dedicated cycle counter: ``PMCCNTR``. 23*54fd6939SJiyong Park 24*54fd6939SJiyong ParkArchitectural mappings 25*54fd6939SJiyong Park~~~~~~~~~~~~~~~~~~~~~~ 26*54fd6939SJiyong Park 27*54fd6939SJiyong Park+--------------+---------+----------------------------+ 28*54fd6939SJiyong Park| Counters | State | System Register Name | 29*54fd6939SJiyong Park+==============+=========+============================+ 30*54fd6939SJiyong Park| | AArch64 | ``PMEVCNTR<n>_EL0[63*:0]`` | 31*54fd6939SJiyong Park| Programmable +---------+----------------------------+ 32*54fd6939SJiyong Park| | AArch32 | ``PMEVCNTR<n>[31:0]`` | 33*54fd6939SJiyong Park+--------------+---------+----------------------------+ 34*54fd6939SJiyong Park| | AArch64 | ``PMCCNTR_EL0[63:0]`` | 35*54fd6939SJiyong Park| Cycle +---------+----------------------------+ 36*54fd6939SJiyong Park| | AArch32 | ``PMCCNTR[63:0]`` | 37*54fd6939SJiyong Park+--------------+---------+----------------------------+ 38*54fd6939SJiyong Park 39*54fd6939SJiyong Park.. note:: 40*54fd6939SJiyong Park Bits [63:32] are only available if ARMv8.5-PMU is implemented. Refer to the 41*54fd6939SJiyong Park `Arm ARM`_ for a detailed description of ARMv8.5-PMU features. 42*54fd6939SJiyong Park 43*54fd6939SJiyong ParkConfiguring the PMU for counting events 44*54fd6939SJiyong Park--------------------------------------- 45*54fd6939SJiyong Park 46*54fd6939SJiyong ParkEach programmable counter has an associated register, ``PMEVTYPER<n>`` which 47*54fd6939SJiyong Parkconfigures it. The cycle counter has the ``PMCCFILTR_EL0`` register, which has 48*54fd6939SJiyong Parkan identical function and bit field layout as ``PMEVTYPER<n>``. In addition, 49*54fd6939SJiyong Parkthe counters are enabled (permitted to increment) via the ``PMCNTENSET`` and 50*54fd6939SJiyong Park``PMCR`` registers. These can be accessed at all privilege levels. 51*54fd6939SJiyong Park 52*54fd6939SJiyong ParkArchitectural mappings 53*54fd6939SJiyong Park~~~~~~~~~~~~~~~~~~~~~~ 54*54fd6939SJiyong Park 55*54fd6939SJiyong Park+-----------------------------+------------------------+ 56*54fd6939SJiyong Park| AArch64 | AArch32 | 57*54fd6939SJiyong Park+=============================+========================+ 58*54fd6939SJiyong Park| ``PMEVTYPER<n>_EL0[63*:0]`` | ``PMEVTYPER<n>[31:0]`` | 59*54fd6939SJiyong Park+-----------------------------+------------------------+ 60*54fd6939SJiyong Park| ``PMCCFILTR_EL0[63*:0]`` | ``PMCCFILTR[31:0]`` | 61*54fd6939SJiyong Park+-----------------------------+------------------------+ 62*54fd6939SJiyong Park| ``PMCNTENSET_EL0[63*:0]`` | ``PMCNTENSET[31:0]`` | 63*54fd6939SJiyong Park+-----------------------------+------------------------+ 64*54fd6939SJiyong Park| ``PMCR_EL0[63*:0]`` | ``PMCR[31:0]`` | 65*54fd6939SJiyong Park+-----------------------------+------------------------+ 66*54fd6939SJiyong Park 67*54fd6939SJiyong Park.. note:: 68*54fd6939SJiyong Park Bits [63:32] are reserved. 69*54fd6939SJiyong Park 70*54fd6939SJiyong ParkRelevant register fields 71*54fd6939SJiyong Park~~~~~~~~~~~~~~~~~~~~~~~~ 72*54fd6939SJiyong Park 73*54fd6939SJiyong ParkFor ``PMEVTYPER<n>_EL0``/``PMEVTYPER<n>`` and ``PMCCFILTR_EL0/PMCCFILTR``, the 74*54fd6939SJiyong Parkmost important fields are: 75*54fd6939SJiyong Park 76*54fd6939SJiyong Park- ``P``: 77*54fd6939SJiyong Park 78*54fd6939SJiyong Park - Bit 31. 79*54fd6939SJiyong Park - If set to ``0``, will increment the associated ``PMEVCNTR<n>`` at EL1. 80*54fd6939SJiyong Park 81*54fd6939SJiyong Park- ``NSK``: 82*54fd6939SJiyong Park 83*54fd6939SJiyong Park - Bit 29. 84*54fd6939SJiyong Park - If equal to the ``P`` bit it enables the associated ``PMEVCNTR<n>`` at 85*54fd6939SJiyong Park Non-secure EL1. 86*54fd6939SJiyong Park - Reserved if EL3 not implemented. 87*54fd6939SJiyong Park 88*54fd6939SJiyong Park- ``NSH``: 89*54fd6939SJiyong Park 90*54fd6939SJiyong Park - Bit 27. 91*54fd6939SJiyong Park - If set to ``1``, will increment the associated ``PMEVCNTR<n>`` at EL2. 92*54fd6939SJiyong Park - Reserved if EL2 not implemented. 93*54fd6939SJiyong Park 94*54fd6939SJiyong Park- ``SH``: 95*54fd6939SJiyong Park 96*54fd6939SJiyong Park - Bit 24. 97*54fd6939SJiyong Park - If different to the ``NSH`` bit it enables the associated ``PMEVCNTR<n>`` 98*54fd6939SJiyong Park at Secure EL2. 99*54fd6939SJiyong Park - Reserved if Secure EL2 not implemented. 100*54fd6939SJiyong Park 101*54fd6939SJiyong Park- ``M``: 102*54fd6939SJiyong Park 103*54fd6939SJiyong Park - Bit 26. 104*54fd6939SJiyong Park - If equal to the ``P`` bit it enables the associated ``PMEVCNTR<n>`` at 105*54fd6939SJiyong Park EL3. 106*54fd6939SJiyong Park 107*54fd6939SJiyong Park- ``evtCount[15:10]``: 108*54fd6939SJiyong Park 109*54fd6939SJiyong Park - Extension to ``evtCount[9:0]``. Reserved unless ARMv8.1-PMU implemented. 110*54fd6939SJiyong Park 111*54fd6939SJiyong Park- ``evtCount[9:0]``: 112*54fd6939SJiyong Park 113*54fd6939SJiyong Park - The event number that the associated ``PMEVCNTR<n>`` will count. 114*54fd6939SJiyong Park 115*54fd6939SJiyong ParkFor ``PMCNTENSET_EL0``/``PMCNTENSET``, the most important fields are: 116*54fd6939SJiyong Park 117*54fd6939SJiyong Park- ``P[30:0]``: 118*54fd6939SJiyong Park 119*54fd6939SJiyong Park - Setting bit ``P[n]`` to ``1`` enables counter ``PMEVCNTR<n>``. 120*54fd6939SJiyong Park - The effects of ``PMEVTYPER<n>`` are applied on top of this. 121*54fd6939SJiyong Park In other words, the counter will not increment at any privilege level or 122*54fd6939SJiyong Park security state unless it is enabled here. 123*54fd6939SJiyong Park 124*54fd6939SJiyong Park- ``C``: 125*54fd6939SJiyong Park 126*54fd6939SJiyong Park - Bit 31. 127*54fd6939SJiyong Park - If set to ``1`` enables the cycle counter ``PMCCNTR``. 128*54fd6939SJiyong Park 129*54fd6939SJiyong ParkFor ``PMCR``/``PMCR_EL0``, the most important fields are: 130*54fd6939SJiyong Park 131*54fd6939SJiyong Park- ``DP``: 132*54fd6939SJiyong Park 133*54fd6939SJiyong Park - Bit 5. 134*54fd6939SJiyong Park - If set to ``1`` it disables the cycle counter ``PMCCNTR`` where event 135*54fd6939SJiyong Park counting (by ``PMEVCNTR<n>``) is prohibited (e.g. EL2 and the Secure 136*54fd6939SJiyong Park world). 137*54fd6939SJiyong Park - If set to ``0``, ``PMCCNTR`` will not be affected by this bit and 138*54fd6939SJiyong Park therefore will be able to count where the programmable counters are 139*54fd6939SJiyong Park prohibited. 140*54fd6939SJiyong Park 141*54fd6939SJiyong Park- ``E``: 142*54fd6939SJiyong Park 143*54fd6939SJiyong Park - Bit 0. 144*54fd6939SJiyong Park - Enables/disables counting altogether. 145*54fd6939SJiyong Park - The effects of ``PMCNTENSET`` and ``PMCR.DP`` are applied on top of this. 146*54fd6939SJiyong Park In other words, if this bit is ``0`` then no counters will increment 147*54fd6939SJiyong Park regardless of how the other PMU system registers or bit fields are 148*54fd6939SJiyong Park configured. 149*54fd6939SJiyong Park 150*54fd6939SJiyong Park.. rubric:: References 151*54fd6939SJiyong Park 152*54fd6939SJiyong Park- `Arm ARM`_ 153*54fd6939SJiyong Park 154*54fd6939SJiyong Park-------------- 155*54fd6939SJiyong Park 156*54fd6939SJiyong Park*Copyright (c) 2019-2020, Arm Limited and Contributors. All rights reserved.* 157*54fd6939SJiyong Park 158*54fd6939SJiyong Park.. _Arm ARM: https://developer.arm.com/docs/ddi0487/latest 159