Skip to content

Commit 8b21ed6

Browse files
committed
Add more checking of measurement handoff in build script
1 parent 1a0b21f commit 8b21ed6

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

Cargo.lock

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

build/kconfig/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ use std::collections::{BTreeMap, BTreeSet};
88
/// Application configuration passed into the kernel build.
99
#[derive(Clone, Debug, Serialize, Deserialize)]
1010
pub struct KernelConfig {
11+
/// Features enabled in the kernel
12+
pub features: Vec<String>,
13+
14+
/// External regions used in the kernel
15+
pub extern_regions: BTreeMap<String, std::ops::Range<u32>>,
16+
1117
/// Tasks in the app image. The order of tasks is significant.
1218
pub tasks: Vec<TaskConfig>,
1319

build/xtask/src/dist.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,11 @@ pub fn make_kconfig(
28802880
flat_shared.retain(|name, _v| used_shared_regions.contains(name.as_str()));
28812881

28822882
Ok(build_kconfig::KernelConfig {
2883+
features: toml.kernel.features.clone(),
2884+
extern_regions: toml
2885+
.kernel_extern_regions(image_name)?
2886+
.into_iter()
2887+
.collect(),
28832888
irqs,
28842889
tasks,
28852890
shared_regions: flat_shared,

lib/measurement-handoff/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,12 @@ edition = "2021"
66
[dependencies]
77
measurement-token.workspace = true
88

9+
[build-dependencies]
10+
anyhow.workspace = true
11+
ron.workspace = true
12+
measurement-token.workspace = true
13+
build-util.path = "../../build/util"
14+
build-kconfig.path = "../../build/kconfig"
15+
916
[lints]
1017
workspace = true

lib/measurement-handoff/build.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
use anyhow::Context;
6+
7+
// Make various assertions about the handoff region
8+
fn main() -> anyhow::Result<()> {
9+
let kconfig: build_kconfig::KernelConfig =
10+
ron::de::from_str(&build_util::env_var("HUBRIS_KCONFIG")?)
11+
.context("parsing kconfig from HUBRIS_KCONFIG")?;
12+
assert!(
13+
kconfig
14+
.features
15+
.contains(&"measurement-handoff".to_string()),
16+
"missing measurement-handoff feature"
17+
);
18+
let dtcm_range = kconfig
19+
.extern_regions
20+
.get("dtcm")
21+
.expect("missing `dtcm` in `extern_regions`");
22+
assert_eq!(
23+
dtcm_range.start,
24+
measurement_token::ADDR as u32,
25+
"invalid address for token"
26+
);
27+
assert!(
28+
(dtcm_range.end - dtcm_range.start) as usize
29+
>= 4 * std::mem::size_of::<u32>(),
30+
"range is not large enough for handoff"
31+
);
32+
Ok(())
33+
}

0 commit comments

Comments
 (0)