[lc_ctrl] DIF does not validate lifecycle state transition legality
- Dominant language
- SystemVerilog
- Stars
- 3.6k
- Forks
- 1.1k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 141
Description
### Description
The LC Controller DIF (`dif_lc_ctrl_configure`) writes the target state
to `TRANSITION_TARGET` and triggers `TRANSITION_CMD` without verifying
whether the requested transition is legal from the current state.
**Document constraint** (`lc_ctrl.hjson`):
> "Note that not all transitions are possible."
**Example of illegal transition**: DEV → RAW is not a valid path in the
lifecycle state machine.
**Current behavior**:
- `dif_lc_ctrl_configure` (line ~404 in `dif_lc_ctrl.c`) writes
`TRANSITION_TARGET` with the requested state
- Then sets `TRANSITION_CMD` to initiate the transition
- No validation that the target state is reachable from the current state
**Expected behavior**:
The DIF should validate the transition legality before initiating the
command, returning `kDifError` (or a new error code) for invalid
transitions. This is particularly important because the lifecycle
controller manages the chip's security state, and invalid transitions
could lead to undefined behavior.
**Suggested fix**:
Add a check in `dif_lc_ctrl_configure` to verify the transition is
legal before writing `TRANSITION_TARGET`. The valid transitions are
documented in the hardware specification and could be encoded as a
lookup table in the DIF.
**Version**:
- OpenTitan commit: ffab8da7381c66b3d2e2b78a382a9f6937e5482e
- LC Controller verification: V2, DIF stage: S2
Contributor guide
Research direction
Start in dif_lc_ctrl.c at dif_lc_ctrl_configure and read the lifecycle transition rules in lc_ctrl.hjson and the referenced hardware specification. Determine how legal transitions are represented and how an invalid request should map to kDifError or another error code. Done means invalid transitions are rejected before TRANSITION_TARGET is written, while valid transitions still initiate the command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100