opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[tlul] ensure we can't execute from registers

Open udinator opened this issue 5 years ago • 7 comments

Support for InstrType instruction fetches has been added to memories via tlul_adapter_sram, but there are no checks to make sure that we can't execute from an IP's CSRs (for example the KMAC state window).

This will require a bit of RTL and DV overhead - tlul_adapter_reg will have to be updated to only allow DataType transactions, and a common DV test should be added to drive instruction fetch transactions to all CSRs in an IP's regfile.

udinator avatar Apr 23 '21 17:04 udinator

How would we execute from KMAC CSRs? Only a very limited set of IPs are connected to the instruction fetch bus of Ibex (https://github.com/lowRISC/opentitan/blob/master/hw/top_earlgrey/data/xbar_main.hjson#L154).

imphil avatar Apr 23 '21 18:04 imphil

Indeed, I think this case should not occur since there is no physical connection between ifetch port and peripheral CSR nodes.

msfschaffner avatar Apr 23 '21 18:04 msfschaffner

o that's a good point. I kind of forgot about the fact that the fabric is physically disconnected.

I guess this applies more if in the future we have cases where executable memories are wrapped up inside modules. And if those paths have separate registers built-in. As an example flash may fall into this category when we do the merge.

tjaychen avatar Apr 23 '21 19:04 tjaychen

i think one more thing to Udi's point.. is that the disconnected fabric is more or less a top level decision. But from a block level perspective, that assumption may not always be true. So since it's cheap to add a "no instructions" check into tlul_adapter_reg, it is probably still worth doing.

tjaychen avatar Apr 23 '21 19:04 tjaychen

ah thanks @imphil and @msfschaffner , I had not checked the xbar to check what was actually connected to the core.

I was thinking of this more from an IP-level perspective though, e.g. the KMAC testbench may not know that it is not connected to the CPU so it still could be worth checking that InstrType transactions don't go through just to cover this scenario. wdyt?

udinator avatar Apr 23 '21 19:04 udinator

Sorry for the long silence on this one. I think this is a good idea, let's add a check for this to tlul_adapter_reg.

msfschaffner avatar Jun 03 '21 20:06 msfschaffner

I believe this check has been added to tlul_err.sv, so closing this issue.

udinator avatar Oct 08 '21 00:10 udinator