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

[pentest] Batch mode for Ibex SCA #22272

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

nasahlpa
Copy link
Member

@nasahlpa nasahlpa commented Mar 26, 2024

This commit adds the following new FI and SCA ibex tests:

  • ibex_sca_tl_write_batch_fvsr
  • ibex_sca_tl_write_batch_fvsr_fix_address
  • ibex_sca_tl_write_batch_random
  • ibex_sca_tl_write_batch_random_fix_address
  • ibex_sca_tl_write_fvsr
  • ibex_sca_tl_write_random
  • ibex_sca_tl_read_batch_fvsr
  • ibex_sca_tl_read_batch_fvsr_fix_address
  • ibex_sca_tl_read_batch_random
  • ibex_sca_tl_read_batch_random_fix_address
  • ibex_sca_tl_read_fvsr
  • ibex_sca_tl_read_random
  • ibex_sca_register_file_write_batch_fvsr
  • ibex_sca_register_file_write_batch_random
  • ibex_sca_register_file_write_fvsr
  • ibex_sca_register_file_write_random
  • ibex_sca_register_file_read_batch_fvsr
  • ibex_sca_register_file_read_batch_random
  • ibex_sca_register_file_read_fvsr
  • ibex_fi_char_sram_static

The host code is located in lowRISC/ot-sca#349

nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Mar 27, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr

The device code is located in lowRISC/opentitan#22272

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Mar 27, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272

Signed-off-by: Pascal Nasahl <[email protected]>
@nasahlpa nasahlpa marked this pull request as ready for review March 27, 2024 15:30
@nasahlpa nasahlpa requested a review from a team as a code owner March 27, 2024 15:30
@nasahlpa nasahlpa requested review from jadephilipoom, luismarques, vogelpi and johannheyszl and removed request for a team and jadephilipoom March 27, 2024 15:31
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Mar 27, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272

Signed-off-by: Pascal Nasahl <[email protected]>
@nasahlpa nasahlpa added the CherryPick:master This PR should be cherry-picked to master label Mar 27, 2024
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.

Thanks @nasahlpa

Copy link
Contributor

@timothytrippel timothytrippel left a comment

Choose a reason for hiding this comment

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

Dropped a few more comments in addition to the style comments I dropped in #22310 and #22269.

sw/device/tests/crypto/cryptotest/firmware/ibex_sca.c Outdated Show resolved Hide resolved

for (int i = 0; i < uj_data.num_iterations; i++) {
// Initialize temporary registers with reference values.
asm volatile("mv x5, %0" : : "r"(0));
Copy link
Contributor

Choose a reason for hiding this comment

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

move this to a static function and share across the file? (DRY principle)

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean the generation of the random values? I've created a two static functions for generating random and FvsR values instead of repeating the same code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean this asm block that initializes temp registers with values

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure if adding a function that initializes x5, x6, x7, x28, x29, x30 works. When having a function call to such an initialization function, is it guaranteed that these registers contain the values I am expecting after returning from the function? These registers are temporary registers.

Copy link
Contributor

@timothytrippel timothytrippel Mar 29, 2024

Choose a reason for hiding this comment

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

sorry, inline function or macro? something to help keep everything in sync over time that still satisfies your constraints. I.e., if you change something, you have to change it everywhere, makes things hard to maintain. Unless there are SCA reasons you have like you stated below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, thanks :)

@nasahlpa nasahlpa force-pushed the ibex_sca_batch branch 2 times, most recently from 6cc7c4b to b018806 Compare March 28, 2024 18:52
@timothytrippel timothytrippel self-requested a review March 28, 2024 23:56
sw/device/tests/crypto/cryptotest/firmware/ibex_sca.c Outdated Show resolved Hide resolved
sw/device/tests/crypto/cryptotest/firmware/ibex_sca.c Outdated Show resolved Hide resolved
sw/device/tests/crypto/cryptotest/firmware/ibex_sca.c Outdated Show resolved Hide resolved
sw/device/tests/crypto/cryptotest/firmware/ibex_sca.c Outdated Show resolved Hide resolved

for (int i = 0; i < uj_data.num_iterations; i++) {
// Initialize temporary registers with reference values.
asm volatile("mv x5, %0" : : "r"(0));
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean this asm block that initializes temp registers with values

@timothytrippel timothytrippel self-requested a review March 29, 2024 19:06
@nasahlpa nasahlpa force-pushed the ibex_sca_batch branch 3 times, most recently from a561652 to 97389d8 Compare April 5, 2024 09:48
This commit adds the following new FI and SCA ibex tests:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_static

The host code is located in lowRISC/ot-sca#349.

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Apr 9, 2024
This commit adds the command handler for the
ibex_char_sram_write test. The device PR is located
in lowRISC/opentitan#22272

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Apr 9, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Apr 9, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272

Signed-off-by: Pascal Nasahl <[email protected]>
@nasahlpa
Copy link
Member Author

nasahlpa commented Apr 10, 2024

Sorry for the long delay with the rebase - after the rebase the firmware was too large for the memory and I had to separate the pen. tests from the crypto tests (see #22450). I hope we can merge this soon - the failing tests in CI are not related to this PR.

@timothytrippel timothytrippel merged commit 7f7dbbc into lowRISC:earlgrey_es_sival Apr 10, 2024
27 of 29 checks passed
Copy link

Backport failed for master, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin master
git worktree add -d .worktree/backport-22272-to-master origin/master
cd .worktree/backport-22272-to-master
git switch --create backport-22272-to-master
git cherry-pick -x 773655502cf220ab0035bd2b5f924d7153be8e71

nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Apr 11, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272 and the
binary was compiled from lowRISC/opentitan@7f7dbbc

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Apr 11, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272 and the
binary was compiled from lowRISC/opentitan@7f7dbbc

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Apr 11, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272 and the
binary was compiled from lowRISC/opentitan@7f7dbbc

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Apr 11, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272 and the
binary was compiled from lowRISC/opentitan@7f7dbbc

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request Apr 11, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272 and the
binary was compiled from lowRISC/opentitan@7f7dbbc

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to lowRISC/ot-sca that referenced this pull request Apr 11, 2024
This commit adds the command handler for:
- ibex_sca_tl_write_batch_fvsr
- ibex_sca_tl_write_batch_fvsr_fix_address
- ibex_sca_tl_write_batch_random
- ibex_sca_tl_write_batch_random_fix_address
- ibex_sca_tl_write_fvsr
- ibex_sca_tl_write_random
- ibex_sca_tl_read_batch_fvsr
- ibex_sca_tl_read_batch_fvsr_fix_address
- ibex_sca_tl_read_batch_random
- ibex_sca_tl_read_batch_random_fix_address
- ibex_sca_tl_read_fvsr
- ibex_sca_tl_read_random
- ibex_sca_register_file_write_batch_fvsr
- ibex_sca_register_file_write_batch_random
- ibex_sca_register_file_write_fvsr
- ibex_sca_register_file_write_random
- ibex_sca_register_file_read_batch_fvsr
- ibex_sca_register_file_read_batch_random
- ibex_sca_register_file_read_fvsr
- ibex_sca_register_file_read_random
- ibex_fi_char_sram_write

The device code is located in lowRISC/opentitan#22272 and the
binary was compiled from lowRISC/opentitan@7f7dbbc

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to lowRISC/ot-sca that referenced this pull request Apr 11, 2024
This commit adds the command handler for the
ibex_char_sram_write test. The device PR is located
in lowRISC/opentitan#22272

Signed-off-by: Pascal Nasahl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPick:master This PR should be cherry-picked to master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants