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

Hw model cold reset support #1454

Merged
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
72 changes: 38 additions & 34 deletions drivers/tests/drivers_integration_tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ fn default_init_params() -> InitParams<'static> {

fn start_driver_test(test_rom: &'static FwId) -> Result<DefaultHwModel, Box<dyn Error>> {
let rom = caliptra_builder::build_firmware_rom(test_rom)?;
caliptra_hw_model::new(BootParams {
init_params: InitParams {
caliptra_hw_model::new(
InitParams {
rom: &rom,
..default_init_params()
},
..Default::default()
})
BootParams::default(),
)
}

fn run_driver_test(test_rom: &'static FwId) {
Expand Down Expand Up @@ -207,16 +207,16 @@ fn test_generate_doe_vectors_when_debug_not_locked() {
#[test]
fn test_doe_when_debug_not_locked() {
let rom = caliptra_builder::build_firmware_rom(&firmware::driver_tests::DOE).unwrap();
let mut model = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut model = caliptra_hw_model::new(
InitParams {
rom: &rom,
security_state: *SecurityState::from(0)
.set_debug_locked(false)
.set_device_lifecycle(DeviceLifecycle::Unprovisioned),
..default_init_params()
},
..Default::default()
})
BootParams::default(),
)
.unwrap();

let txn = model.wait_for_mailbox_receive().unwrap();
Expand Down Expand Up @@ -301,16 +301,16 @@ fn test_generate_doe_vectors_when_debug_locked() {
#[test]
fn test_doe_when_debug_locked() {
let rom = caliptra_builder::build_firmware_rom(&firmware::driver_tests::DOE).unwrap();
let mut model = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut model = caliptra_hw_model::new(
InitParams {
rom: &rom,
security_state: *SecurityState::from(0)
.set_debug_locked(true)
.set_device_lifecycle(DeviceLifecycle::Unprovisioned),
..default_init_params()
},
..Default::default()
})
BootParams::default(),
)
.unwrap();

let txn = model.wait_for_mailbox_receive().unwrap();
Expand Down Expand Up @@ -785,14 +785,14 @@ fn test_csrng_with_nibbles(
) {
let rom = caliptra_builder::build_firmware_rom(fwid).unwrap();

let mut model = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut model = caliptra_hw_model::new(
InitParams {
rom: &rom,
itrng_nibbles,
..default_init_params()
},
..Default::default()
})
BootParams::default(),
)
.unwrap();

model.step_until_exit_success().unwrap();
Expand Down Expand Up @@ -854,15 +854,17 @@ fn test_csrng_repetition_count() {
.cycle()
});

let mut model = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut model = caliptra_hw_model::new(
InitParams {
rom: &rom,
itrng_nibbles,
..default_init_params()
},
initial_repcnt_thresh_reg: soc_repcnt_threshold,
..Default::default()
})
BootParams {
initial_repcnt_thresh_reg: soc_repcnt_threshold,
..Default::default()
},
)
.unwrap();

model.step_until_exit_success().unwrap();
Expand Down Expand Up @@ -976,15 +978,17 @@ fn test_csrng_adaptive_proportion() {
.high_threshold(HI_THRESHOLD)
.low_threshold(LO_THRESHOLD);

let mut model = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut model = caliptra_hw_model::new(
InitParams {
rom: &rom,
itrng_nibbles,
..default_init_params()
},
initial_adaptp_thresh_reg: Some(threshold_reg),
..Default::default()
})
BootParams {
initial_adaptp_thresh_reg: Some(threshold_reg),
..Default::default()
},
)
.unwrap();

model.step_until_exit_success().unwrap();
Expand Down Expand Up @@ -1016,15 +1020,15 @@ fn test_trng_in_itrng_mode() {
let rom = caliptra_builder::build_firmware_rom(&firmware::driver_tests::TRNG_DRIVER_RESPONDER)
.unwrap();

let mut model = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut model = caliptra_hw_model::new(
InitParams {
rom: &rom,
itrng_nibbles: Box::new(trng_nibbles()),
trng_mode: Some(TrngMode::Internal),
..default_init_params()
},
..Default::default()
})
BootParams::default(),
)
.unwrap();

let trng_block = model.mailbox_execute(0, &[]).unwrap();
Expand Down Expand Up @@ -1071,8 +1075,8 @@ fn test_trng_in_etrng_mode() {
let rom = caliptra_builder::build_firmware_rom(&firmware::driver_tests::TRNG_DRIVER_RESPONDER)
.unwrap();

let mut model = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut model = caliptra_hw_model::new(
InitParams {
rom: &rom,
itrng_nibbles: Box::new([].iter().copied()),
etrng_responses: Box::new(
Expand All @@ -1091,8 +1095,8 @@ fn test_trng_in_etrng_mode() {
trng_mode: Some(TrngMode::External),
..default_init_params()
},
..Default::default()
})
BootParams::default(),
)
.unwrap();

let trng_block = model.mailbox_execute(0, &[]).unwrap();
Expand Down
12 changes: 7 additions & 5 deletions fmc/tests/fmc_integration_tests/test_hand_off.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ fn test_hand_off() {
)
.unwrap();

let mut hw = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut hw = caliptra_hw_model::new(
InitParams {
rom: &rom,
..Default::default()
},
fw_image: Some(&image.to_bytes().unwrap()),
..Default::default()
})
BootParams {
fw_image: Some(&image.to_bytes().unwrap()),
..Default::default()
},
)
.unwrap();

let mut output = vec![];
Expand Down
36 changes: 21 additions & 15 deletions fmc/tests/fmc_integration_tests/test_rtalias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ fn test_boot_status_reporting() {
)
.unwrap();

let mut hw = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut hw = caliptra_hw_model::new(
InitParams {
rom: &rom,
..Default::default()
},
fw_image: Some(&image.to_bytes().unwrap()),
..Default::default()
})
BootParams {
fw_image: Some(&image.to_bytes().unwrap()),
..Default::default()
},
)
.unwrap();

hw.step_until_boot_status(RT_ALIAS_MEASUREMENT_COMPLETE, true);
Expand All @@ -74,14 +76,16 @@ fn test_fht_info() {
)
.unwrap();

let mut hw = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut hw = caliptra_hw_model::new(
InitParams {
rom: &rom,
..Default::default()
},
fw_image: Some(&image.to_bytes().unwrap()),
..Default::default()
})
BootParams {
fw_image: Some(&image.to_bytes().unwrap()),
..Default::default()
},
)
.unwrap();

let data = hw.mailbox_execute(TEST_CMD_READ_FHT, &[]).unwrap().unwrap();
Expand All @@ -108,14 +112,16 @@ fn test_pcr_log() {
)
.unwrap();

let mut hw = caliptra_hw_model::new(BootParams {
init_params: InitParams {
let mut hw = caliptra_hw_model::new(
InitParams {
rom: &rom,
..Default::default()
},
fw_image: Some(&image1.to_bytes().unwrap()),
..Default::default()
})
BootParams {
fw_image: Some(&image1.to_bytes().unwrap()),
..Default::default()
},
)
.unwrap();

let data = hw.mailbox_execute(TEST_CMD_READ_FHT, &[]).unwrap().unwrap();
Expand Down
Loading
Loading