AArch64 EL2 hypervisor for QEMU virt that boots at EL2
1

Configure Feed

Select the types of activity you want to include in your feed.

Introduce policy lattice validation for privileged register classes

+49
+49
core/policy.c
··· 54 54 static enum policy_profile g_profile; 55 55 static struct policy_entry g_effective_entry; 56 56 57 + static bool policy_action_valid(enum policy_action action) 58 + { 59 + return action == POLICY_ALLOW_NATIVE || 60 + action == POLICY_EMULATE_READ || 61 + action == POLICY_EMULATE_WRITE || 62 + action == POLICY_WRITE_MASK || 63 + action == POLICY_DENY_SKIP || 64 + action == POLICY_DENY_UNDEF || 65 + action == POLICY_PAUSE || 66 + action == POLICY_PANIC; 67 + } 68 + 69 + static bool policy_class_valid(enum policy_class access_class) 70 + { 71 + return access_class == POLICY_CLASS_ID || 72 + access_class == POLICY_CLASS_MMU || 73 + access_class == POLICY_CLASS_TIMER || 74 + access_class == POLICY_CLASS_THREAD || 75 + access_class == POLICY_CLASS_PMU || 76 + access_class == POLICY_CLASS_DEBUG || 77 + access_class == POLICY_CLASS_EL2_EL3 || 78 + access_class == POLICY_CLASS_MISC; 79 + } 80 + 81 + static bool policy_lattice_valid(const struct policy_entry *entry) 82 + { 83 + if (entry == (const struct policy_entry *)0 || entry->name == (const char *)0) { 84 + return false; 85 + } 86 + if (!policy_class_valid(entry->access_class) || 87 + !policy_action_valid(entry->read_policy) || 88 + !policy_action_valid(entry->write_policy)) { 89 + return false; 90 + } 91 + if (entry->access_class == POLICY_CLASS_EL2_EL3 && 92 + (entry->read_policy != POLICY_DENY_UNDEF || 93 + entry->write_policy != POLICY_DENY_UNDEF)) { 94 + return false; 95 + } 96 + if (entry->write_policy == POLICY_WRITE_MASK && entry->writable_mask == 0u && 97 + entry->access_class != POLICY_CLASS_DEBUG) { 98 + return false; 99 + } 100 + return true; 101 + } 102 + 57 103 void policy_init(void) 58 104 { 59 105 g_profile = POLICY_PROFILE_STRICT; ··· 268 314 enum policy_profile saved = g_profile; 269 315 bool profile_ok; 270 316 for (uint32_t i = 0; i < HV_ARRAY_SIZE(g_policy); i++) { 317 + if (!policy_lattice_valid(&g_policy[i])) { 318 + return false; 319 + } 271 320 if (sysreg_policy_lookup(g_policy[i].key) != &g_policy[i]) { 272 321 return false; 273 322 }