Skip to content

Commit cb0b519

Browse files
committed
deprecate ImageHeader version and epoch
1 parent db85c0b commit cb0b519

File tree

17 files changed

+319
-132
lines changed

17 files changed

+319
-132
lines changed

Cargo.lock

Lines changed: 285 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,14 @@ zip = { version = "0.6", default-features = false, features = ["bzip2"] }
120120
# Oxide forks and repos
121121
attest-data = { git = "https://github.com/oxidecomputer/dice-util", default-features = false, version = "0.2.0" }
122122
dice-mfg-msgs = { git = "https://github.com/oxidecomputer/dice-util", default-features = false, version = "0.2.1" }
123-
#gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false, features = ["smoltcp"] }
124-
# XXX fix before push
125-
gateway-messages = { path = "/home/stoltz/Oxide/src/mgs/epoch/gateway-messages", default-features = false, features = ["smoltcp"] }
123+
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false, features = ["smoltcp"] }
126124
gimlet-inspector-protocol = { git = "https://github.com/oxidecomputer/gimlet-inspector-protocol", version = "0.1.0" }
127125
hif = { git = "https://github.com/oxidecomputer/hif", default-features = false }
128126
humpty = { git = "https://github.com/oxidecomputer/humpty", default-features = false, version = "0.1.3" }
129-
#hubtools = { git = "https://github.com/oxidecomputer/hubtools", default-features = false, version = "0.4.1" }
130-
# XXX fix before push
131-
# hubtools = { git = "https://github.com/oxidecomputer/hubtools", default-features = false, branch = "epoch", version = "0.4.7" }
132-
hubtools = { path = "/home/stoltz/Oxide/src/hubtools/epoch/hubtools" }
127+
hubtools = { git = "https://github.com/oxidecomputer/hubtools", default-features = false, version = "0.4.7" }
133128
idol = { git = "https://github.com/oxidecomputer/idolatry.git", default-features = false }
134129
idol-runtime = { git = "https://github.com/oxidecomputer/idolatry.git", default-features = false }
135-
#lpc55_sign = { git = "https://github.com/oxidecomputer/lpc55_support", default-features = false }
136-
lpc55_sign = { path = "/home/stoltz/Oxide/src/lpc55_support/lpc55_sign", default-features = false }
130+
lpc55_sign = { git = "https://github.com/oxidecomputer/lpc55_support", default-features = false }
137131
ordered-toml = { git = "https://github.com/oxidecomputer/ordered-toml", default-features = false }
138132
pmbus = { git = "https://github.com/oxidecomputer/pmbus", default-features = false }
139133
salty = { version = "0.3", default-features = false }

app/gimlet/base.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ chip = "../../chips/stm32h7"
33
memory = "memory-large.toml"
44
stacksize = 896
55
fwid = true
6-
epoch = 0
76

87
[kernel]
98
name = "gimlet"

app/gimletlet/base-gimletlet2.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ target = "thumbv7em-none-eabihf"
33
chip = "../../chips/stm32h7"
44
memory = "memory-large.toml"
55
stacksize = 896
6-
epoch = 0
7-
version = 0
86
fwid = true
97

108
[kernel]

app/grapefruit/app.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ target = "thumbv7em-none-eabihf"
44
chip = "../../chips/stm32h7"
55
memory = "memory-large.toml"
66
stacksize = 896
7-
epoch = 0
8-
version = 0
97
fwid = true
108

119
[kernel]

app/oxide-rot-1/app-dev.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ board = "oxide-rot-1"
44
chip = "../../chips/lpc55"
55
stacksize = 1024
66
image-names = ["a", "b"]
7-
epoch = 0
8-
version = 0
97
fwid = true
108

119
[kernel]

app/oxide-rot-1/app.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ board = "oxide-rot-1"
44
chip = "../../chips/lpc55"
55
stacksize = 1024
66
image-names = ["a", "b"]
7-
epoch = 0
8-
version = 0
97
fwid = true
108

119
[kernel]

