blob: a9d68f7e80aa93aa2c35ad04d1838604f2271fea [file] [log] [blame]
Fuad Tabbaf1d6dc52019-09-18 17:33:14 +01001/*
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
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010023#include "vmapi/hf/ffa.h"
Fuad Tabbaf1d6dc52019-09-18 17:33:14 +010024
25/**
Fuad Tabbaf1d6dc52019-09-18 17:33:14 +010026 * 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
75bool perfmon_is_register_access(uintreg_t esr_el2);
76
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010077bool perfmon_process_access(struct vcpu *vcpu, ffa_vm_id_t vm_id,
Fuad Tabbaf1d6dc52019-09-18 17:33:14 +010078 uintreg_t esr_el2);
79
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010080uintreg_t perfmon_get_pmccfiltr_el0_init_value(ffa_vm_id_t vm_id);