chipsalliance / caliptra-sw

Caliptra software (ROM, FMC, runtime firmware), and libraries/tools needed to build and test
Apache License 2.0
53 stars 39 forks source link

Adding LMS KAT to RT boot #1507

Closed nquarton closed 4 months ago

nquarton commented 4 months ago

This is the non-ideal approach of always running the LMS KAT at the start of RT FW (before processing commands). Ideally, this would be run exactly once as/if needed before an LMS operation is performed in runtime. This gets a little tricky in rust though as it requires static state to be shared about whether or not the KAT has been run.

This approach adds approximately 1.25 ms of boot time at the start of runtime on 1.1 HW and around 3ms on 1.0 HW.

This is updated to add state in the LMS driver to track whether or not this has been run.

sree-revoori1 commented 4 months ago

Can we add a bool to the drivers struct indicating whether or not the KAT has been run instead?

nquarton commented 4 months ago

Can we add a bool to the drivers struct indicating whether or not the KAT has been run instead?

I did consider that. It's an accessible place to put some state. The only issue is the drivers don't bring in KATs as a crate. So either

  1. The runtime code needs to enforce this rule, check/update the state, and run the KAT. Certainly possible but feels a little disaggregated.
  2. The drivers need to have a circular dependency on the KATs (is this okay/allowed?)

But if people still like this path (or I'm missing a better option) then I can absolutely do this.

nquarton commented 4 months ago

I have updated this implementation to store state in the LMS driver.

This solution isn't fully ideal because:

  1. The driver cannot handle running the KAT because it would create a cyclic dependency. This means the caller (only one in this case) must call the KAT's new execute_once function first.
  2. This affects ROM (since it touches the driver) and technically ROM doesn't need this functionality. This may be okay at this stage since ROM 1.1 has not been declared.