app/rot-carrier/app.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ board = "rot-carrier-2"
44
chip = "../../chips/lpc55"
55
stacksize = 1024
66
image-names = ["a", "b"]
7-
epoch = 0
8-
version = 0
97
fwid = true
108

119
[kernel]

build/xtask/src/config.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ struct RawConfig {
2424
board: String,
2525
chip: String,
2626
#[serde(default)]
27-
epoch: u32,
28-
#[serde(default)]
29-
version: u32,
30-
#[serde(default)]
3127
fwid: bool,
3228
memory: Option<String>,
3329
#[serde(default)]
@@ -50,8 +46,6 @@ pub struct Config {
5046
pub target: String,
5147
pub board: String,
5248
pub chip: String,
53-
pub epoch: u32,
54-
pub version: u32,
5549
pub fwid: bool,
5650
pub image_names: Vec<String>,
5751
pub signing: Option<RoTMfgSettings>,
@@ -174,8 +168,6 @@ impl Config {
174168
board: toml.board,
175169
image_names: img_names,
176170
chip: toml.chip,
177-
epoch: toml.epoch,
178-
version: toml.version,
179171
fwid: toml.fwid,
180172
signing: toml.signing,
181173
stacksize: toml.stacksize,
@@ -254,11 +246,6 @@ impl Config {
254246
let task_names =
255247
self.tasks.keys().cloned().collect::<Vec<_>>().join(",");
256248
env.insert("HUBRIS_TASKS".to_string(), task_names);
257-
env.insert(
258-
"HUBRIS_BUILD_VERSION".to_string(),
259-
format!("{}", self.version),
260-
);
261-
env.insert("HUBRIS_BUILD_EPOCH".to_string(), format!("{}", self.epoch));
262249
env.insert("HUBRIS_BOARD".to_string(), self.board.to_string());
263250
env.insert(
264251
"HUBRIS_APP_TOML".to_string(),

build/xtask/src/dist.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ fn build_kernel(
12511251
/// Returns true if the header was found and updated,
12521252
/// false otherwise.
12531253
fn update_image_header(
1254-
cfg: &PackageConfig,
1254+
_cfg: &PackageConfig,
12551255
input: &Path,
12561256
output: &Path,
12571257
map: &IndexMap<String, Range<u32>>,
@@ -1290,16 +1290,8 @@ fn update_image_header(
12901290
// `xtask build kernel`, we need a result from this calculation
12911291
// but `end` will be `None`. Substitute a placeholder:
12921292
let end = end.unwrap_or(flash.start);
1293-
12941293
let len = end - flash.start;
1295-
1296-
let header = abi::ImageHeader {
1297-
version: cfg.toml.version,
1298-
epoch: cfg.toml.epoch,
1299-
magic: abi::HEADER_MAGIC,
1300-
total_image_len: len,
1301-
..Default::default()
1302-
};
1294+
let header = abi::ImageHeader::new(len);
13031295

13041296
header
13051297
.write_to_prefix(

drv/lpc55-update-server/build.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
use std::fs::File;
6-
use std::io::Write;
7-
85
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
96
build_util::expose_target_board();
107
build_util::build_notifications()?;
@@ -18,15 +15,5 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1815
"server_stub.rs",
1916
idol::server::ServerStyle::InOrder,
2017
)?;
21-
22-
let out = build_util::out_dir();
23-
let mut ver_file = File::create(out.join("consts.rs")).unwrap();
24-
25-
let version: u32 = build_util::env_var("HUBRIS_BUILD_VERSION")?.parse()?;
26-
let epoch: u32 = build_util::env_var("HUBRIS_BUILD_EPOCH")?.parse()?;
27-
28-
writeln!(ver_file, "const HUBRIS_BUILD_VERSION: u32 = {};", version)?;
29-
writeln!(ver_file, "const HUBRIS_BUILD_EPOCH: u32 = {};", epoch)?;
30-
3118
Ok(())
3219
}

drv/lpc55-update-server/src/images.rs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl TryFrom<&[u8]> for ImageVectorsLpc55 {
185185
/// the end of optional caboose and the beginning of the signature block.
186186
pub fn validate_header_block(
187187
header_access: &ImageAccess<'_>,
188-
) -> Result<(Option<Epoch>, u32), UpdateError> {
188+
) -> Result<u32, UpdateError> {
189189
let mut vectors = ImageVectorsLpc55::new_zeroed();
190190
let mut header = ImageHeader::new_zeroed();
191191

@@ -212,17 +212,14 @@ pub fn validate_header_block(
212212
// Note that `ImageHeader.epoch` is used by rollback protection for early
213213
// rejection of invalid images.
214214
// TODO: Improve estimate of where the first executable instruction can be.
215-
let (code_offset, epoch) = if header.magic == HEADER_MAGIC {
215+
let code_offset = if header.magic == HEADER_MAGIC {
216216
if header.total_image_len != vectors.nxp_offset_to_specific_header {
217217
// ImageHeader disagrees with LPC55 vectors.
218218
return Err(UpdateError::InvalidHeaderBlock);
219219
}
220-
(
221-
IMAGE_HEADER_OFFSET + (core::mem::size_of::<ImageHeader>() as u32),
222-
Some(Epoch::from(header.epoch)),
223-
)
220+
IMAGE_HEADER_OFFSET + (core::mem::size_of::<ImageHeader>() as u32)
224221
} else {
225-
(IMAGE_HEADER_OFFSET, None)
222+
IMAGE_HEADER_OFFSET
226223
};
227224

228225
if vectors.nxp_image_length as usize > header_access.at_runtime().len() {
@@ -249,7 +246,7 @@ pub fn validate_header_block(
249246
return Err(UpdateError::InvalidHeaderBlock);
250247
}
251248

252-
Ok((epoch, vectors.nxp_offset_to_specific_header))
249+
Ok(vectors.nxp_offset_to_specific_header)
253250
}
254251

255252
/// Get the range of the caboose contained within an image if it exists.
@@ -266,7 +263,7 @@ pub fn caboose_slice(
266263
//
267264
// In this context, NoImageHeader actually means that the image
268265
// is not well formed.
269-
let (_epoch, image_end_offset) = validate_header_block(image)
266+
let image_end_offset = validate_header_block(image)
270267
.map_err(|_| RawCabooseError::NoImageHeader)?;
271268

272269
// By construction, the last word of the caboose is its size as a `u32`
@@ -651,33 +648,17 @@ pub fn check_rollback_policy(
651648
fn get_image_epoch(
652649
image: &ImageAccess<'_>,
653650
) -> Result<Option<Epoch>, UpdateError> {
654-
let (header_epoch, _caboose_offset) = validate_header_block(image)?;
655-
656651
if let Ok(span) = caboose_slice(image) {
657652
let mut block = [0u8; BLOCK_SIZE_BYTES];
658653
let caboose = block[0..span.len()].as_bytes_mut();
659654
image.read_bytes(span.start, caboose)?;
660655
let reader = CabooseReader::new(caboose);
661-
let caboose_epoch = if let Ok(epoc) = reader.get(CABOOSE_TAG_EPOC) {
662-
Some(Epoch::from(epoc))
656+
if let Ok(epoc) = reader.get(CABOOSE_TAG_EPOC) {
657+
Ok(Some(Epoch::from(epoc)))
663658
} else {
664-
None
665-
};
666-
match (header_epoch, caboose_epoch) {
667-
(None, None) => Ok(None),
668-
(Some(header_epoch), None) => Ok(Some(header_epoch)),
669-
(None, Some(caboose_epoch)) => Ok(Some(caboose_epoch)),
670-
(Some(header_epoch), Some(caboose_epoch)) => {
671-
if caboose_epoch == header_epoch {
672-
Ok(Some(caboose_epoch))
673-
} else {
674-
// Epochs present in both and not matching is invalid.
675-
// The image will be rejected after epoch 0.
676-
Ok(Some(Epoch::from(0u32)))
677-
}
678-
}
659+
Ok(None)
679660
}
680661
} else {
681-
Ok(header_epoch)
662+
Ok(None)
682663
}
683664
}

drv/lpc55-update-server/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,14 @@ impl idl::InOrderUpdateImpl for ServerImpl<'_> {
289289

290290
// TODO(AJS): Remove this in favor of `status`, once SP code is updated.
291291
// This has ripple effects up through control-plane-agent.
292+
/// Deprecated. The version and epoch are in the Caboose
292293
fn current_version(
293294
&mut self,
294295
_: &RecvMessage,
295296
) -> Result<ImageVersion, RequestError<Infallible>> {
296297
Ok(ImageVersion {
297-
epoch: HUBRIS_BUILD_EPOCH,
298-
version: HUBRIS_BUILD_VERSION,
298+
epoch: 0,
299+
version: 0,
299300
})
300301
}
301302

@@ -1312,7 +1313,6 @@ fn main() -> ! {
13121313
}
13131314
}
13141315

1315-
include!(concat!(env!("OUT_DIR"), "/consts.rs"));
13161316
include!(concat!(env!("OUT_DIR"), "/notifications.rs"));
13171317
mod idl {
13181318
use super::{

drv/sprot-api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ SpRot.status() => Status {
461461
}
462462
```
463463
464-
Update API, retrieve current version.
464+
Update API, retrieve current version (deprecated)
465465
This information is redundant with information in the Status structure.
466466
```sh
467467
$ humility hiffy -c SpRot.current_version

drv/stm32h7-update-server/build.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
use std::fs::File;
6-
use std::io::Write;
7-
85
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
96
build_util::build_notifications()?;
107
idol::Generator::new()
@@ -16,15 +13,5 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1613
"server_stub.rs",
1714
idol::server::ServerStyle::InOrder,
1815
)?;
19-
20-
let out = build_util::out_dir();
21-
let mut ver_file = File::create(out.join("consts.rs")).unwrap();
22-
23-
let version: u32 = build_util::env_var("HUBRIS_BUILD_VERSION")?.parse()?;
24-
let epoch: u32 = build_util::env_var("HUBRIS_BUILD_EPOCH")?.parse()?;
25-
26-
writeln!(ver_file, "const HUBRIS_BUILD_VERSION: u32 = {};", version)?;
27-
writeln!(ver_file, "const HUBRIS_BUILD_EPOCH: u32 = {};", epoch)?;
28-
2916
Ok(())
3017
}

drv/stm32h7-update-server/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,14 @@ impl idl::InOrderUpdateImpl for ServerImpl<'_> {
416416
Ok(BLOCK_SIZE_BYTES)
417417
}
418418

419+
/// Deprecated. The version and epoch values are in the Caboose.
419420
fn current_version(
420421
&mut self,
421422
_: &RecvMessage,
422423
) -> Result<ImageVersion, RequestError<Infallible>> {
423424
Ok(ImageVersion {
424-
epoch: HUBRIS_BUILD_EPOCH,
425-
version: HUBRIS_BUILD_VERSION,
425+
epoch: 0,
426+
version: 0,
426427
})
427428
}
428429

@@ -569,7 +570,6 @@ fn main() -> ! {
569570
}
570571
}
571572

572-
include!(concat!(env!("OUT_DIR"), "/consts.rs"));
573573
mod idl {
574574
use super::{CabooseError, ImageVersion, SlotId};
575575

sys/abi/src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,18 @@ pub struct ImageHeader {
520520
pub magic: u32,
521521
pub total_image_len: u32,
522522
pub _pad: [u32; 16], // previous location of SAU entries
523-
pub version: u32,
524-
pub epoch: u32,
523+
pub _version: u32,
524+
pub _epoch: u32,
525+
}
526+
527+
impl ImageHeader {
528+
pub fn new(total_image_len: u32) -> Self {
529+
ImageHeader {
530+
magic: HEADER_MAGIC,
531+
total_image_len,
532+
..Default::default()
533+
}
534+
}
525535
}
526536

527537
// Corresponds to the ARM vector table, limited to what we need

0 commit comments

Comments
 (0)