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

How should design process unimplemented pmp csr and performance counter? #1011

Closed
jinyinghan324 opened this issue Apr 13, 2023 · 3 comments

Comments

@jinyinghan324
Copy link

If 16 PMP CSRs are implemeted, how should design process csr instructions to pmpaddr16~63? Illegal instruction or read-only 0?

And if 20 performance counter(mhpmcounter3-22) are implemented, how should design process csr instructions to mhpmcounter23-31? Illegal instruction or read-only 0?

@scottj97
Copy link
Contributor

"Implemented", when it comes to CSRs, means that they do not take an illegal instruction exception. Read-only 0 counts as "implemented". For PMP, when the spec says "Implementations may implement zero, 16, or 64 PMP entries" that refers only to which ones take an illegal instruction exception. You can make any number of the implemented PMP CSRs read-only 0.

For your specific question about pmpaddr16-63, you can do either illegal instruction or read-only 0, but they must all have the same behavior. (For example, having pmpaddr16-31 read-only 0 and pmpaddr32-64 take an illegal instruction exception would not be a legal implementation.)

For performance counters, the spec says, "All counters should be implemented, but a legal implementation is to make both the counter and its corresponding event selector be read-only 0." Which means you must not take an illegal instruction exception on any of the 29 event counters, but mhpmcounter23-31 and mhpmevent23-31 can be read-only 0.

@pdonahue-ventana
Copy link
Contributor

Adding emphasis:

For performance counters, the spec says, "All counters should be implemented, but a legal implementation is to make both the counter and its corresponding event selector be read-only 0." Which means you must not take an illegal instruction exception on any of the 29 event counters, but mhpmcounter23-31 and mhpmevent23-31 can be read-only 0.

I think that you should not take an illegal instruction exception on any of the counters, though that is technically allowed. (I encourage you to not make an implementation that tests the limits of the architecture. I'm just being pedantic.)

@jinyinghan324
Copy link
Author

Thank you!

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

3 participants