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

Add S-mode shadow for debug CSRs #58

Closed
AoteJin opened this issue Aug 27, 2024 · 7 comments
Closed

Add S-mode shadow for debug CSRs #58

AoteJin opened this issue Aug 27, 2024 · 7 comments
Assignees

Comments

@AoteJin
Copy link
Collaborator

AoteJin commented Aug 27, 2024

To align with RISC-V, the specification will add a set of S-mode shadows for the debug CSRs: dcsr, dpc, and dscratch*.

@AoteJin AoteJin self-assigned this Aug 27, 2024
@pdonahue-ventana
Copy link
Contributor

Can you explain why there would need to be S-mode shadows for those CSRs?

(Due to my own bandwidth limitations, I only partially pay attention to what's going on here so I might have missed a previous discussion about this.)

@AoteJin
Copy link
Collaborator Author

AoteJin commented Aug 28, 2024

The external debug security spec adds constraints on the debugger, potentially limiting it to S-mode privilege only. In such cases, the debugger would lose access DCSR, DPC, DSCRATH*. Currently, the spec allows access to those CSRs in debug mode regardless privilege granted to the debugger. However, this approach is not very much aligned with RISC-V style, and we discussed in TG meeting to add a set of S-mode shadow for DCSR, DPC, DSCRATCH* to be more consistent.

@pdonahue-ventana
Copy link
Contributor

Unfortunately, I have a conflicting meeting during the Tuesday TG meeting so I haven't been able to come.

My understanding is that if the debugger is limited to S-mode privilege then halting will still take you to Debug Mode. The debug spec says that in Debug Mode "All operations are executed with machine mode privilege, except that additional Debug Mode CSRs are accessible..." My assumption was that the external debug security spec would say something like "If Debug Mode is limited to S-mode privilege then all operations are executed with supervisor mode privilege, except that additional Debug Mode CSRs are accessible..." (I know that the top two bits of the CSR address encode the mode. However, that already doesn't apply to dcsr/dpc/dscratch*.)

My main concern is that I don't think that these registers should be accessible to an operating system. Maybe I'm missing a subtlety of the proposal. If the proposal is that the new CSRs are only accessible to the external debugger but (like with the current Sdext) not accessible when running normal S-mode or M-mode software then this is OK with me.

@AoteJin
Copy link
Collaborator Author

AoteJin commented Aug 28, 2024

My main concern is that I don't think that these registers should be accessible to an operating system. Maybe I'm missing a subtlety of the proposal. If the proposal is that the new CSRs are only accessible to the external debugger but (like with the current Sdext) not accessible when running normal S-mode or M-mode software then this is OK with me.

Right, this update is not intended to extend the access scope of the debug CSRs, and none of them should be accessible outside of debug mode .
As you mentioned, one of the purpose is to simplify the implementation by leveraging the address based logic to regulate the CSR access from debugger.

@pdonahue-ventana
Copy link
Contributor

none of them should be accessible outside of debug mode

Perfect. Then I have no objections.

@AoteJin
Copy link
Collaborator Author

AoteJin commented Sep 4, 2024

PR #60 to submit the update

@AoteJin
Copy link
Collaborator Author

AoteJin commented Sep 23, 2024

Close with PR merged.

@AoteJin AoteJin closed this as completed Sep 23, 2024
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

No branches or pull requests

2 participants