opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[sram] memory request during lifecycle escalation + PRINCE key latching

Open udinator opened this issue 5 years ago • 3 comments

Hi @msfschaffner,

I ran into an interesting issue as a result of #5568 that I wanted to bring up, the waveform of the situation is below:

Screenshot from 2021-03-12 11-44-24

Basically, at marker M2 the testbench sends an escalation request of lc_ctrl_pkg::On, which then correctly gets latched by escalated_q three cycles later at the yellow marker.

One cycle before escalate_q goes high, we send in a read request to the memory to address 0x8060032a, which should still be valid as the prim_ram_1p_scr will only lock down all requests once escalated_q is high.

However, halfway through the keystream generation for the read data decryption, the input key to the PRINCE cipher changes, since escalation resets the key and nonce back to the default netlist constants. Since the PRINCE currently does not latch its input key, it absorbs the reset key values during the second stage of its internal pipeline, causing an incorrect data value to result from the decryption.

The most straightforward solution here would be to enable the HalfwayKeyReg parameter in PRINCE to prevent this sort of edge case issue from occurring again (I've confirmed this locally), wdyt?

udinator avatar Mar 12 '21 20:03 udinator

Hey @udinator,

Indeed, this corner case can occur due to the lack of the key pipeline register in the PRINCE module. I have not instantiated this register because it is really costly (128bit), and this corner case is technically not something that we care about. I.e., once we escalate, we want to escalate as soon as possible, and if a transaction into SRAM gets corrupted along the way that is ok.

I know, instantiating the register would be much more straightforward from a DV perspective - would it be hard to work around this corner case in the testbench?

msfschaffner avatar Mar 12 '21 21:03 msfschaffner

I see, that makes sense.

It might be a bit tricky to account for this in DV, but definitely not impossible. I'll give it a look and see what I can do.

Thanks for the info!

udinator avatar Mar 12 '21 22:03 udinator

adding @weicaiyang for visibility - this relates to the weird timing edge case in the SRAM scoreboard relating to status_lc_esc and handling_lc_esc

udinator avatar Oct 08 '21 00:10 udinator