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

libcaliptra: add SHA accelerator API #1637

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MDr164
Copy link

@MDr164 MDr164 commented Aug 14, 2024

Resolves #1361 by providing an abstraction above the caliptra_write_u32 and caliptra_read_u32 function calls according to the info at https://chipsalliance.github.io/caliptra-rtl/main/external-regs/?p=caliptra_top_reg.sha512_acc_csr

Copy link

linux-foundation-easycla bot commented Sep 11, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: MDr164 / name: Marvin Drees (594c2ed)

Copy link
Contributor

@nquarton nquarton left a comment

Choose a reason for hiding this comment

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

I think there are some issues when it comes to obtaining and releasing the lock. It think there should also be a test that performs these operations with a known answer to ensure this is working.

libcaliptra/src/caliptra_api.c Outdated Show resolved Hide resolved
@MDr164 MDr164 force-pushed the sha-accel branch 3 times, most recently from 3eef2a0 to c1d16d7 Compare December 11, 2024 18:02
@MDr164 MDr164 force-pushed the sha-accel branch 4 times, most recently from 505ae38 to c9f6499 Compare January 20, 2025 15:49
@MDr164 MDr164 requested review from nquarton and jhand2 February 7, 2025 16:04
@@ -225,6 +225,18 @@ void caliptra_req_idev_csr_start();
// Clear IDEV CSR request.
void caliptra_req_idev_csr_complete();

// Computes the SHA hash using the specified mode and endianess.
int caliptra_compute_sha(int mode, int endian, uint32_t* data, uint32_t data_len, uint32_t* hash, uint32_t mbox_start_addr);
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is a hash over data in the mailbox? Can the function name or comment clarify that?

Copy link
Author

Choose a reason for hiding this comment

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

I can change that yes, if I remember correctly a user would need to specify the mbox regs and then it computes the hash over it. I will also update the name of the parameters a bit then as it could help users of the function.

@@ -671,6 +670,63 @@ int rt_test_all_commands(const test_info* info)
printf("Certify Key Extended: OK\n");
}

// SHA Engine Tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Can there be a test for caliptra_compute_sha as well?

Copy link
Author

Choose a reason for hiding this comment

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

Sure thing, it would test the same functionality but just in a different input way but shouldn't be too hard to add another test for that as well.

@@ -0,0 +1,14 @@
// Licensed under the Apache-2.0 license
Copy link
Contributor

Choose a reason for hiding this comment

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

These should come from caliptra_top_reg.h. See the other examples in caliptra_fuses.h and caliptra_mbox.h. That file comes from the HW repo submodule (hw/latest/rtl/src/soc_ifc/rtl/caliptra_top_reg.h)

Copy link
Author

Choose a reason for hiding this comment

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

I must have missed those declarations, will update 👍

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

Successfully merging this pull request may close these issues.

Libcaliptra support needed for SHA accelerator engine
4 participants