Skip to content

Comments

Make vm_map_prot2perm properly MD.#2566

Merged
qwattash merged 3 commits intodevfrom
prot2perm-rework
Feb 24, 2026
Merged

Make vm_map_prot2perm properly MD.#2566
qwattash merged 3 commits intodevfrom
prot2perm-rework

Conversation

@qwattash
Copy link
Contributor

@qwattash qwattash commented Feb 19, 2026

This should simplify the handling of prot2perm in a few ways:

  1. Remove the level of indirection for defining PROT2PERM permission bits. These have to be followed across a couple of #define layers otherwise.
  2. Remove the use of CHERI_PROT2PERM_MASK, instead add a base_perms argument to vm_map_prot2perm so that it is clearer that the permissions are being "inherited" from a base bitmask and modified according to VM_PROT.

Currently this places vm_map_prot2perms in cheri_machdep.c, it is unclear to me whether this is the right place. It may also make sense to rename it to something else.

Copy link
Member

@brooksdavis brooksdavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the too-long lines in the arm64 vm_map_prot2perms implementation I think this is good.

Copy link
Member

@brooksdavis brooksdavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one more comment. I wonder if vm_map_prot2perms should be vm_prot2perms now that it's no longer in vm_map.c.

@qwattash
Copy link
Contributor Author

Sorry, one more comment. I wonder if vm_map_prot2perms should be vm_prot2perms now that it's no longer in vm_map.c.

Yeah I have a similar feeling that the name / placement may not be entirely right. I considered also moving it to vm_machdep, but given that it is a cheri-specific thing perhaps it fits well in cheri_machdep.
I will change the name to vm_prot2perms though.

Remove the definition indirection via CHERI_PERMS_PROT2PERM_*; instead,
make vm_map_prot2perms fully machine-dependent.

Since vm_map_prot2perms is no longer in vm_map.c, rename it to vm_prot2perms.

Add a base_perms argument to vm_prot2perms. This removes the direct use of
CHERI_PROT2PERM_MASK and makes it clearer that the permission mask
is inherited from a base permission bitmask that is altered according
to VM_PROT_*.

Add a CHERI_PERMS_RWX_MASK macro that serves a similar function as
CHERI_PROT2PERMS_MASK, but this is more general.
This is useful to clearly separate the permission bits that the system
implicitly ties to RWX memory access from the permission bits that are
part of other mechanisms, such as c18n, sealing, etc.
Note that this serves a different purpose from the existing USER/KERNEL
permission bit macros.
This prevents issuing PERM_SYSCALL for data capabilities.
@qwattash qwattash merged commit fb7e119 into dev Feb 24, 2026
30 checks passed
@qwattash qwattash deleted the prot2perm-rework branch February 24, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants