Skip to content

Add UDF instruction. Closes #199. #201

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

Merged
merged 3 commits into from
Mar 15, 2020
Merged

Add UDF instruction. Closes #199. #201

merged 3 commits into from
Mar 15, 2020

Conversation

adamgreig
Copy link
Member

No description provided.

@adamgreig adamgreig requested a review from a team as a code owner March 15, 2020 19:41
@rust-highfive
Copy link

r? @ithinuel

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m labels Mar 15, 2020
@jonas-schievink
Copy link
Contributor

I wonder if we should make the function diverge. There is not really any useful recovery that an exception handler could perform (and such a handler can't currently be written anyways).

@adamgreig
Copy link
Member Author

It's not necessarily useful but if you defined a custom UsageFault handler (which you can do in c-m-rt) which did nothing, would execution continue from after the udf instruction, or do you immediately UsageFault again?

I think irregardless if you're deliberately calling cortex_m::asm::udf() you probably don't intend to continue execution from this branch, so I'll update the call to be divergent and add an infinite loop.

@jonas-schievink
Copy link
Contributor

A UsageFault handler that deliberately continues past opcodes that are expected to trap is certainly UB, so we don't really have to worry about that. This means that it should be fine to assume that the udf itself diverges, so the bx lr can be omitted and the infinite loop can be replaced with unreachable_unchecked.

In some cases fault handlers can return safely, for example when a userspace process causes a HardFault (the kernel might terminate the process and schedule another), but that's not really an issue here (though udf does cause a HardFault on thumbv6 from what I recall).

@adamgreig
Copy link
Member Author

Sure, makes sense. I've updated to use unreachable_unchecked().

Copy link
Contributor

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 15, 2020

Build succeeded

@bors bors bot merged commit 66c83bb into master Mar 15, 2020
@bors bors bot deleted the udf branch March 15, 2020 23:42
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
201: Add binary for armv8 hardfloat r=korken89 a=aurabindo

Fixes build for `thumbv8m.main-none-eabihf`

Co-authored-by: Aurabindo Jayamohanan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants