On 08/01/2024 11:23, Amit Daniel Kachhap wrote:
[...]
+cheri_perms_t mapping_to_capability_perm(int prot, bool has_tag_access) +{
- cheri_perms_t perms = 0;
- if (mapping_may_have_prot_flag(prot, PROT_READ)) {
perms |= CHERI_PERM_LOAD;
if (has_tag_access)
perms |= CHERI_PERM_LOAD_CAP;
- }
- if (mapping_may_have_prot_flag(prot, PROT_WRITE)) {
perms |= CHERI_PERM_STORE;
if (has_tag_access)
perms |= (CHERI_PERM_STORE_CAP | CHERI_PERM_STORE_LOCAL_CAP);
- }
- if (mapping_may_have_prot_flag(prot, PROT_EXEC)) {
perms |= CHERI_PERM_EXECUTE;
if (cheri_perms_get(cheri_pcc_get()) & CHERI_PERM_SYSTEM_REGS)
cheri_pcc_get() gives you the current PCC, that is the kernel one. We don't have a generic way to access saved (user) capability registers at the moment (i.e. for PCC an equivalent of instruction_pointer()). Since we're already introducing an arch helper, we might as well add this permission there.
Kevin
perms |= CHERI_PERM_SYSTEM_REGS;
- }
- /* Fetch any extra architecture specific permissions */
- perms |= arch_map_to_cap_perm(PROT_MAX_EXTRACT(prot) ? PROT_MAX_EXTRACT(prot) : prot,
has_tag_access);
- perms |= CHERI_PERMS_ROOTCAP;
- return perms;
} #endif /* CONFIG_CHERI_PURECAP_UABI */