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

NA4 Region not calculated correctly #587

Closed
MuhammadHammad001 opened this issue Oct 11, 2024 · 4 comments
Closed

NA4 Region not calculated correctly #587

MuhammadHammad001 opened this issue Oct 11, 2024 · 4 comments

Comments

@MuhammadHammad001
Copy link
Contributor

The implementation for address upper range calculation for NA4 is not correct. Please refer to:
https://github.com/riscv/sail-riscv/blob/f7192a642242a718290524a77797b11fcf6783b6/model/riscv_pmp_control.sail#L18C1-L23C16

    NA4   => {
               // NA4 is not selectable when the PMP grain G >= 1. See pmpWriteCfg().
               assert(sys_pmp_grain() < 1, "NA4 cannot be selected when PMP grain G >= 1.");
               let lo = pmpaddr;
               Some((lo, lo + 4))
             },

The correct implementation should be:

    NA4   => {
               // NA4 is not selectable when the PMP grain G >= 1. See pmpWriteCfg().
               assert(sys_pmp_grain() < 1, "NA4 cannot be selected when PMP grain G >= 1.");
               let lo = pmpaddr;
               Some((lo, lo + 1))
             },

This will properly configure the NA4 region equal to 4B instead of 16B.

@MuhammadHammad001
Copy link
Contributor Author

PR # 588

@Timmmm
Copy link
Collaborator

Timmmm commented Oct 11, 2024

Ah good spot. This got missed when we updated the function to return words instead of bytes (to fix 34 bit physical addresses on RV32). How did you find this bug out of interest? (I think our internal testing didn't find it because our CPU doesn't support NA4 :-/ ).

@MuhammadHammad001
Copy link
Contributor Author

MuhammadHammad001 commented Oct 11, 2024 via email

@Timmmm Timmmm closed this as completed Oct 11, 2024
@allenjbaum
Copy link
Collaborator

allenjbaum commented Oct 11, 2024 via email

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