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 /* Activity Monitor Unit (AMU) */
41 #define HF_FEATURE_AMU (UINT64_C(1) << 7)
42 
43 /* Scalable Vector Extension (SVE) */
44 #define HF_FEATURE_SVE (UINT64_C(1) << 8)
45 
46 /* Scalable Matrix Extension (SME) */
47 #define HF_FEATURE_SME (UINT64_C(1) << 9)
48 
49 /*
50  * NOTE: This should be based on the last (highest value) defined feature.
51  * Adjust if adding more features.
52  */
53 #define HF_FEATURE_ALL ((HF_FEATURE_SME << 1) - 1)
54 
55 bool feature_id_is_register_access(uintreg_t esr_el2);
56 
57 bool feature_id_process_access(struct vcpu *vcpu, uintreg_t esr_el2);
58 
59 void feature_set_traps(struct vm *vm, struct arch_regs *regs);
60