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

Ssdbltrp - VS mode double trap check #1799

Closed
lewislzh opened this issue Sep 9, 2024 · 4 comments · Fixed by #1804
Closed

Ssdbltrp - VS mode double trap check #1799

lewislzh opened this issue Sep 9, 2024 · 4 comments · Fixed by #1804

Comments

@lewislzh
Copy link

lewislzh commented Sep 9, 2024

In Spike's double trap check for VS/S mode, the current code accesses state.nonvirtual_sstatus in VS mode and state.sstatus in S mode.
processor.cc#L447-L453
I think this reverses the intended access to the VS/S status registers, preventing the correct execution of double traps in VS mode.
Moreover, I think it might not be necessary to use curr_virt to select between VS and S status registers.
Spike inherently supports accessing sstatus based on the current virtualization mode, reading from either sstatus or vsstatus as appropriate.
Therefore, we might consider adjusting line 466 to: reg_t s = state.sstatus->read();

@aswaterman
Copy link
Collaborator

@ved-rivos can you take a look at this?

@ved-rivos
Copy link
Contributor

I think this reverses the intended access to the VS/S status registers, preventing the correct execution of double traps in VS mode

Yes. Thanks for spotting that.

Therefore, we might consider adjusting line 466 to: reg_t s = state.sstatus->read();

I am not sure that is right. Please see use of nonvirtual_sstatus vs. sstatus in rest of the function.

I sent a PR #1804 to swap it. @aswaterman please let me know if its right to just use sstatus->read(). Will it resolve to the sstatus or vstatus internally?

@aswaterman
Copy link
Collaborator

@ved-rivos I'll follow up on the PR.

@ved-rivos
Copy link
Contributor

@aswaterman - Thanks. I have updated the PR.

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

Successfully merging a pull request may close this issue.

3 participants