Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stage0 #209

Merged
merged 1 commit into from
Apr 29, 2024
Merged

Update stage0 #209

merged 1 commit into from
Apr 29, 2024

Conversation

lzrd
Copy link
Contributor

@lzrd lzrd commented Mar 21, 2024

Support update of RoT bootloader.

Includes always calculating FWID and signature check at RoT boot time.
Messages for SP and RoT Hubris updates are backward compatible.

See https://github.com/oxidecomputer/sprot-e2e for test scripts that exercise update and rollback of Hubris and Bootleby on SP and RoT.

A new RoTBootInfo mesage is plumbed that includes info on the four RoT flash banks.

The ImageError enum gives detailed information on invalid RoT flash bank contents.

This is a draft PR because it needs to be coordinated with hubris and omicron changes so as not to break people's development environments.

Closes #208

@lzrd lzrd requested review from jgallagher and labbott March 21, 2024 17:54
@lzrd lzrd marked this pull request as ready for review March 26, 2024 23:28
faux-mgs/Cargo.toml Outdated Show resolved Hide resolved
gateway-sp-comms/src/single_sp/update.rs Outdated Show resolved Hide resolved
gateway-sp-comms/src/sp_response_expect.rs Show resolved Hide resolved
gateway-messages/src/sp_to_mgs.rs Show resolved Hide resolved
faux-mgs/Cargo.toml Outdated Show resolved Hide resolved
faux-mgs/src/main.rs Outdated Show resolved Hide resolved
gateway-messages/src/sp_to_mgs.rs Show resolved Hide resolved
gateway-messages/src/sp_to_mgs.rs Outdated Show resolved Hide resolved
gateway-messages/src/sp_to_mgs.rs Outdated Show resolved Hide resolved
gateway-messages/src/sp_to_mgs.rs Outdated Show resolved Hide resolved
gateway-sp-comms/src/single_sp/update.rs Outdated Show resolved Hide resolved
gateway-sp-comms/src/single_sp/update.rs Outdated Show resolved Hide resolved
gateway-sp-comms/src/single_sp/update.rs Outdated Show resolved Hide resolved
gateway-sp-comms/src/single_sp/update.rs Show resolved Hide resolved
@lzrd lzrd force-pushed the update-stage0 branch 6 times, most recently from 8db8400 to 082c523 Compare April 22, 2024 17:13
faux-mgs/src/main.rs Outdated Show resolved Hide resolved
faux-mgs/src/main.rs Outdated Show resolved Hide resolved
gateway-messages/src/lib.rs Outdated Show resolved Hide resolved
gateway-messages/src/mgs_to_sp.rs Show resolved Hide resolved
gateway-messages/src/sp_to_mgs.rs Outdated Show resolved Hide resolved
gateway-messages/src/sp_to_mgs.rs Outdated Show resolved Hide resolved
gateway-messages/tests/versioning/v12.rs Outdated Show resolved Hide resolved
gateway-sp-comms/src/single_sp/update.rs Outdated Show resolved Hide resolved
faux-mgs/src/main.rs Outdated Show resolved Hide resolved
@lzrd lzrd force-pushed the update-stage0 branch 3 times, most recently from 64fc4e9 to 4d3dd86 Compare April 23, 2024 05:46
gateway-messages/tests/versioning/v13.rs Outdated Show resolved Hide resolved
gateway-messages/tests/versioning/v13.rs Outdated Show resolved Hide resolved
gateway-messages/tests/versioning/v13.rs Show resolved Hide resolved
SpComponent::Stage0 (boot loader) is distinct from SpComponent::ROT (Hubris).

There is no support for an atomic switch-over to stage0 bank 1 (stage0next).
Copy from stage0next to stage0 is allowed if stage0next signatuire is valid at boot
time and contents still match boot-time contents.

Note: Only one stage0 update should be in process in a rack at a time to reduce the
chance of an interrupted copy bricking a subsystem.

RotStateV3 includes the FWID of all RoT image flash banks and error
information if an image is not valid. The FWID for invalid banks is
always computed and reported. This allows us to distinguish between
completly erased banks and those that are not completely erased:

The FWID over any erased bank is the "a7ff..." value below:
```
$ touch empty.bin
$ rot-fwid empty.bin
empty.bin 0 a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a
```

Add a versioned RoT Boot Info message to facilitate update of RoT Hubris independant
of SP or RoT being on a later version than the other.

SpStateV3 does not contain RotState because coupling them and allowing for version skew
over-complicates things.

Implement Display for RotState* for nicer human output.

Bumped the faux-mgs crate version

Add test for SpStateV3
@lzrd lzrd merged commit c85a4ca into main Apr 29, 2024
10 checks passed
)]
pub enum ImageError {
/// Image has not been sanity checked (internal use)
Unchecked = 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever care about the in-memory representation of this enum? If not, I'd recommend removing the = 1, because it suggests that we care about the in-memory representation.

Note that the = 1 does not change how this object will be serialized. For example:

#[derive(serde::Serialize)]
enum Foo {
    One = 1,
    Two,
}

fn main() {
    let b = bincode::serialize(&Foo::One).unwrap();
    println!("{b:?}") // prints [0, 0, 0, 0]
}

@lzrd
Copy link
Contributor Author

lzrd commented Apr 29, 2024

You're right, we don't care about the in-memory representation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support update of RoT bootloader
4 participants