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

[prim_sha2_pad, hmac] Don't allow skipping the padding after stopping a hash operation #23936

Closed
vogelpi opened this issue Jul 5, 2024 · 2 comments
Labels
Component:RTL IP:hmac NoECO_IntegratePostM5 Accepted for integration post M5 Type:Bug Bugs Type:FutureRelease Not relevant to currently planned releases/milestones
Milestone

Comments

@vogelpi
Copy link
Contributor

vogelpi commented Jul 5, 2024

Description

During coverage closure for V2S, @martin-velay and @gdessouky noted that there are some uncovered FSM transitions inside prim_sha2_pad:

  • StLenHi -> StFifoReceive
  • StLenLo -> StFifoReceive
  • StPad00 -> StFifoReceive
  • StPad80 -> StFifoReceive

An inspection of the RTL reveals that these transtions can be covered by something like the following sequence:

  1. Trigger and message and make prim_sha2_pad go into any the StPad80 / StPad00 / StLenHi / StLenLo states. As a result of this cfg_block will assert and any future reg_hash_start / reg_hash_continue won't be forwarded to prim_sha2_pad.
  2. Trigger a reg_hash_stop. This will make cfg_block go low again in the next clock cycle.
  3. In the next clock cycle, trigger again a reg_hash_start / reg_hash_continue. This will trigger the uncovered transition.

The problematic thing with this is that after Step 2, the design should finish the hashing and then append the padding. By triggering another reg_hash_start or reg_hash_continue, software can cause the hardware to abort the padding and restart the hashing. This is not intended behavior, but software is also not expected to start another operation directly after stopping one. Instead, software is expected to wait for the hmac_done interrupt or to poll the status register to wait for the hashing and padding to finish before triggering further operations as outlined in the HMAC programmer's guide .

@andreaskurth and I concluded that this is NOT a terrible bug for Earlgrey-PROD and we will exclude the missing / buggy transitions from FSM coverage. But we should still fix this in a future release. The FSM should only be able to go back into the StFifoReceive state after finishing the padding.

@vogelpi vogelpi added Type:Bug Bugs Component:RTL IP:hmac Type:FutureRelease Not relevant to currently planned releases/milestones labels Jul 5, 2024
@vogelpi vogelpi added this to the Backlog milestone Jul 5, 2024
@vogelpi
Copy link
Contributor Author

vogelpi commented Jul 5, 2024

For more details, please refer to this comment.

@vogelpi vogelpi added the NoECO_IntegratePostM5 Accepted for integration post M5 label Jul 15, 2024
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 10, 2024
This commit removes a conditional FSM state transition that was deemed
undesirable in `prim_sha2_pad`, see lowRISC#23936. It made it possible to
cancel an ongoing padding operation, which is disallowed by the HMAC
module. As a side-effect, the removal plugs some existing FSM
transition coverage holes in `prim_sha2_pad` whose manual exclusions
can be removed as well.

Signed-off-by: Andrea Caforio <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 10, 2024
This commit removes a conditional FSM state transition that was deemed
undesirable in `prim_sha2_pad`, see lowRISC#23936. It made it possible to
cancel an ongoing padding operation, which is disallowed by the HMAC
module. As a side-effect, the removal plugs some existing FSM
transition coverage holes in `prim_sha2_pad` whose manual exclusions
can be removed as well.

Removing the conditional makes it impossible to transition into the
`StFifoReceive` state from either `StPad80`, `StPad00`, `StLenHi` or
`StLenLo` by asserting the `hash_go` signal. The FSM will still
correctly move from `StIdle` to `StFifoReceive` as it already checks
the same conditional inside its state logic whereas for
`StFifoReceive` it had no effect.

Signed-off-by: Andrea Caforio <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 10, 2024
This commit removes some conditional FSM states transition that were deemed
undesirable in `prim_sha2_pad`, see lowRISC#23936. It made it possible to
cancel an ongoing padding operation, which is disallowed by the HMAC
module. As a side-effect, the removal plugs some existing FSM
transition coverage holes in `prim_sha2_pad` whose manual exclusions
can be removed as well.

This change makes it impossible to transition into the
`StFifoReceive` state from either `StPad80`, `StPad00`, `StLenHi` or
`StLenLo` by asserting the `hash_go` signal.

Signed-off-by: Andrea Caforio <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 10, 2024
This commit removes some conditional FSM states transition that were deemed
undesirable in `prim_sha2_pad`, see lowRISC#23936. It made it possible to
cancel an ongoing padding operation, which is disallowed by the HMAC
module. As a side-effect, the removal plugs some existing FSM
transition coverage holes in `prim_sha2_pad` whose manual exclusions
can be removed as well.

This change makes it impossible to transition into the
`StFifoReceive` state from either `StPad80`, `StPad00`, `StLenHi` or
`StLenLo` by asserting the `hash_go` signal.

