lowRISC / lowRISC/opentitan

[sw,driver] keymgr driver idle status handling

Open
#27,683 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

IP:keymgr SW:ROM_EXT Type:Question
Dominant language
SystemVerilog
Stars
3.6k
Forks
1.1k
Avg merge
2d 22h
Merged PRs (30d)
141

Description

Description

The keymgr driver in both silicon creator and cryptolib uses keymgr_wait_until_done after starting an operation. In all instances, keymgr_wait_until_done is invoked immediately following the initiation of an operation.

https://github.com/lowRISC/opentitan/blob/ff5a9219dbf1a13e53743057dbe6a61978456821/sw/device/silicon_creator/lib/drivers/keymgr.c#L240-L244

https://github.com/lowRISC/opentitan/blob/ff5a9219dbf1a13e53743057dbe6a61978456821/sw/device/lib/crypto/drivers/keymgr.c#L149-L151


This function, intended to wait for completion, currently returns OK if the OP_STATUS register is idle.

https://github.com/lowRISC/opentitan/blob/ff5a9219dbf1a13e53743057dbe6a61978456821/sw/device/silicon_creator/lib/drivers/keymgr.c#L186-L199


However, the hardware documentation for the keymgr IP indicates that the OP_STATUS field should not be idle/cleared once an operation is initiated. Also, our coverage report indicates that this switch case is not triggered by available tests.

An internal error or a trap would seem more suitable if this unexpected status were encountered.

https://github.com/lowRISC/opentitan/blob/ff5a9219dbf1a13e53743057dbe6a61978456821/hw/ip/keymgr/doc/registers.md?plain=1#L652-L660

https://github.com/lowRISC/opentitan/blob/ff5a9219dbf1a13e53743057dbe6a61978456821/hw/ip/keymgr/doc/registers.md?plain=1#L676-L681

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cited keymgr_wait_until_done implementations in sw/device/silicon_creator/lib/drivers/keymgr.c and sw/device/lib/crypto/drivers/keymgr.c, then read the OP_STATUS behavior in hw/ip/keymgr/doc/registers.md. Check the existing tests and coverage for the idle-status branch. Done means unexpected idle status after operation start is handled appropriately and the behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.