-
Notifications
You must be signed in to change notification settings - Fork 21
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
blog: add post on capability ptr #109
Open
bradjc
wants to merge
2
commits into
master
Choose a base branch
from
capptr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: Talking Tock 58 | ||
subtitle: New pointer type in the kernel | ||
authors: bradjc | ||
--- | ||
|
||
Correctly expressing data types in Rust between userspace and the kernel with | ||
correctly captured semantics is challenging as different hardware platforms | ||
provide different data representations. The common example of this is 32-bit | ||
platforms versus 64-bit platforms which store different sized types in registers | ||
and therefore provide a different amount of data between userspace and the | ||
kernel. Emerging platforms, for example hardware with CHERI support, complicate | ||
this further. With [pull request #4174](https://github.com/tock/tock/pull/4174) | ||
merged, Tock has taken a step to improve this by adding `CapabilityPtr`, a type | ||
within the kernel to clearly express when data within the kernel is a pointer. | ||
|
||
The `CapabilityPtr` Type | ||
------------------------ | ||
|
||
Fundamentally this type stores a pointer to memory. The name "capability" | ||
signifies this type also captures the validity of that pointer and whether the | ||
holder of the pointer can actually use the pointer to access memory. | ||
|
||
Traditionally, a valid pointer in `unsafe` Rust always has the capability to be | ||
dereferenced. That is, the hardware will (at least try to) access the referenced | ||
memory. `CapabilityPtr` expands this abstraction, and enables software to track | ||
whether hardware will permit the memory access, if the hardware has such | ||
restrictions. | ||
|
||
Support for CHERI | ||
----------------- | ||
|
||
The primary driver for adding the `CapabilityPtr` type is the | ||
[CHERI](https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/) extension for | ||
hardware architectures. With CHERI, hardware can track whether a pointer can be | ||
dereferenced. The metadata for that tracking is stored alongside the pointer | ||
address in hardware registers. Tock is targeting a hybrid CHERI ABI which | ||
supports both a traditional pointer and pointers with the CHERI metadata. With | ||
the `CapabilityPtr` type, Tock now has a mechanism to represent these pointers | ||
with metadata that are larger than the machine's `usize` yet `CapabilityPtr` | ||
still represents a single register. | ||
|
||
Adding `CapabilityPtr` is only a first step towards support for CHERI in Tock. | ||
Additional pull requests will fill in the remaining support needed in the Tock | ||
kernel for this hardware support. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When someone talks about running "Rust on CHERI", they're usually referring to a pure-capability CHERI ABI. However, @LawrenceEsswood is porting the Tock kernel to a hybrid CHERI ABI, which has some different properties. One of those properties is that in hybrid CHERI, a language's default pointer types are not CHERI capabilities -- which is the reason why we need
CapabilityPtr
. In purecap CHERI, we don't needCapabilityPtr
, as*mut T
can do the same job.We should probably clarify that
CapabilityPtr
is to support hybrid CHERI, otherwise this may be confusing for readers familiar with the upstream efforts to port Rust to CHERI.(Lawrence, please correct me if I'm wrong about this).
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.
I can try to clarify this, but maybe this indicates this post is helpful as this difference is pretty opaque to me.
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.
Jonathan is correct. At the end of the day both
*const T
andCapabilityPtr
are types in an abstract machine, and what hardware representation they have is always with respect to a given ABI."Legacy" CHERI ABI says that these should be lowered to an integer address
Hybrid CHERI ABIs say that
*const T
should be lowered to an address butCapabilityPtr
to a CHERI capability.Purecap CHERI ABIs say that both should be lowered to a CHERI capability.