-
Notifications
You must be signed in to change notification settings - Fork 151
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
Initial Rust CMSE support #189
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thejpster (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
oops forgot some Clippy lints |
This is amazing! Perhaps there would be shared interest to setup a sub-working group to advance the state of TrustZone-M in Rust? I believe @thejpster and @jonas-schievink have been experimenting with the nRF53? also ping @perlindgren and @japaric. |
I have a couple of safety questions, but otherwise this looks great! Thank you so much :) |
I checked the ARMv8 Architecture Reference Manual, and it says the instruction is decoded like this:
The
Not sure we need a dedicated subgroup or subteam for this, it seems to fit the Cortex-M team perfectly. While I'm not terribly interested in TrustZone support (since I don't see any use case for it that I find personally interesting), I'm always up for reviewing PRs, and adding support to cortex-m-rt for generating veneers in Non-Secure Callable regions does kinda sound like fun. |
Just to add to what @jonas-schievink said (I agree), from Armv8-M ARM (in the glossary):
And rule RKJPM says that the For TrustZone support as a whole, the steps missing would be:
There is also some scripting needed to build, link and flash Secure and Non-Secure projects together. I am building a simple blinky example using TrustZone and grouping together all of the elements above. |
Armv8-M and Armv8.1-M architecture profiles have an optional Security Extension which provides a set of Security features. This patch adds initial support of the Cortex-M Security Extensions but providing support for the TT intrinsics and helper functions on top of it in the newly added cmse module of this crate. The code is a Rust idiomatic implementation of the C requirements described in this document: https://developer.arm.com/docs/ecm0359818/latest Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
Clippy complains that error: this match could be written as a `let` statement
--> src/asm.rs:9:5
|
9 | / match () {
10 | | #[cfg(all(cortex_m, feature = "inline-asm"))]
11 | | () => unsafe { asm!("bkpt" :::: "volatile") },
12 | |
... |
23 | | () => unimplemented!(),
24 | | }
| |_____^
|
= note: `-D clippy::match-single-binding` implied by `-D warnings`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
help: consider using `let` statement
|
9 | let () = ();
10 | unsafe {
11 | extern "C" {
12 | fn __bkpt();
13 | }
14 |
... It seems like a false positive to me. Is that a bug in Clippy? Should I |
The problem is that you cannot |
Would you be happy if I allow |
Clippy complains that the match expressions used for cfg gating could be rewritten as a let statement, this is a false positive. Also adds inline on two functions. Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
Added a new |
bors r+ |
Build succeeded |
Armv8-M and Armv8.1-M architecture profiles have an optional Security Extension which provides a set of Security features.
This patch adds initial support of the Cortex-M Security Extensions but providing support for the TT intrinsics and helper functions on top of it in the newly added
cmse
module of this crate.The code is a Rust idiomatic implementation of the C requirements described in this document: https://developer.arm.com/docs/ecm0359818/latest
Executed
assemble.sh
to generate the new static libraries containing theTT*
instructions. Testedcheck_blobs.sh
locally and it passed.Tested on QEMU using the
mps2-an505
machine.