Skip to content

Commit

Permalink
[otbn,dv] Tidy up how we handle "start-of-time RMA" in model
Browse files Browse the repository at this point in the history
Signed-off-by: Rupert Swarbrick <[email protected]>
  • Loading branch information
rswarbrick committed Jul 9, 2024
1 parent 7d8ed76 commit 39ed6b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hw/ip/otbn/dv/otbnsim/sim/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def _step_pre_wipe(self, verbose: bool) -> StepRes:
# complex might not be up, so we don't want to wait for a seed. Handle
# this by jumping straight to the WIPING state and setting the number
# of rounds to 1 (so that we don't wait again for a seed afterwards)
if self.state.rma_req == LcTx.ON and self.state.wipe_rounds_done == 0:
if self.state.rma_req == LcTx.ON and not self.state.edn_seen_running:
self.state.lock_after_wipe = True
self.state.wipe_rounds_to_do = 1
self.state.set_fsm_state(FsmState.WIPING)
Expand Down
9 changes: 9 additions & 0 deletions hw/ip/otbn/dv/otbnsim/sim/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ def __init__(self) -> None:
# in IDLE.
self.delayed_lock = False

# We set this flag when the first URND seed comes back from the EDN. If
# we get an RMA request before this flag is set, we'll be in the
# PRE_WIPE state and the EDN might not actually be running. In that
# situation, we do a shortened secure wipe (just one round and no
# random data).
self.edn_seen_running = False

def get_next_pc(self) -> int:
if self._pc_next_override is not None:
return self._pc_next_override
Expand Down Expand Up @@ -217,6 +224,8 @@ def urnd_completed(self) -> None:
# it back into four 64-bit words.
w64s = [(w256 >> (64 * i)) & ((1 << 64) - 1) for i in range(4)]

self.edn_seen_running = True

self.wsrs.URND.set_seed(w64s)

def start_init_sec_wipe(self) -> None:
Expand Down

0 comments on commit 39ed6b3

Please sign in to comment.