snmalloc
snmalloc copied to clipboard
memcpy vs StrictProvenance
More Lincoln Logs-style work, mostly: assemble existing pieces differently for a StrictProvenance
/ CHERI-aware memcpy
. As documented, there are two constraints in tension:
- We must use capability load and store instructions wherever possible, so that our
memcpy
obliviously copies capabilities (and preserves tags) during its operation. - We cannot use capability load or store instructions at misaligned addresses, since those (are permitted to) trap.
Therefore, we have three cases to consider:
- copies too small to move a capability: use a jump table of data word copies and be done with it
- "equally (mis)aligned" source and targets: these may have a (naturally aligned) capability inside the source that would also land at a naturally aligned destination address: perform data word copies to get us up to
alignof(void*)
, perform capability copies, and then go back to doing data word copies to get us up to the end. - differently aligned source and targets: since at least one of these must be misaligned relative to capabilities, use exclusively data word copies, which will result in the destination having all capability tags clear.
The only part of this that isn't (relatively) straightforward assembly of existing pieces is the change to copy_one
to not use __builtin_memcpy_inline
on StrictProvenance
architectures to work around (or work with?) https://github.com/CTSRD-CHERI/llvm-project/issues/623 .