-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add stack overflow detection to sw-emulator #1785
base: main
Are you sure you want to change the base?
Conversation
6534995
to
15c3882
Compare
15c3882
to
c1836a9
Compare
c1836a9
to
d6f8397
Compare
sw-emulator/lib/cpu/src/cpu.rs
Outdated
/// Checks if the stack will overflow when pushed to `stack_address`. | ||
/// | ||
/// Returns `true` if the stack will overflow, `false` if it will not overflow. | ||
pub fn check_overflow(&mut self, stack_address: u32) -> bool { |
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.
The stack info is only based on one fw stage (i.e. ROM, FMC, or RT). It's not clear to me how the emulator should know that the stack is relevant for a given fw stage.
Idk if this is too convoluted, but one thing we could do is have the stack tied to a certain ICCM range.
e.g. If PC is in range [A, B], SP must be in range [X, Y]
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'll work on adding that change
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.
Updated to check multiple code ranges / stacks
d6f8397
to
a99ab23
Compare
Added stack monitoring and overflow detection to the SW emulator
If a stack overflow is detected, the emulator will panic and cause test failure.
This resolves #1735