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

Pmp tests #284

Closed
wants to merge 5 commits into from
Closed

Conversation

UmerShahidengr
Copy link
Collaborator

Dear All,
This PR contains Priv Arch compliance tests. This repo will be updated weekly with new priv arch tests. These short PRs will be easier to review on weekly basis. In the first iteration, a few basic PMP compliance tests have been pushed for review.

@allenjbaum
Copy link
Collaborator

allenjbaum commented Sep 19, 2022 via email

@pawks
Copy link
Collaborator

pawks commented Sep 20, 2022

What is going to be important in order to merge these tests are that - they compare between Sail and Spike (I think you already verified this) - that risc-isac can verify coverage. That means you need to be able to describe the coverage using a YAML ctg schema description. I think you'll find that this will be as hard as writing the tests, but it is important.

There is a small hitch in this case. The csr coverpoints are currently defined over the values in the csrs. So the coverpoints for the pmpaddr csr can be defined only based on the value contained in them. However, it is perfectly legal for the values to be different based on the implementation defined address space, meaning that the coverpoint itself changes between implementations. There are two possible ways to handle this:

  • Allow for the coverpoints to be different based on the implementation and assume a default for SAIL. Since the coverage is primarily measured on SAIL, this allows us to easily measure coverage but the coverpoints are tied to a specific memory map.
  • Define the coverpoints based on the behaviour of the pmp, making them independent of the actual addresses i.e use the effective address of the access and write expressions which mimic the pmp match and priority functions to check for coverage. Doing so will require some more discussion and adding support for the same in isac.

Your written descriptions are a start, but the need to be fleshed out with the real corner cases in that YAML format (e.g. - 2 matches from both first and last PMP entry, - intervening entries being non-matching (including off) - the first is a wider range than the last, or a smaller or overlapping - 4 combinations of illegal/legal - for each of the permission bits. Another might be 3 entries: 2 abutting, and a 3rd overlapping the other two for just 8bytes (which I think can only occur on an RV64 with a doubleword data fetch) with - 6 different prioriity orders, - 3 different accesses (matching entirely in the 1st, 2nd or 3rd entry) - 8 different legal/illegal combinations, - both loads and stores

The tests also should be easily configurable to account for the following:

  • Granularity of the pmps
  • Write-ability of the pmp* csrs
  • Number of pmp csrs defined

Another corner case which needs to be considered is partial matches. This particular case is applicable for mem accesses only when the granularity of the pmps is 4 and the XLEN is 64 or the D extension exists. However, this is applicable for instruction accesses when the C extension exists regardless of the granularity of the csrs.

@UmerShahidengr
Copy link
Collaborator Author

  • that risc-isac can verify coverage. That means you need to be able to describe the coverage using a YAML ctg schema description. I think you'll find that this will be as hard as writing the tests, but it is important.

Since ISAC has limitation on adding coverpoints. I added csr coverpoints which were defined over the values in the pmp registers, I submitted that PR at riscv-ctg with updated cfg files, I will update those cfg files according to the test cases for each upcoming test

@UmerShahidengr
Copy link
Collaborator Author

  • Allow for the coverpoints to be different based on the implementation and assume a default for SAIL. Since the coverage is primarily measured on SAIL, this allows us to easily measure coverage but the coverpoints are tied to a specific memory map.
  • Define the coverpoints based on the behaviour of the pmp, making them independent of the actual addresses i.e use the effective address of the access and write expressions which mimic the pmp match and priority functions to check for coverage. Doing so will require some more discussion and adding support for the same in isac.

Dear @pawks , I am not sure if I understand it fully. I'll dig in to it, but I might need more help in this regard. I will ping you offline in case of any query. In the meantime, can you refer me to some good documentation on understanding cgf files in more detail?

@UmerShahidengr
Copy link
Collaborator Author

  • Granularity of the pmps
  • Write-ability of the pmp* csrs
  • Number of pmp csrs defined

Another corner case which needs to be considered is partial matches. This particular case is applicable for mem accesses only when the granularity of the pmps is 4 and the XLEN is 64 or the D extension exists. However, this is applicable for instruction accesses when the C extension exists regardless of the granularity of the csrs.

Point noted. We are actually following this testplan, you can review our testplan and give your feedback, we will add more tests to cover the corner point which you mentioned.

@pawks
Copy link
Collaborator

pawks commented Sep 20, 2022

Dear @pawks , I am not sure if I understand it fully. I'll dig in to it, but I might need more help in this regard. I will ping you offline in case of any query. In the meantime, can you refer me to some good documentation on understanding cgf files in more detail?

A description of the various types of coverpoints and their functions can be found here.

@UmerShahidengr
Copy link
Collaborator Author

A description of the various types of coverpoints and their functions can be found here.

Thanks.

@pawks
Copy link
Collaborator

pawks commented Sep 22, 2022

The tests should also mention the conditions for it to be enabled in the TEST_CASE macros. It would probably be better if the tests are organized in such a way that all related test cases for a particular pmpentry in a single test. All the tests in the PR for the L bit only test their warl behaviour. However, the same test can be leveraged to test for the matching and permission logic too.

@pawks
Copy link
Collaborator

pawks commented Sep 22, 2022

Another thing which should probably be accounted for is the Smepmp spec as it changes the behavior of the pmps. They will definitely influence the conditions for these tests.

@UmerShahidengr
Copy link
Collaborator Author

Another thing which should probably be accounted for is the Smepmp spec as it changes the behavior of the pmps. They will definitely influence the conditions for these tests.

Agreed. The addition of Smepmp will definitely change the conditions and test cases of these tests (and we are also looking forward to work on it), but since Sail does not have full support of ePMP yet and we are still naive in this environment, so why not if you declare these tests as beta version (or something with partial completion status), and review it as first draft. We will keep improving these tests with the passage of time and with each update in golden model.

@UmerShahidengr
Copy link
Collaborator Author

The tests should also mention the conditions for it to be enabled in the TEST_CASE macros. It would probably be better if the tests are organized in such a way that all related test cases for a particular pmpentry in a single test. All the tests in the PR for the L bit only test their warl behaviour. However, the same test can be leveraged to test for the matching and permission logic too.

Agreed to this point too. Yes we can add all possible test cases of one particular pmpentry in one single test but that will complicate the test structure especially when we incorporate the behavior of each test case in different privilege mode (S,U, H).
We are following it step-by-step. In the first go, we have written tests to verify the warl behavior of L-bit in pmpcfg_lock_bit test (as you mentioned). Similarly, we are testing if pmp regs are accessible in only M-mode or not in pmp_csr_access test.Same can be said for pmp TOR mode tests, NAPOT mode tests, and NA4 mode tests. Combining all possible scenerios wrt particular pmp entry will complicate the understanding of these tests. If you see the test plan, things will become complicated in future PRs (when tests related to priorities & matching, and paging will come into play)

@allenjbaum
Copy link
Collaborator

allenjbaum commented Sep 22, 2022 via email

@UmerShahidengr
Copy link
Collaborator Author

In this week's commit, the following changes are made:

  • Based on Allen's comments, in PMP-CFG-reg.S tests for locked bit and zero bits are merged.
  • code size is reduced by adding macros and .rept directive.
  • coverpoints for pmpcfg tests are added in rv32i_priv.cgf.
    Hopefully, all other coverpoints and pmp tests will be merged till next week, contributors are requested to review the draft.

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 this pull request may close these issues.

3 participants