Add TBI helpers for AArch64 - #1622
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) some time within the next two weeks. |
|
☔ The latest upstream changes (presumably 5097cfb) made this pull request unmergeable. Please resolve the merge conflicts. |
Adds a new `TBIBox` type in `core_arch`, which allows for modifying the top byte of the address that the allocation lives at. Modifying the top byte reallocates the data, thereby invalidating any existing pointers and avoiding aliasing.
| ) | ||
| }; | ||
| // Reconstruct the `Box` using the address with the new top byte and return that, wrapped as a TBIBox | ||
| Self(Some(unsafe { Box::from_raw(ptr) }), original_ptr, top_byte) |
There was a problem hiding this comment.
This doesn't hide things sufficiently well from the compiler. The compiler can still see that ptr is just the same as original_ptr with an offset applied -- making this still UB.
You need the computation of ptr itself to occur in a "black box".
There was a problem hiding this comment.
Ah yes I see, maybe I could move the step that actually sets the top byte i.e. addr | top_byte_shifted into the inline asm block and do it there with an explicit ORR, do you think that would work?
|
Because the TBIBox interacts with Box and does allocations, it does not actually fit into stdarch - this will be moved into |
|
☔ The latest upstream changes (presumably 21a2557) made this pull request unmergeable. Please resolve the merge conflicts. |
|
☔ The latest upstream changes (possibly #2053) made this pull request unmergeable. Please resolve the merge conflicts. |
Adds a trait to
core_archfor AArch64 to set a value in the top byte of a pointer (which should logically become the canonical address of the allocation), and to retrieve the value stored in the top byte of a pointer, if any.The intent is for a Rust-provided mechanism for such adjustments to pointers, so that any internal pointer tracking could be updated as necessary, such as to enable this pattern within Miri.