Fuad Tabba | f1d6dc5 | 2019-09-18 17:33:14 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Hafnium Authors. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include "hf/arch/types.h" |
| 20 | |
| 21 | #include "hf/cpu.h" |
| 22 | |
| 23 | #include "vmapi/hf/spci.h" |
| 24 | |
| 25 | /** |
Fuad Tabba | f1d6dc5 | 2019-09-18 17:33:14 +0100 | [diff] [blame] | 26 | * Set to disable cycle counting when event counting is prohibited. |
| 27 | */ |
| 28 | #define PMCR_EL0_DP 0x10 |
| 29 | |
| 30 | /** |
| 31 | * Set to enable export of events where not prohibited. |
| 32 | */ |
| 33 | #define PMCR_EL0_X 0x8 |
| 34 | |
| 35 | /** |
| 36 | * Set to enable event counting. |
| 37 | */ |
| 38 | #define PMCR_EL0_E 0x1 |
| 39 | |
| 40 | /** |
| 41 | * Set to disable cycle counting in EL1. |
| 42 | */ |
| 43 | #define PMCCFILTR_EL0_P 0x80000000 |
| 44 | |
| 45 | /** |
| 46 | * Set to disable cycle counting in EL0. |
| 47 | */ |
| 48 | #define PMCCFILTR_EL0_U 0x40000000 |
| 49 | |
| 50 | /** |
| 51 | * Cycle counting in non-secure EL1 is enabled if NSK == P. |
| 52 | */ |
| 53 | #define PMCCFILTR_EL0_NSK 0x20000000 |
| 54 | |
| 55 | /** |
| 56 | * Cycle counting in non-secure EL0 is enabled if NSU == U. |
| 57 | */ |
| 58 | #define PMCCFILTR_EL0_NSU 0x10000000 |
| 59 | |
| 60 | /** |
| 61 | * Set to enable cycle counting in EL2. |
| 62 | */ |
| 63 | #define PMCCFILTR_EL0_NSH 0x8000000 |
| 64 | |
| 65 | /** |
| 66 | * Cycle counting in EL3 is enabled if M == P. |
| 67 | */ |
| 68 | #define PMCCFILTR_EL0_M 0x4000000 |
| 69 | |
| 70 | /** |
| 71 | * Cycle counting in Secutre EL2 is enabled if SH != NSH. |
| 72 | */ |
| 73 | #define PMCCFILTR_EL0_SH 0x1000000 |
| 74 | |
| 75 | bool perfmon_is_register_access(uintreg_t esr_el2); |
| 76 | |
| 77 | bool perfmon_process_access(struct vcpu *vcpu, spci_vm_id_t vm_id, |
| 78 | uintreg_t esr_el2); |
| 79 | |
| 80 | uintreg_t perfmon_get_pmccfiltr_el0_init_value(spci_vm_id_t vm_id); |