Skip to content

Commit cccf641

Browse files
authored
Skip FPGA ROM tests in nightly when testing with older ROMs (#2263)
- Adds rom feature to drivers to exclude hw-1.0 support - Exclude FIPS tests for hw-1.0 that require building ROM with test hooks - Fix some RT integration tests that call the wrong ROM builder function
1 parent c6334bf commit cccf641

10 files changed

Lines changed: 48 additions & 7 deletions

File tree

.github/workflows/fpga.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ jobs:
170170
run: |
171171
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="aarch64-linux-gnu-gcc"
172172
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=--sysroot=$FARGO_SYSROOT"
173+
EXCLUDE_ARG=""
173174
if [ "${{ inputs.rom-version }}" != "latest" ]; then
174175
export CPTRA_CI_ROM_VERSION="${{ inputs.rom-version }}"
176+
# Skip ROM tests when testing with older ROMs
177+
EXCLUDE_ARG="--exclude caliptra-rom"
175178
fi
176179
177180
if [ "${{ inputs.workflow_call }}" ]; then
@@ -183,6 +186,8 @@ jobs:
183186
FEATURES=$FEATURES,hw-${{ inputs.hw-version }}
184187
fi
185188
cargo nextest archive \
189+
--workspace \
190+
$EXCLUDE_ARG \
186191
--features=${FEATURES} \
187192
--release \
188193
--target=aarch64-unknown-linux-gnu \

drivers/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ caliptra-cfi-derive-git = { workspace = true, optional = true }
2929

3030
[features]
3131
emu = []
32+
rom = []
3233
runtime = ["dep:dpe", "dep:caliptra-cfi-lib-git", "dep:caliptra-cfi-derive-git"]
3334
fmc = []
3435
fpga_realtime = ["caliptra-hw-model/fpga_realtime"]

drivers/src/hmac384.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ impl Hmac384 {
176176

177177
let rand_data = trng.generate()?;
178178

179-
#[cfg(any(feature = "fmc", feature = "runtime"))]
179+
// Support HW 1.0 RTL (except for ROM)
180+
#[cfg(not(feature = "rom"))]
180181
if crate::soc_ifc::is_hw_gen_1_0() {
181182
use crate::Array4x5;
182183
let iv: [u32; 5] = rand_data.0[..5].try_into().unwrap();

drivers/src/lms.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ impl Lms {
320320
) -> CaliptraResult<HashValue<N>> {
321321
let iteration_count = ((1u16 << params.w) - 1) as u8;
322322

323-
#[cfg(any(feature = "fmc", feature = "runtime"))]
323+
// Support HW 1.0 RTL (except for ROM)
324+
#[cfg(not(feature = "rom"))]
324325
if crate::soc_ifc::is_hw_gen_1_0() {
325326
// RTL 1.0 version (no HW acceleration)
326327
for j in coeff..iteration_count {

rom/dev/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rust-version = "1.70"
1010
caliptra-cfi-lib = { workspace = true, default-features = false, features = ["cfi", "cfi-counter" ] }
1111
caliptra-cfi-derive.workspace = true
1212
caliptra_common = { workspace = true, default-features = false, features = ["rom"] }
13-
caliptra-drivers.workspace = true
13+
caliptra-drivers = { workspace = true, features = ["rom"] }
1414
caliptra-error = { workspace = true, default-features = false }
1515
caliptra-image-types = { workspace = true, default-features = false }
1616
caliptra-image-verify = { workspace = true, default-features = false }

runtime/tests/runtime_integration_tests/test_warm_reset.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use caliptra_api::soc_mgr::SocManager;
44
use caliptra_builder::{
5-
firmware::{self, runtime_tests::MBOX, APP_WITH_UART, FMC_WITH_UART, ROM_WITH_UART},
5+
firmware::{self, runtime_tests::MBOX, APP_WITH_UART, FMC_WITH_UART},
66
ImageOptions,
77
};
88
use caliptra_error::CaliptraError;
@@ -29,7 +29,7 @@ fn test_rt_journey_pcr_validation() {
2929
.set_debug_locked(true)
3030
.set_device_lifecycle(DeviceLifecycle::Production);
3131

32-
let rom = caliptra_builder::build_firmware_rom(&ROM_WITH_UART).unwrap();
32+
let rom = caliptra_builder::rom_for_fw_integration_tests().unwrap();
3333
let image = caliptra_builder::build_and_sign_image(
3434
&FMC_WITH_UART,
3535
&firmware::runtime_tests::MBOX,
@@ -98,7 +98,7 @@ fn test_mbox_busy_during_warm_reset() {
9898
.set_debug_locked(true)
9999
.set_device_lifecycle(DeviceLifecycle::Production);
100100

101-
let rom = caliptra_builder::build_firmware_rom(&ROM_WITH_UART).unwrap();
101+
let rom = caliptra_builder::rom_for_fw_integration_tests().unwrap();
102102
let image = caliptra_builder::build_and_sign_image(
103103
&FMC_WITH_UART,
104104
&MBOX,
@@ -167,7 +167,7 @@ fn test_mbox_idle_during_warm_reset() {
167167
.set_debug_locked(true)
168168
.set_device_lifecycle(DeviceLifecycle::Production);
169169

170-
let rom = caliptra_builder::build_firmware_rom(&ROM_WITH_UART).unwrap();
170+
let rom = caliptra_builder::rom_for_fw_integration_tests().unwrap();
171171
let image = caliptra_builder::build_and_sign_image(
172172
&FMC_WITH_UART,
173173
&APP_WITH_UART,

test/tests/fips_test_suite/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Support for additional environments can be done by creating new implementations/
4242

4343
Certain tests require "hooks" into the ROM or FW to cause operation to deviate from the normal flow (ie. injecting errors or halting execution at specific points). This functionality is enabled using a build option called "fips-test-hooks". Then, the specific command codes are written and read from the DBG_MANUF_SERVICE_REG. The ROM/FW can respond back with a status code written to the same field if applicable. See command codes in drivers\src\fips_test_hooks.rs for more details.
4444

45+
Note the ROM with test hooks can only be built for the current ROM within the same git commit. Because of this, the test suite cannot perform these tests against older versions of the HW since it cannot build the compatible ROM. To run those tests, execute the test suite from the same commit as the applicable ROM.
46+
4547
Test hooks are needed to meet the following FIPS 140-3 test requirements:
4648
TE03.07.02
4749
TE03.07.04

test/tests/fips_test_suite/fw_load.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ fn fw_load_error_vendor_pub_key_digest_invalid() {
287287

288288
#[test]
289289
#[cfg(not(feature = "test_env_immutable_rom"))]
290+
#[cfg(not(feature = "hw-1.0"))]
290291
fn fw_load_error_vendor_pub_key_digest_failure() {
291292
// Set fuses
292293
let fuses = caliptra_hw_model::Fuses {
@@ -321,6 +322,7 @@ fn fw_load_error_vendor_pub_key_digest_mismatch() {
321322

322323
#[test]
323324
#[cfg(not(feature = "test_env_immutable_rom"))]
325+
#[cfg(not(feature = "hw-1.0"))]
324326
fn fw_load_error_owner_pub_key_digest_failure() {
325327
fw_load_error_flow_with_test_hooks(
326328
None,
@@ -386,6 +388,7 @@ fn fw_load_error_vendor_ecc_pub_key_revoked() {
386388

387389
#[test]
388390
#[cfg(not(feature = "test_env_immutable_rom"))]
391+
#[cfg(not(feature = "hw-1.0"))]
389392
fn fw_load_error_header_digest_failure() {
390393
fw_load_error_flow_with_test_hooks(
391394
None,
@@ -397,6 +400,7 @@ fn fw_load_error_header_digest_failure() {
397400

398401
#[test]
399402
#[cfg(not(feature = "test_env_immutable_rom"))]
403+
#[cfg(not(feature = "hw-1.0"))]
400404
fn fw_load_error_vendor_ecc_verify_failure() {
401405
fw_load_error_flow_with_test_hooks(
402406
None,
@@ -438,6 +442,7 @@ fn fw_load_error_vendor_ecc_pub_key_index_mismatch() {
438442

439443
#[test]
440444
#[cfg(not(feature = "test_env_immutable_rom"))]
445+
#[cfg(not(feature = "hw-1.0"))]
441446
fn fw_load_error_owner_ecc_verify_failure() {
442447
fw_load_error_flow_with_test_hooks(
443448
None,
@@ -478,6 +483,7 @@ fn fw_load_error_toc_entry_count_invalid() {
478483

479484
#[test]
480485
#[cfg(not(feature = "test_env_immutable_rom"))]
486+
#[cfg(not(feature = "hw-1.0"))]
481487
fn fw_load_error_toc_digest_failure() {
482488
fw_load_error_flow_with_test_hooks(
483489
None,
@@ -504,6 +510,7 @@ fn fw_load_error_toc_digest_mismatch() {
504510

505511
#[test]
506512
#[cfg(not(feature = "test_env_immutable_rom"))]
513+
#[cfg(not(feature = "hw-1.0"))]
507514
fn fw_load_error_fmc_digest_failure() {
508515
fw_load_error_flow_with_test_hooks(
509516
None,
@@ -529,6 +536,7 @@ fn fw_load_error_fmc_digest_mismatch() {
529536

530537
#[test]
531538
#[cfg(not(feature = "test_env_immutable_rom"))]
539+
#[cfg(not(feature = "hw-1.0"))]
532540
fn fw_load_error_runtime_digest_failure() {
533541
fw_load_error_flow_with_test_hooks(
534542
None,
@@ -1003,6 +1011,7 @@ fn fw_load_error_vendor_lms_pub_key_index_mismatch() {
10031011

10041012
#[test]
10051013
#[cfg(not(feature = "test_env_immutable_rom"))]
1014+
#[cfg(not(feature = "hw-1.0"))]
10061015
fn fw_load_error_vendor_lms_verify_failure() {
10071016
// Turn LMS verify on
10081017
let fuses = caliptra_hw_model::Fuses {
@@ -1077,6 +1086,7 @@ fn fw_load_error_fmc_runtime_load_addr_overlap() {
10771086

10781087
#[test]
10791088
#[cfg(not(feature = "test_env_immutable_rom"))]
1089+
#[cfg(not(feature = "hw-1.0"))]
10801090
fn fw_load_error_owner_lms_verify_failure() {
10811091
// Turn LMS verify on
10821092
let fuses = caliptra_hw_model::Fuses {

test/tests/fips_test_suite/security_parameters.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ pub fn attempt_ssp_access_rom() {
153153

154154
#[test]
155155
#[cfg(not(feature = "test_env_immutable_rom"))]
156+
#[cfg(not(feature = "hw-1.0"))]
156157
pub fn attempt_ssp_access_fw_load() {
157158
let rom = caliptra_builder::build_firmware_rom(&ROM_WITH_FIPS_TEST_HOOKS).unwrap();
158159

test/tests/fips_test_suite/self_tests.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use zerocopy::IntoBytes;
1616

1717
#[test]
1818
#[cfg(not(feature = "test_env_immutable_rom"))]
19+
#[cfg(not(feature = "hw-1.0"))]
1920
pub fn kat_halt_check_no_output() {
2021
let rom = caliptra_builder::build_firmware_rom(&ROM_WITH_FIPS_TEST_HOOKS).unwrap();
2122

@@ -40,6 +41,7 @@ pub fn kat_halt_check_no_output() {
4041

4142
#[test]
4243
#[cfg(not(feature = "test_env_immutable_rom"))]
44+
#[cfg(not(feature = "hw-1.0"))]
4345
pub fn fw_load_halt_check_no_output() {
4446
let rom = caliptra_builder::build_firmware_rom(&ROM_WITH_FIPS_TEST_HOOKS).unwrap();
4547

@@ -67,6 +69,8 @@ pub fn fw_load_halt_check_no_output() {
6769
// NOTE: SHA engine is not locked during FW load
6870
}
6971

72+
// This is not compatible with hw-1.0 because we cannot build a 1.0 ROM from this newer version of the repo
73+
#[cfg(not(feature = "hw-1.0"))]
7074
fn self_test_failure_flow_rom(hook_code: u8, exp_error_code: u32) {
7175
let rom = caliptra_builder::build_firmware_rom(&ROM_WITH_FIPS_TEST_HOOKS).unwrap();
7276

@@ -240,6 +244,7 @@ fn self_test_failure_flow_rt(hook_code: u8, exp_error_code: u32) {
240244

241245
#[test]
242246
#[cfg(not(feature = "test_env_immutable_rom"))]
247+
#[cfg(not(feature = "hw-1.0"))]
243248
pub fn kat_sha1_digest_failure_rom() {
244249
self_test_failure_flow_rom(
245250
FipsTestHook::SHA1_DIGEST_FAILURE,
@@ -257,6 +262,7 @@ pub fn kat_sha1_digest_failure_rt() {
257262

258263
#[test]
259264
#[cfg(not(feature = "test_env_immutable_rom"))]
265+
#[cfg(not(feature = "hw-1.0"))]
260266
pub fn kat_sha1_digest_mismatch_rom() {
261267
self_test_failure_flow_rom(
262268
FipsTestHook::SHA1_CORRUPT_DIGEST,
@@ -274,6 +280,7 @@ pub fn kat_sha1_digest_mismatch_rt() {
274280

275281
#[test]
276282
#[cfg(not(feature = "test_env_immutable_rom"))]
283+
#[cfg(not(feature = "hw-1.0"))]
277284
pub fn kat_sha256_digest_failure_rom() {
278285
self_test_failure_flow_rom(
279286
FipsTestHook::SHA256_DIGEST_FAILURE,
@@ -291,6 +298,7 @@ pub fn kat_sha256_digest_failure_rt() {
291298

292299
#[test]
293300
#[cfg(not(feature = "test_env_immutable_rom"))]
301+
#[cfg(not(feature = "hw-1.0"))]
294302
pub fn kat_sha256_digest_mismatch_rom() {
295303
self_test_failure_flow_rom(
296304
FipsTestHook::SHA256_CORRUPT_DIGEST,
@@ -308,6 +316,7 @@ pub fn kat_sha256_digest_mismatch_rt() {
308316

309317
#[test]
310318
#[cfg(not(feature = "test_env_immutable_rom"))]
319+
#[cfg(not(feature = "hw-1.0"))]
311320
pub fn kat_sha384_digest_failure_rom() {
312321
self_test_failure_flow_rom(
313322
FipsTestHook::SHA384_DIGEST_FAILURE,
@@ -325,6 +334,7 @@ pub fn kat_sha384_digest_failure_rt() {
325334

326335
#[test]
327336
#[cfg(not(feature = "test_env_immutable_rom"))]
337+
#[cfg(not(feature = "hw-1.0"))]
328338
pub fn kat_sha384_digest_mismatch_rom() {
329339
self_test_failure_flow_rom(
330340
FipsTestHook::SHA384_CORRUPT_DIGEST,
@@ -342,6 +352,7 @@ pub fn kat_sha384_digest_mismatch_rt() {
342352

343353
#[test]
344354
#[cfg(not(feature = "test_env_immutable_rom"))]
355+
#[cfg(not(feature = "hw-1.0"))]
345356
pub fn kat_sha2_512_384acc_digest_start_op_failure_rom() {
346357
self_test_failure_flow_rom(
347358
FipsTestHook::SHA2_512_384_ACC_START_OP_FAILURE,
@@ -359,6 +370,7 @@ pub fn kat_sha2_512_384acc_digest_start_op_failure_rt() {
359370

360371
#[test]
361372
#[cfg(not(feature = "test_env_immutable_rom"))]
373+
#[cfg(not(feature = "hw-1.0"))]
362374
pub fn kat_sha2_512_384acc_digest_failure_rom() {
363375
self_test_failure_flow_rom(
364376
FipsTestHook::SHA2_512_384_ACC_DIGEST_512_FAILURE,
@@ -376,6 +388,7 @@ pub fn kat_sha2_512_384acc_digest_failure_rt() {
376388

377389
#[test]
378390
#[cfg(not(feature = "test_env_immutable_rom"))]
391+
#[cfg(not(feature = "hw-1.0"))]
379392
pub fn kat_sha2_512_384acc_digest_mismatch_rom() {
380393
self_test_failure_flow_rom(
381394
FipsTestHook::SHA2_512_384_ACC_CORRUPT_DIGEST_512,
@@ -393,6 +406,7 @@ pub fn kat_sha2_512_384acc_digest_mismatch_rt() {
393406

394407
#[test]
395408
#[cfg(not(feature = "test_env_immutable_rom"))]
409+
#[cfg(not(feature = "hw-1.0"))]
396410
pub fn kat_ecc384_signature_generate_failure_rom() {
397411
self_test_failure_flow_rom(
398412
FipsTestHook::ECC384_SIGNATURE_GENERATE_FAILURE,
@@ -410,6 +424,7 @@ pub fn kat_ecc384_signature_generate_failure_rt() {
410424

411425
#[test]
412426
#[cfg(not(feature = "test_env_immutable_rom"))]
427+
#[cfg(not(feature = "hw-1.0"))]
413428
pub fn kat_ecc384_signature_verify_failure_rom() {
414429
self_test_failure_flow_rom(
415430
FipsTestHook::ECC384_CORRUPT_SIGNATURE,
@@ -427,6 +442,7 @@ pub fn kat_ecc384_signature_verify_failure_rt() {
427442

428443
#[test]
429444
#[cfg(not(feature = "test_env_immutable_rom"))]
445+
#[cfg(not(feature = "hw-1.0"))]
430446
pub fn kat_ecc384_deterministic_key_gen_generate_failure_rom() {
431447
self_test_failure_flow_rom(
432448
FipsTestHook::ECC384_KEY_PAIR_GENERATE_FAILURE,
@@ -444,6 +460,7 @@ pub fn kat_ecc384_deterministic_key_gen_generate_failure_rt() {
444460

445461
#[test]
446462
#[cfg(not(feature = "test_env_immutable_rom"))]
463+
#[cfg(not(feature = "hw-1.0"))]
447464
pub fn kat_ecc384_deterministic_key_gen_verify_failure_rom() {
448465
self_test_failure_flow_rom(
449466
FipsTestHook::ECC384_CORRUPT_KEY_PAIR,
@@ -461,6 +478,7 @@ pub fn kat_ecc384_deterministic_key_gen_verify_failure_rt() {
461478

462479
#[test]
463480
#[cfg(not(feature = "test_env_immutable_rom"))]
481+
#[cfg(not(feature = "hw-1.0"))]
464482
pub fn kat_hmac384_failure_rom() {
465483
self_test_failure_flow_rom(
466484
FipsTestHook::HMAC384_FAILURE,
@@ -478,6 +496,7 @@ pub fn kat_hmac384_failure_rt() {
478496

479497
#[test]
480498
#[cfg(not(feature = "test_env_immutable_rom"))]
499+
#[cfg(not(feature = "hw-1.0"))]
481500
pub fn kat_hmac384_tag_mismatch_rom() {
482501
self_test_failure_flow_rom(
483502
FipsTestHook::HMAC384_CORRUPT_TAG,
@@ -495,6 +514,7 @@ pub fn kat_hmac384_tag_mismatch_rt() {
495514

496515
#[test]
497516
#[cfg(not(feature = "test_env_immutable_rom"))]
517+
#[cfg(not(feature = "hw-1.0"))]
498518
pub fn kat_lms_digest_mismatch_rom() {
499519
self_test_failure_flow_rom(
500520
FipsTestHook::LMS_CORRUPT_INPUT,

0 commit comments

Comments
 (0)