AArch64 EL2 hypervisor for QEMU virt that boots at EL2
1#ifndef HV_POLICY_H
2#define HV_POLICY_H
3
4#include "hv/log.h"
5#include "hv/sysreg.h"
6#include "hv/vcpu.h"
7
8enum policy_access_class {
9 POLICY_CLASS_ID = 1,
10 POLICY_CLASS_MMU,
11 POLICY_CLASS_TIMER,
12 POLICY_CLASS_THREAD,
13 POLICY_CLASS_DEBUG,
14 POLICY_CLASS_PMU,
15 POLICY_CLASS_EL2_EL3,
16 POLICY_CLASS_MISC,
17};
18
19enum policy_action {
20 POLICY_ALLOW_NATIVE = 0,
21 POLICY_EMULATE_READ,
22 POLICY_EMULATE_WRITE,
23 POLICY_WRITE_MASK,
24 POLICY_DENY_SKIP,
25 POLICY_DENY_UNDEF,
26 POLICY_PAUSE,
27 POLICY_PANIC,
28};
29
30struct policy_entry {
31 uint64_t key;
32 const char *name;
33 enum policy_access_class access_class;
34 enum policy_action read_policy;
35 enum policy_action write_policy;
36 uint64_t reset_value;
37 uint64_t writable_mask;
38 uint32_t logging_level;
39 uint32_t violation_reason;
40};
41
42struct policy_decision {
43 const struct policy_entry *entry;
44 enum policy_action action;
45 uint64_t value;
46 uint32_t reason;
47};
48
49enum policy_profile {
50 POLICY_PROFILE_STRICT = 0,
51 POLICY_PROFILE_DIAGNOSTIC,
52 POLICY_PROFILE_LINUX_BOOT,
53 POLICY_PROFILE_DEBUG,
54};
55
56void policy_init(void);
57bool policy_set_profile(enum policy_profile profile);
58bool policy_set_profile_name(const char *name);
59enum policy_profile policy_get_profile(void);
60const char *policy_profile_name(enum policy_profile profile);
61const struct policy_entry *sysreg_policy_lookup(uint64_t key);
62bool policy_apply_sysreg(struct vcpu *vcpu, const struct sysreg_access *access,
63 uint64_t operand, struct policy_decision *decision);
64void policy_dump(void);
65bool policy_selftest(void);
66
67#endif