Skip to content

Conversation

@h-filali
Copy link
Contributor

@h-filali h-filali commented Oct 29, 2025

This allows subfunctions to be replaced by NOPs for constant time tests.

This is useful for the case where a function runs in constant time under normal conditions but is not
necessarily constant time in case of FI.

The issue I was facing was that we have constant time tests in the CI which check whether assembly functions have a constant execution time. For example p384_isoncurve_check is a function that should, under normal conditions, execute in constant time. However it calls trigger_fault_if_fg0_not_z which is not constant time in the case of fault injection. This trips up the consttime check, since all of a sudden it is possible to terminate earlier.

For this reason this PR makes it possible to replace the function body of trigger_fault_if_fg0_not_z by NOPs. This way the constant time can still check the rest of p384_isoncurve_check for constant-time-ness.

@h-filali h-filali force-pushed the otbn-sim-nop-ignored-subfuncs branch from e46744a to 25c22c4 Compare October 29, 2025 14:31
Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitty suggestion, but I think I don't properly understand how this works, so can't really give it a proper review yet.

I'd suggest:

  • Add a commit message that explains why a change is needed ("with the previous code XYZ reported a spurious error because ABC. This change avoids the problem")
  • Also explain how the control_deps_ignore stuff in check_const_time was supposed to work in the past and why it can be ripped out.
  • In the code itself, I think I might need a few more comments to make sure I understand what's going on. Squinting a little, I think it might be possible to make simpler, but I'm not sure I understand how yet!

@h-filali h-filali requested a review from vogelpi October 30, 2025 09:04
Copy link
Contributor

@johannheyszl johannheyszl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar enough with this part to review properly, but the intent to exclude failing const time check in cases of caused by FI makes sense. Thanks @h-filali

This allows subfunctions to be replaced by NOPs for
constant time tests.

This is useful for the case where a function runs in
constant time under normal conditions but is not
necessarily constant time in case of FI.

Co-authored-by: Rupert Swarbrick <[email protected]>
Signed-off-by: Hakim Filali <[email protected]>
@h-filali h-filali force-pushed the otbn-sim-nop-ignored-subfuncs branch from 25c22c4 to 4795b06 Compare October 30, 2025 10:10
@h-filali
Copy link
Contributor Author

Thanks @rswarbrick for your helpful review. I implemented your suggested changes. I also added you as a co-author since I used a lot of your code to improve this PR.

Also thanks @johannheyszl for your review.

Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @h-filali and @rswarbrick , this looks good to me and we really need this for another PR but I would like @rswarbrick to have the final word.

@h-filali h-filali added the CherryPick:earlgrey_1.0.0 This PR should be cherry-picked to earlgrey_1.0.0 label Oct 30, 2025
Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, and thanks for the tweaks.

@rswarbrick rswarbrick added this pull request to the merge queue Oct 30, 2025
Merged via the queue into lowRISC:master with commit e431c33 Oct 30, 2025
49 checks passed
@lowrisc-ci
Copy link

lowrisc-ci bot commented Oct 30, 2025

Successfully created backport PR for earlgrey_1.0.0:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CherryPick:earlgrey_1.0.0 This PR should be cherry-picked to earlgrey_1.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants