-
Notifications
You must be signed in to change notification settings - Fork 292
Miri Experiment #3297
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
Miri Experiment #3297
Conversation
@@ -3663,7 +3663,7 @@ macro_rules! spi_instance { | |||
#[inline(always)] | |||
fn info(&self) -> &'static Info { | |||
static INFO: Info = Info { | |||
register_block: crate::peripherals::[<SPI $num>]::regs(), | |||
register_block: crate::peripherals::[<SPI $num>]::ptr(), |
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.
Wait, this compiles? 👀
This is interesting! Thanks for looking in to this! I'm curious if we can just run all (or a subset) of our HIL tests with miri enabled? That would feel a bit more useful than writing seperate miri specific tests, I think. I've never actually tested any of my projects with MIRI though, so I'm not sure how it's typically used. |
I thought about how we could test usual driver code - one thing that might be possible would be to have a forked svd2rust which produces mock-PACs which Miri won't hate (it definitely hates writing / reading to / from random addresses) - and also our drivers expect something to happen when we write to the hw-registers I think that could work - I am just not very sure if it's a good deal in terms of effort vs benefit - but would definitely be fun to explore |
Apparently the idea of mocking register access is not new: https://crates.io/crates/regmock-rs |
This was a nice experiment! I think we have two options here. We keep this as it is, merge it and we find a "use" (some nicer test cases) for this, or we drop this until we have a test case. What do you think? My main interest is if we can test or catch things like #3555 which we wouldn't catch even with HIL (unless we get lucky or run millions of iterations). |
I think there are good use cases for something like this but there is not much use in keeping this PR open (or merge it). It will stay with us under the closed-PRs so we can easily come back to this once we have something nice to check. TL;DR will close this, but it will still be here for further reference |
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
This isn't intended to get merged (especially not as is)! It's just for exploring and discussing if and how we could make use of MIRI
unsafe { &*Self::PTR }
is not ok for register blocks ( Const validation rejects references that might be dangling (but could actually be valid at run-time) rust-lang/rust#63197 (comment) ) - the first commit here is just to not already fail during compilation#[cfg(miri)]
to make interesting functions availableTesting
n/a