-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TBI helpers for AArch64 #1622
base: master
Are you sure you want to change the base?
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.
91238bc
to
bbe68c4
Compare
) | ||
}; | ||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that would be better.
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. |
Adds a trait to
core_arch
for 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.