Add mcounteren register#2403
Conversation
58188e6 to
63fb24f
Compare
gautschimi
left a comment
There was a problem hiding this comment.
The changes look all good to me! Just a few minor comments. (I did not look at the two WIP commits about formal)
| CSR_HPMCOUNTER20, CSR_HPMCOUNTER21, CSR_HPMCOUNTER22, CSR_HPMCOUNTER23, | ||
| CSR_HPMCOUNTER24, CSR_HPMCOUNTER25, CSR_HPMCOUNTER26, CSR_HPMCOUNTER27, | ||
| CSR_HPMCOUNTER28, CSR_HPMCOUNTER29, CSR_HPMCOUNTER30, CSR_HPMCOUNTER31: begin | ||
| csr_rdata_int = mhpmcounter[mhpmcounter_idx][31:0]; |
There was a problem hiding this comment.
should we assign this to zero if the condition below does not match?
There was a problem hiding this comment.
I was wondering the same. The values currently never make it to the register file because we trap, but we could also gate it to prevent any potential security concerns.
| .out_o(fetch_enable_buf) | ||
| ); | ||
|
|
||
| prim_buf #(.Width($bits(ibex_mubi_t))) u_mcounteren_writable_buf ( |
There was a problem hiding this comment.
what is this buffer used for?
There was a problem hiding this comment.
I was following the fetch_enable example here, which says to buffer security critical signals to prevent synthesis optimisation removing them.
| @@ -0,0 +1,224 @@ | |||
| # Copyright lowRISC contributors. | |||
There was a problem hiding this comment.
This test is good! It verifies that the counters are accessible or not depending on mcounteren.
Maybe we can add a short test that also verifies that the read values are correct.
There was a problem hiding this comment.
I can add this, that should not be difficult.
| @@ -60,6 +60,14 @@ | |||
| test_srcs: empty/empty.S | |||
There was a problem hiding this comment.
did something change in this file (except for the new mcounteren_test)? The diff is big. Did the order of the tests change or was something real added?
There was a problem hiding this comment.
No, this is what I was also confused about. The order seems to change every time I add a test or even modify the description of the test. This makes it quite hard to check the diff. I was wondering whether someone with more experience with this tool had any insights on this.
|
I disabled the check of the mcounteren CSR in the formal verification for now. Another reason for the failure of the formal verification was that we ran out of memory on the runner that has twice as many cores but half as much memory available. I'll address this in a separate PR and rebase once merged. |
This PR adds the
mcounterenregister, which has so far been tied to zero and implements the U-mode performance counter aliases. Themcounterenregister can be locked with an external MUBI signal (mcounteren_writable_i).DV:
This PR adds two directed tests:
mcounteren_testgoes through multiple configurations of the mcounteren register and validates that u-mode can only access the ones enabled.mcounteren_lock_testverifies that the mcounteren CSR cannot be modified without themcounteren_writable_isignal being set.To Dos:
dv/uvm/core_ibex/directed_tests/directed_testlist.yamlchanges a lot everytime I regenerate it after even small modifications. This polluted the diff quite a bit. Is this expected?