Signed-off-by: Andrea Caforio <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 11, 2024
This commit removes some conditional FSM states transition that were
deemed undesirable in `prim_sha2_pad`, see lowRISC#23936. It made it possible
to cancel an ongoing padding operation, which is disallowed by the
HMAC module. As a side-effect, the removal plugs some existing FSM
transition coverage holes in `prim_sha2_pad` whose manual exclusions
can be removed as well.

This change makes it impossible to transition into the `StFifoReceive`
state from either `StPad80`, `StPad00`, `StLenHi` or `StLenLo` by
asserting the `hash_go` signal.

Signed-off-by: Andrea Caforio <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 18, 2024
This commit removes some conditional FSM states transition that were
deemed undesirable in `prim_sha2_pad`, see lowRISC#23936. They made it
possible to cancel an ongoing padding operation, which is disallowed
by the HMAC module.

This change makes it impossible to transition into the `StFifoReceive`
state from either `StPad80`, `StPad00`, `StLenHi` or `StLenLo` by
asserting the `hash_go` signal.

Signed-off-by: Andrea Caforio <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 18, 2024
This commit removes the coverage exclusions that were introduced as
part of the padding cancellation bug lowRISC#23936 that was fixed in the
previous commit. New exclusions are added that cover some impossible
conditions and branches as identified in lowRISC#24692.

Signed-off-by: Andrea Caforio <[email protected]>
Co-authored-by: Martin Velay <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 18, 2024
This commit removes the coverage exclusions that were introduced as
part of the padding cancellation bug lowRISC#23936 that was fixed in the
previous commit. New exclusions are added that cover some impossible
conditions and branches as identified in lowRISC#24692.

Signed-off-by: Andrea Caforio <[email protected]>
Co-authored-by: Martin Velay <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 18, 2024
This commit removes some conditional FSM states transition that were
deemed undesirable in `prim_sha2_pad`, see lowRISC#23936. They made it
possible to cancel an ongoing padding operation, which is disallowed
by the HMAC module.

This change makes it impossible to transition into the `StFifoReceive`
state from either `StPad80`, `StPad00`, `StLenHi` or `StLenLo` by
asserting the `hash_go` signal.

Signed-off-by: Andrea Caforio <[email protected]>
andrea-caforio added a commit to andrea-caforio/opentitan that referenced this issue Dec 19, 2024
This commit removes some conditional FSM states transition that were
deemed undesirable in `prim_sha2_pad`, see lowRISC#23936. They made it
possible to cancel an ongoing padding operation, which is disallowed
by the HMAC module.

This change makes it impossible to transition into the `StFifoReceive`
state from either `StPad80`, `StPad00`, `StLenHi` or `StLenLo` by
asserting the `hash_go` signal.

Signed-off-by: Andrea Caforio <[email protected]>
vogelpi pushed a commit that referenced this issue Dec 20, 2024
This commit removes some conditional FSM states transition that were
deemed undesirable in `prim_sha2_pad`, see #23936. They made it
possible to cancel an ongoing padding operation, which is disallowed
by the HMAC module.

This change makes it impossible to transition into the `StFifoReceive`
state from either `StPad80`, `StPad00`, `StLenHi` or `StLenLo` by
asserting the `hash_go` signal.

Signed-off-by: Andrea Caforio <[email protected]>
@vogelpi
Copy link
Contributor Author

vogelpi commented Dec 20, 2024

PR #25590 which removes these undesirable FSM transitions has been merged into master now and I am thus closing this issue.

PR #25696 will remove the corresponding coverage exclusions on master. We have been doing these changes for the D3/V3 sign offs.

For earlgrey_1.0.0 the RTL and also the coverage exclusions remain untouched. If the design is operated according to the programmer's guide, there is no issue. As previously stated, triggering these previously uncovered FSM transitions is tricky if not impossible by software as it requires multiple commands to be triggered back-to-back without a single bubble cycle in between. It's extremely unrealistic to trigger this.

@vogelpi vogelpi closed this as completed Dec 20, 2024
Razer6 pushed a commit to Razer6/opentitan that referenced this issue Jan 2, 2025
This commit removes some conditional FSM states transition that were
deemed undesirable in `prim_sha2_pad`, see lowRISC#23936. They made it
possible to cancel an ongoing padding operation, which is disallowed
by the HMAC module.

This change makes it impossible to transition into the `StFifoReceive`
state from either `StPad80`, `StPad00`, `StLenHi` or `StLenLo` by
asserting the `hash_go` signal.

Signed-off-by: Andrea Caforio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:RTL IP:hmac NoECO_IntegratePostM5 Accepted for integration post M5 Type:Bug Bugs Type:FutureRelease Not relevant to currently planned releases/milestones
Projects
None yet
Development

No branches or pull requests

1 participant