1 /*
2  * Copyright 2019 The Hafnium Authors.
3  *
4  * Use of this source code is governed by a BSD-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/BSD-3-Clause.
7  */
8 
9 #pragma once
10 
11 #include "hf/arch/types.h"
12 
13 #include "hf/cpu.h"
14 
15 #include "vmapi/hf/ffa.h"
16 
17 #define HF_FEATURE_NONE UINT64_C(0)
18 
19 /*  Reliability, Availability, and Serviceability (RAS) Extension Features */
20 #define HF_FEATURE_RAS UINT64_C(1)
21 
22 /* Limited Ordering Regions */
23 #define HF_FEATURE_LOR (UINT64_C(1) << 1)
24 
25 /* Performance Monitor */
26 #define HF_FEATURE_PERFMON (UINT64_C(1) << 2)
27 
28 /* Debug Registers */
29 #define HF_FEATURE_DEBUG (UINT64_C(1) << 3)
30 
31 /* Statistical Profiling Extension (SPE) */
32 #define HF_FEATURE_SPE (UINT64_C(1) << 4)
33 
34 /* Self-hosted Trace */
35 #define HF_FEATURE_TRACE (UINT64_C(1) << 5)
36 
37 /* Pointer Authentication (PAuth) */
38 #define HF_FEATURE_PAUTH (UINT64_C(1) << 6)
39 
40 /*
41  * NOTE: This should be based on the last (highest value) defined feature.
42  * Adjust if adding more features.
43  */
44 #define HF_FEATURE_ALL ((HF_FEATURE_PAUTH << 1) - 1)
45 
46 bool feature_id_is_register_access(uintreg_t esr_el2);
47 
48 bool feature_id_process_access(struct vcpu *vcpu, uintreg_t esr_el2);
49 
50 void feature_set_traps(struct vm *vm, struct arch_regs *regs);
51