Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions sw/device/silicon_creator/lib/rescue/rescue.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,20 @@ rom_error_t rescue_validate_mode(uint32_t mode, rescue_state_t *state) {
}

rom_error_t rescue_send_handler(rescue_state_t *state) {
if (state->mode == kRescueModeNoOp) {
// The No-Op mode is always allowed and does nothing.
return kErrorOk;
// The following commands are always allowed and are not subject to
// the "command allowed" check.
switch (state->mode) {
case kRescueModeReboot:
// If a reboot was requested, return an error and go through the normal
// shutdown process.
return kErrorRescueReboot;
case kRescueModeNoOp:
// The No-Op mode is always allowed and does nothing.
return kErrorOk;
default:
/* do nothing */;
}

hardened_bool_t allow =
owner_rescue_command_allowed(state->config, state->mode);
if (allow != kHardenedBoolTrue) {
Expand Down Expand Up @@ -255,10 +265,6 @@ rom_error_t rescue_send_handler(rescue_state_t *state) {
case kRescueModeFirmwareSlotB:
// Nothing to do for receive modes.
return kErrorOk;
case kRescueModeReboot:
// If a reboot was requested, return an error and go through the normal
// shutdown process.
return kErrorRescueReboot;
default:
// This state should be impossible.
return kErrorRescueBadMode;
Expand Down
2 changes: 2 additions & 0 deletions sw/device/silicon_creator/rom_ext/e2e/rescue/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ opentitan_test(
--exec="rescue get-device-id --reboot=false"
# Try the `RESQ` mode and make sure we get an error message.
--exec="console --non-interactive --send='RESQ\r' --exit-success='{exit_success}' --exit-failure='{exit_failure}'"
# Try the `REBO` mode and make sure we reboot without crash.
--exec="console --non-interactive --send='REBO\r' --exit-success='ROM:' --exit-failure='BFV:.*\r\n'"
no-op
""",
),
Expand Down
Loading