Skip to content

Improve stack pointer swap #539

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

Open
christian-herber-nxp opened this issue May 28, 2025 · 0 comments
Open

Improve stack pointer swap #539

christian-herber-nxp opened this issue May 28, 2025 · 0 comments

Comments

@christian-herber-nxp
Copy link
Collaborator

The stack pointer swap mechanism currently relies on the notion of levels to decide if a stack pointer swap is necessary.
This makes it rely on Smlic.
Also, this may lead to issues in double trap scenarios, or requires additional spec corner cases.

To make it more general, I propose the following:

The stack pointer register will have the low bits reserved as per the RISC-V calling convention. We can use the LSb to differentiate if the stack pointer belongs to regular execution or trap handling.
This way, upon entering the trap handler, the stack pointer can be swapped depending on whether the LSb of the xsp register has the LSb asserted or not. This also simplifies the overall logic, and arguably eases DV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant