opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[kmac/top] Chip-level chip_csr_hw_reset failure due to fifo_empty interrupt

Open msfschaffner opened this issue 5 years ago • 13 comments

With recent changes in CSR nodes of several IPs, we now seem to be hitting a new corner case in kmac in chip-level sims. In particular, it looks like the random CSR tests seem to initiate transactions into the message FIFO, and this in turn produces a fifo_empty interrupt - which is not expected at this point.

Error message from VCS:

Check failed obs == exp (2 [0x2] vs 0 [0x0]) Regname: chip_reg_block.kmac.intr_state

in the chip_csr_hw_reset test (see private CI from a recent PR, e.g. https://github.com/lowRISC/opentitan/pull/6870)

Is this something we can solve using exclusions?

msfschaffner avatar Jun 08 '21 23:06 msfschaffner

This is caught in IP-level too. https://reports.opentitan.org/hw/ip/kmac_masked/dv/latest/results.html

in hw_reset, sequence is like this: random write CSRs -> reset -> read all CSRs for check if the interrupt appears after reset, then it seems not quite right. @udinator WDYT?

weicaiyang avatar Jun 09 '21 01:06 weicaiyang

Hmm yes like @weicaiyang says I am seeing some infrequent failures in the IP level as well - let me dig into this, interrupts should not be firing after reset.

udinator avatar Jun 09 '21 01:06 udinator

Adding @rswarbrick also (since this involves rom_ctrl<->kmac things).

After some digging, I've root-caused the failure.

The various KMAC interrupts (kmac_done, fifo_empty, kmac_err) will rise/fall during the period just after reset when the ROM controller is initiating a hash of its memory contents - this is perfectly ok since the KMAC is currently active.

However, what is happening here is that the KMAC burst-reads a bunch of data from the ROM, rapidly incrementing the msgfifo read pointer and causing fifo_empty to occur - again, this is correct behavior.

As a result, once the ROM operation has finished and the "main" part of the csr_hw_reset test begins, a KMAC interrupt is already set, which then appears like an interrupt is somehow high right after reset - causing a comparison failure as the csr sequence clearly doesn't expect this interrupt to be high.

A possible solution is to add a read-check exclusion to the intr_state csr, as I think this error can technically pop up in other CSR tests. However, this would affect IP-level testing also.

WDYT?

udinator avatar Jun 10 '21 02:06 udinator

I'm not an expert on the details of how KMAC works, but rom_ctrl connects through one of the non-Ibex "app" interfaces. Since this isn't controlled by the CPU, I'm slightly surprised that its behaviour can trigger an interrupt being sent to the CPU. Shouldn't those be conditional on the cause coming from SW?

@eunchan: Maybe you can comment on what you think the design is supposed to do?

rswarbrick avatar Jun 10 '21 10:06 rswarbrick

sorry, I should have clarified - the interrupt lines themselves are not going high as the enable bits are all zeroed after each reset. what is getting updated, however, are the fields of the intr_state CSR, and this is what is causing the mismatch failures.

udinator avatar Jun 10 '21 17:06 udinator

I dont think interrupts are actually sent (that requires intr_enable to be programmed, which is already write-excluded). However, the intr_state gets updated regardless, if those conditions is met. IMO just do a read-check exclude on KMAC's intr_state fields and call it a day.

sriyerg avatar Jun 10 '21 17:06 sriyerg

This solution sounds good to me as well. Is there a straightforward way to add these exclusions? These regs are autogenerated and hence there is no full associated register entry in the hjson.

msfschaffner avatar Jun 10 '21 17:06 msfschaffner

@msfschaffner yup, in reggen/reg_block.py we can add exclusions for the interrupt and alert registers, I am modifying the intr_state exclusions to exclude all checks.

udinator avatar Jun 11 '21 19:06 udinator

@msfschaffner the fix has been merged, can you rebase your PRs and run CI again?

udinator avatar Jun 11 '21 23:06 udinator

to @rswarbrick point, we should probably think about whether it makes sense that pure hardware triggered / response events really should be setting the interrupts though.

This might not matter for the rom case since it happens only at power up, but this could get kind of strange for the case kmac is used by both otp and software. If the software for example statically sets up the interrupts enables, and then gets an interrupt that is actually triggered by otp token hashing, will that end up creating confusion for software?

@eunchan @udinator

tjaychen avatar Jun 14 '21 19:06 tjaychen

This might not matter for the rom case since it happens only at power up, but this could get kind of strange for the case kmac is used by both otp and software. If the software for example statically sets up the interrupts enables, and then gets an interrupt that is actually triggered by otp token hashing, will that end up creating confusion for software?

Yep, that was what I was trying to get at.

rswarbrick avatar Jun 15 '21 08:06 rswarbrick

@msfschaffner can this be closed?

udinator avatar Oct 08 '21 00:10 udinator

The original issue has been fixed. I am splitting out the interrupt triggering as a separate issue to see whether it needs more discussing.

msfschaffner avatar Oct 19 '21 15:10 msfschaffner