Skip to content
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

cortex-m: Detect stack overflow #2002

Merged
merged 3 commits into from Jul 20, 2020
Merged

cortex-m: Detect stack overflow #2002

merged 3 commits into from Jul 20, 2020

Conversation

bradjc
Copy link
Contributor

@bradjc bradjc commented Jul 6, 2020

Pull Request Overview

This pull request adds logic to the kernel hardfault handler to detect a stack overflow condition, and resets the stack before using it. With IPC on hail I'm able to trigger this case and verify I get the panic handler.

This also moves the userland state saving down below since I'm not sure why that code was run in both the kernel and userspace fault case.

Fixes #1176.

Testing Strategy

Verifying that IPC on hail causes this panic handler to be displayed.

TODO or Help Wanted

  1. Someone to look over the assembly.

  2. I can copy to m3 once we are happy with it. I'm not sure this will work on cortex-m0 due to differences in the SCB.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

arch/cortex-m4/src/lib.rs Outdated Show resolved Hide resolved
arch/cortex-m4/src/lib.rs Show resolved Hide resolved
arch/cortex-m4/src/lib.rs Outdated Show resolved Hide resolved
@bradjc
Copy link
Contributor Author

bradjc commented Jul 15, 2020

@tock/core-wg

hudson-ayers
hudson-ayers previously approved these changes Jul 15, 2020
Copy link
Member

@ppannuto ppannuto 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 bors bot merged commit 93f799a into master Jul 20, 2020
@bors bors bot deleted the stack-overflow branch July 20, 2020 13:54
bors bot added a commit that referenced this pull request Jul 31, 2020
2043: cortex-m: fix warning about volatile keyword in incorrect position r=bradjc a=hudson-ayers

### Pull Request Overview

#2002 added a volatile keyword in the position intended for clobbers in the assembly responsible for resetting the stack pointer.
This surfaced a warning whenever compiling a cortex-m4 architecture, but this warning did not cause CI to fail because `cd arch/ && RUSTFLAGS="-D warnings" cargo test` ignores code that can't be compiled on the host platform, and we do not deny warnings when compiling all boards.

### Testing Strategy

This pull request was tested by compiling Imix and seeing that the warning is gone.


### TODO or Help Wanted

Ideally we would deny warnings in `ci-job-compilation` so mistakes like this couldn't slip past CI, but passing `RUSTFLAGS="-D warnings"` to the call to `make allboards` within `ci-job-compilation` did not seem to work, and I did not try anything further.

### Documentation Updated

- [x] No updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Hudson Ayers <hayers@stanford.edu>
Co-authored-by: Hudson Ayers <32688905+hudson-ayers@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hard Fault Handler Pushes to Stack
4 participants