[kmac] Specify and implement a dynamic app interface extension#30141
[kmac] Specify and implement a dynamic app interface extension#30141etterli wants to merge 2 commits into
Conversation
|
The CI tests fail mainly due to the mentioned breaking changes in other IPs and missing top level updates. |
rswarbrick
left a comment
There was a problem hiding this comment.
This is a partial review of the specification commit.
etterli
left a comment
There was a problem hiding this comment.
@rswarbrick Thank you for the first review. Incorporated the feedback.
| ### Application Interfaces | ||
|
|
||
| The IP has N instances of an application interface. | ||
| Each of these interface can be either static or dynamic. |
There was a problem hiding this comment.
Good idea to split the two types. I will rewrite this once I came up with a solution to the wiring problem.
b6b80ec to
4f86a12
Compare
| ### Application Interfaces | ||
|
|
||
| The IP has N instances of an application interface. | ||
| Each of these interface can be either static or dynamic. |
There was a problem hiding this comment.
I am not sure it's worth to invest more effort into that. Eventually, all interfaces will be dynamic but some will just always provide the same static configuration. The reason for splitting this into two variants is that we need the configurability in OTBN, but at the time being, we don't want to change LC_CTRL, OTP_CTRL, ROM_CTRL which also use an app interface.
There was a problem hiding this comment.
Thanks @vogelpi for the review. I addressed some of the comments. Open points are:
- Refactor / clean up the FSM
- Adapt the error handling
- Change the name of the dynamic config
- Come up with a good naming for 'last' and 'finished'
608c39f to
786c5e9
Compare
|
Newest push contains
Open points are:
|
|
I have now adapted the error handling and refactored the FSM. |
eface93 to
318d780
Compare
| Once SW has cleared the error, the interface then triggers a PROCESS command to bring the hashing engine back into the idle state. | ||
|
|
||
| Case 3: If the key gets invalidated after the interface sent the PROCESS command (i.e., if in `StAppProcess` or `StAppWait`) the message is already complete and the PROCESS command may not be issued again. | ||
| The app interface still sends the error response and a dynamic interface waits for the finish response which it responds to with a finish response which has the error flag set (= 1). |
There was a problem hiding this comment.
waits for the finish request which ...
Actually, you're talking about finish requests and finish responses here but the interface defines a last request and a finish response. I recommend to align the terminology with the signals in the interface.
There was a problem hiding this comment.
I now have renamed all the finish requests to termination requests. Now we have the following requests / responses which should be quite easy to differentiate:
- message requests
- last requests / process commands
- termination requests
- digest responses
- finish responses
Renaming these termination requests to also 'last requests' would have again been conflicting with the last requests.
There was a problem hiding this comment.
Hm, it's getting a bit confusing. Maybe we can discuss this tomorrow. We probably don't have to change much to make this easier for others to understand.
| A dynamic interface also sends an immediate error response but then waits until a finish request arrives. | ||
| The finish request is then answered with a finish response which has the error flag set (= 1). | ||
| Both interface types then wait for SW to acknowledged the error by writing to the `error_processed` bit. | ||
| Once SW has cleared the error, the interface then triggers a PROCESS command to bring the hashing engine back into the idle state. |
There was a problem hiding this comment.
This sounds good to me. Can you please ensure that for this PROCESS command, we enforce that the entropy_fast_process bit forwarded to the SHA3 engine is 0?
There was a problem hiding this comment.
Which way to ensure this is preferred:
- By checking that SW configured this correctly before starting a KMAC operation and raising a service rejected error
- By overwriting this signal / The app interface sets the actual signal to the SHA3 engine? Is this possible at runtime?
There was a problem hiding this comment.
Sorry, I misunderstand the request. It must clearly be set to 0 by the app interface at runtime, once we recover the error.
Btw, why should this be 0?
There was a problem hiding this comment.
I implemented it so that the bit is overwritten for the duration of the error recovery.
There was a problem hiding this comment.
@vogelpi Have you also checked the implementation thereof? Is it as you requested it?
There was a problem hiding this comment.
Thanks for the reminder. I overlooked this comment initially.
The way you implemented this is fine. But to be on the safe side, I would drive the disable_entropy_fast_process signal to 1 in all error states. The result of this is that whenever we experience an error, any hashing operations of the SHA3 core will be done by updating the PRNG (hence the masking is fully enabled). For power saving, the entropy_fast_process bit got added originally but I see a slight risk of leaving this disabled during error handling. It could be used to trigger improperly masked hashing operations.
There was a problem hiding this comment.
All error states now force this signal to 0.
vogelpi
left a comment
There was a problem hiding this comment.
Thanks @etterli for implementing the changes. I did another full pass over this PR and it looks really great. I have a few remaining comments, most of them are minor, or can be implemented with little effort. Please let me know if you have further questions.
| Once the interface has sent the finish response, it will return to its idle state, ready to serve the next app request. | ||
|
|
||
| When the app receives the finish response, it must check it for errors. | ||
| The reason is that there could have been an error in the last digest but this was not reported immediately to satisfy to the valid locked-in property. |
There was a problem hiding this comment.
Added a small explanation.
| A dynamic interface also sends an immediate error response but then waits until a finish request arrives. | ||
| The finish request is then answered with a finish response which has the error flag set (= 1). | ||
| Both interface types then wait for SW to acknowledged the error by writing to the `error_processed` bit. | ||
| Once SW has cleared the error, the interface then triggers a PROCESS command to bring the hashing engine back into the idle state. |
There was a problem hiding this comment.
@vogelpi Have you also checked the implementation thereof? Is it as you requested it?
| AppKMAC = 2 | ||
| // Application interface type. Either use a compile-time defined configuration or the app | ||
| // provides a hashing configuration at runtime. | ||
| typedef enum logic { |
rswarbrick
left a comment
There was a problem hiding this comment.
I haven't managed to get GitHub to show me any other responses you sent on this PR today (apparently, that's not possible for some reason).
These are responses to lines that are still visible on the pending changes :-)
| If this error occurs, the app interface will not send a response or handle any message requests. | ||
|
|
||
| ##### Service rejected error | ||
| This error occurs when the configuration is invalid (both dynamic and static) or a KMAC operation is requested when the entropy is not ready. |
There was a problem hiding this comment.
But that requires testing... Since we don't care, it's better not to specify that this happens.
| As of this no data is ever pushed into the hashing engine. | ||
| After the last message request, the app interface then immediately sends a response with garbage data and the error flag set. | ||
| A static interface then directly returns into the Idle state without waiting for SW to set the `error_processed` bit. | ||
| A dynamic interface waits until a termination request is received and answers with a finish acknowledgment response. |
There was a problem hiding this comment.
Sounds reasonable to me. But it needs documenting!
| AppKMAC = 2 | ||
| // Application interface type. Either use a compile-time defined configuration or the app | ||
| // provides a hashing configuration at runtime. | ||
| typedef enum logic { |
There was a problem hiding this comment.
I really hope that you don't want to be able to specify that the parameter is 'x... I strongly believe that values that are boolean should be encoded as bit, rather than logic.
|
Hey @rswarbrick I went through all your initial comments and now only the relevant comments are still open. Here is also a list of direct links to all comments which are of interest to review my answer. Once the new tab opens, click the "load more" link. It will then jump to the comment (it takes a while). #30141 (comment) |
|
I addressed the following points:
|
Thanks @etterli , this looks great! |
1585336 to
f6b53e0
Compare
|
Rebased on master with some minor style fixes. |
|
Rebased again on master which now includes #30229. |
|
I changed the description how an app terminates the message phase. This includes the case how OTBN will end the phase. It was already implemented this way but not specified. |
nasahlpa
left a comment
There was a problem hiding this comment.
Thanks Pascal - I again had a look into spec and RTL - which looks good to me. Great work!
Signed-off-by: Pascal Etterli <pascal.etterli@lowrisc.org>
Signed-off-by: Pascal Etterli <pascal.etterli@lowrisc.org>
|
Force-push rebased on lastest master. |
|
Closing this PR in favor of #30143. This PR here now just serves as documentation of the specification and RTL implementation review. |
This PR extends the current KMAC application interface so it supports changing the hashing configuration at runtime. The new interface mode is called 'dynamic'. The extension keeps full compatibility with the existing interface behavior, hereinafter referred to as 'static'.
The new interface behavior is described / specified in the
hw/ip/kmac/doc/theory_of_operation.md.The diagrams in the documentation are best viewed by building the documentation locally using:
util/site/build-docs.sh serve(or if using VS code install the wavedrom and a mermaid extensions).
Note, this PR should not yet be merged, as the changes also directly break the
keymgr,keymgr_dpe,rom_ctrl, andlc_ctrlIPs. The reason is that the typesapp_req_tandapp_rsp_tare modified. This PR would also break the DV ofkmacand the related IPs.I will push commits resolving these problems but for now I think it would make sense to start reviewing the specification and core implementation of the interface.