diff --git a/.github/workflows/fpga.yml b/.github/workflows/fpga.yml index db2604eb77..ff359795a1 100644 --- a/.github/workflows/fpga.yml +++ b/.github/workflows/fpga.yml @@ -420,6 +420,10 @@ jobs: TEST_BIN=/tmp/caliptra-test-binaries VARS="CPTRA_UIO_NUM=4 CALIPTRA_PREBUILT_FW_DIR=/tmp/caliptra-test-firmware CALIPTRA_IMAGE_NO_GIT_REVISION=1" + if [[ "${{ inputs.workflow_call }}" && "${{ inputs.hw-version }}" != "latest" ]]; then + VARS+=" FIPS_TEST_HW_EXP_VERSION=1_0_0" + fi + if [ "${{ inputs.rom-logging }}" == "true" ] || [ -z "${{ inputs.rom-logging }}" ]; then VARS+=" CPTRA_ROM_TYPE=ROM_WITH_UART" elif [ "${{ inputs.rom-logging }}" == false ]; then diff --git a/.github/workflows/fw-test-emu.yml b/.github/workflows/fw-test-emu.yml index b600ba6231..6ef6609823 100644 --- a/.github/workflows/fw-test-emu.yml +++ b/.github/workflows/fw-test-emu.yml @@ -67,6 +67,10 @@ jobs: exit 1 fi + if [[ ${{ inputs.extra-features }} == *"hw-1.0"* ]]; then + export FIPS_TEST_HW_EXP_VERSION=1_0_0 + fi + # Workaround https://github.com/nextest-rs/nextest/issues/267 export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib diff --git a/hw-model/Cargo.toml b/hw-model/Cargo.toml index 2a0f2df48d..51709c5dc7 100644 --- a/hw-model/Cargo.toml +++ b/hw-model/Cargo.toml @@ -13,6 +13,7 @@ verilator = ["dep:caliptra-verilated"] fpga_realtime = ["dep:uio"] itrng = ["caliptra-verilated?/itrng"] coverage = ["dep:caliptra-coverage"] +"hw-1.0" = ["caliptra-emu-periph/hw-1.0"] [dependencies] bitfield.workspace = true diff --git a/hw-model/src/model_fpga_realtime.rs b/hw-model/src/model_fpga_realtime.rs index a2441d7175..f4155d38b0 100644 --- a/hw-model/src/model_fpga_realtime.rs +++ b/hw-model/src/model_fpga_realtime.rs @@ -23,7 +23,8 @@ use crate::{HwModel, SecurityState, TrngMode}; #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum OpenOcdError { Closed, - NotAccessible, + CaliptraNotAccessible, + VeerNotAccessible, WrongVersion, } @@ -526,17 +527,19 @@ impl ModelFpgaRealtime { println!("openocd log returned EOF. Log: {output}"); return Err(OpenOcdError::Closed); } - if output.contains("Debug Module did not become active") { - return Err(OpenOcdError::NotAccessible); - } - if output.contains("Listening on port 4444 for telnet connections") { + if output.contains("OpenOCD setup finished") { break; } } if !output.contains("Open On-Chip Debugger 0.12.0") { return Err(OpenOcdError::WrongVersion); } - + if output.contains("Caliptra not accessible") { + return Err(OpenOcdError::CaliptraNotAccessible); + } + if output.contains("Core not accessible") { + return Err(OpenOcdError::VeerNotAccessible); + } self.openocd = Some(openocd); Ok(()) } diff --git a/hw/fpga/openocd_caliptra.txt b/hw/fpga/openocd_caliptra.txt index 819d78308d..e5d3c5b2c5 100644 --- a/hw/fpga/openocd_caliptra.txt +++ b/hw/fpga/openocd_caliptra.txt @@ -35,4 +35,24 @@ $_TARGETNAME_0 riscv expose_csrs 1984,1986,1992,1993,1994,1995,2032,2041,2047,40 gdb_report_data_abort enable init -halt + +# Check if we can read/write CPTRA_DBG_MANUF_SERVICE_REG to see if Caliptra JTAG registers are accessible +set manuf [riscv dmi_read 0x60] +riscv dmi_write 0x60 [expr {0xFFFFFFFF - $manuf}] +set manuf_inv [riscv dmi_read 0x60] +# Restore original value +riscv dmi_write 0x60 [format %08X $manuf] +if { $manuf == $manuf_inv } { + puts stderr "Caliptra not accessible" +} else { + puts stderr "Caliptra accessible" +} + +set dmstatus [riscv dmi_read 0x11] +if {0x0 == $dmstatus} { + puts stderr "Core not accessible" +} else { + puts stderr "Core accessible" + halt +} +puts stderr "OpenOCD setup finished" diff --git a/hw/latest/registers/src/csrng.rs b/hw/latest/registers/src/csrng.rs index 7ea370f44e..ae31d9f806 100644 --- a/hw/latest/registers/src/csrng.rs +++ b/hw/latest/registers/src/csrng.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/doe.rs b/hw/latest/registers/src/doe.rs index 04f134cba6..39362b83bc 100644 --- a/hw/latest/registers/src/doe.rs +++ b/hw/latest/registers/src/doe.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/dv.rs b/hw/latest/registers/src/dv.rs index ed71c9263c..e451ec0136 100644 --- a/hw/latest/registers/src/dv.rs +++ b/hw/latest/registers/src/dv.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/ecc.rs b/hw/latest/registers/src/ecc.rs index 0a796b0bf3..45f8adcf67 100644 --- a/hw/latest/registers/src/ecc.rs +++ b/hw/latest/registers/src/ecc.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/el2_pic_ctrl.rs b/hw/latest/registers/src/el2_pic_ctrl.rs index 85532ef83b..ee532e3300 100644 --- a/hw/latest/registers/src/el2_pic_ctrl.rs +++ b/hw/latest/registers/src/el2_pic_ctrl.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/entropy_src.rs b/hw/latest/registers/src/entropy_src.rs index db5a5a4cab..e3aedad61c 100644 --- a/hw/latest/registers/src/entropy_src.rs +++ b/hw/latest/registers/src/entropy_src.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/hmac.rs b/hw/latest/registers/src/hmac.rs index 1c779fab63..e5dfc63727 100644 --- a/hw/latest/registers/src/hmac.rs +++ b/hw/latest/registers/src/hmac.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/kv.rs b/hw/latest/registers/src/kv.rs index 01023539f1..5a7925aaa3 100644 --- a/hw/latest/registers/src/kv.rs +++ b/hw/latest/registers/src/kv.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/lib.rs b/hw/latest/registers/src/lib.rs index ad85e80b2f..efb38bb544 100644 --- a/hw/latest/registers/src/lib.rs +++ b/hw/latest/registers/src/lib.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![no_std] #![allow(clippy::erasing_op)] @@ -141,7 +141,7 @@ pub mod regs { pub fn hmac_block_dest_valid(&self) -> bool { ((self.0 >> 7) & 1) != 0 } - /// SHA BLOCK is a valid destination + /// Reserved field. No SHA key vault interface #[inline(always)] pub fn sha_block_dest_valid(&self) -> bool { ((self.0 >> 8) & 1) != 0 @@ -203,7 +203,7 @@ pub mod regs { pub fn hmac_block_dest_valid(self, val: bool) -> Self { Self((self.0 & !(1 << 7)) | (u32::from(val) << 7)) } - /// SHA BLOCK is a valid destination + /// Reserved field. No SHA key vault interface #[inline(always)] pub fn sha_block_dest_valid(self, val: bool) -> Self { Self((self.0 & !(1 << 8)) | (u32::from(val) << 8)) diff --git a/hw/latest/registers/src/mbox.rs b/hw/latest/registers/src/mbox.rs index ef3f048d21..ddc1291568 100644 --- a/hw/latest/registers/src/mbox.rs +++ b/hw/latest/registers/src/mbox.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/pv.rs b/hw/latest/registers/src/pv.rs index 92ad9e614b..7583751aaf 100644 --- a/hw/latest/registers/src/pv.rs +++ b/hw/latest/registers/src/pv.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/sha256.rs b/hw/latest/registers/src/sha256.rs index ef41f84c38..a809ab725b 100644 --- a/hw/latest/registers/src/sha256.rs +++ b/hw/latest/registers/src/sha256.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/sha512.rs b/hw/latest/registers/src/sha512.rs index b9a155952e..e2d188f94e 100644 --- a/hw/latest/registers/src/sha512.rs +++ b/hw/latest/registers/src/sha512.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/sha512_acc.rs b/hw/latest/registers/src/sha512_acc.rs index 82fc52b03f..56e2e6d685 100644 --- a/hw/latest/registers/src/sha512_acc.rs +++ b/hw/latest/registers/src/sha512_acc.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/soc_ifc.rs b/hw/latest/registers/src/soc_ifc.rs index dce856ba21..46e982d0de 100644 --- a/hw/latest/registers/src/soc_ifc.rs +++ b/hw/latest/registers/src/soc_ifc.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] @@ -689,6 +689,8 @@ impl RegisterBlock { } } /// SOC provided count in cycles for WDT1 timeout. + /// [br]Caliptra Access: RW + /// [br]SOC Access: RW /// /// Read value: [`u32`]; Write value: [`u32`] #[inline(always)] @@ -703,6 +705,8 @@ impl RegisterBlock { } } /// Adaptive threshold values for entropy source health tests. + /// [br]Caliptra Access: RW + /// [br]SOC Access: RW /// /// Read value: [`soc_ifc::regs::CptraItrngEntropyConfig0ReadVal`]; Write value: [`soc_ifc::regs::CptraItrngEntropyConfig0WriteVal`] #[inline(always)] @@ -717,6 +721,8 @@ impl RegisterBlock { } } /// Repetition count value for entropy source health tests. + /// [br]Caliptra Access: RW + /// [br]SOC Access: RW /// /// Read value: [`soc_ifc::regs::CptraItrngEntropyConfig1ReadVal`]; Write value: [`soc_ifc::regs::CptraItrngEntropyConfig1WriteVal`] #[inline(always)] @@ -731,6 +737,8 @@ impl RegisterBlock { } } /// Set of reserved registers for survivability + /// [br]Caliptra Access: RW + /// [br]SOC Access: RW /// /// Read value: [`u32`]; Write value: [`u32`] #[inline(always)] @@ -1016,7 +1024,7 @@ impl RegisterBlock { ) } } - /// Control register to set the number of cycles for which FW update reset must be asserted. Default is 5. Max value is 255 (8 bit). + /// Control register to set the number of cycles for which FW update reset must be asserted. Minimum value is 5. Max value is 255 (8 bit). /// [br]Caliptra Access: RW /// [br]SOC Access: RO /// @@ -2197,6 +2205,11 @@ pub mod regs { pub fn uart_en(&self) -> bool { ((self.0 >> 3) & 1) != 0 } + /// + #[inline(always)] + pub fn lms_acc_en(&self) -> bool { + ((self.0 >> 4) & 1) != 0 + } } impl From for CptraHwConfigReadVal { #[inline(always)] @@ -2228,6 +2241,11 @@ pub mod regs { pub fn nmi_pin(&self) -> bool { ((self.0 >> 2) & 1) != 0 } + /// + #[inline(always)] + pub fn crypto_err(&self) -> bool { + ((self.0 >> 3) & 1) != 0 + } /// Construct a WriteVal that can be used to modify the contents of this register value. #[inline(always)] pub fn modify(self) -> CptraHwErrorFatalWriteVal { @@ -2264,6 +2282,11 @@ pub mod regs { pub fn nmi_pin(self, val: bool) -> Self { Self((self.0 & !(1 << 2)) | (u32::from(val) << 2)) } + /// + #[inline(always)] + pub fn crypto_err(self, val: bool) -> Self { + Self((self.0 & !(1 << 3)) | (u32::from(val) << 3)) + } } impl From for CptraHwErrorFatalWriteVal { #[inline(always)] @@ -2347,7 +2370,10 @@ pub mod regs { #[derive(Clone, Copy)] pub struct CptraHwRevIdReadVal(u32); impl CptraHwRevIdReadVal { - /// + /// Caliptra official release version. Bit field encoding is: + /// [br][lb]15:8[rb] Patch version + /// [br][lb] 7:4[rb] Minor version + /// [br][lb] 3:0[rb] Major version #[inline(always)] pub fn cptra_generation(&self) -> u32 { (self.0 >> 0) & 0xffff @@ -3588,6 +3614,11 @@ pub mod regs { pub fn mask_nmi_pin(&self) -> bool { ((self.0 >> 2) & 1) != 0 } + /// + #[inline(always)] + pub fn mask_crypto_err(&self) -> bool { + ((self.0 >> 3) & 1) != 0 + } /// Construct a WriteVal that can be used to modify the contents of this register value. #[inline(always)] pub fn modify(self) -> InternalHwErrorFatalMaskWriteVal { diff --git a/hw/latest/registers/src/soc_ifc_trng.rs b/hw/latest/registers/src/soc_ifc_trng.rs index ad93cf616b..8a23c36a9e 100644 --- a/hw/latest/registers/src/soc_ifc_trng.rs +++ b/hw/latest/registers/src/soc_ifc_trng.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/spi_host.rs b/hw/latest/registers/src/spi_host.rs index 2d9df73ca9..7475282fac 100644 --- a/hw/latest/registers/src/spi_host.rs +++ b/hw/latest/registers/src/spi_host.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/registers/src/uart.rs b/hw/latest/registers/src/uart.rs index c18ab2b0f0..f28c83a66f 100644 --- a/hw/latest/registers/src/uart.rs +++ b/hw/latest/registers/src/uart.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license. // -// generated by caliptra_registers_generator with caliptra-rtl repo at e928359b071f3c354a194a31c2b3bdac8adb20d0 +// generated by caliptra_registers_generator with caliptra-rtl repo at 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 // #![allow(clippy::erasing_op)] #![allow(clippy::identity_op)] diff --git a/hw/latest/rtl b/hw/latest/rtl index e928359b07..5f85fb4bc9 160000 --- a/hw/latest/rtl +++ b/hw/latest/rtl @@ -1 +1 @@ -Subproject commit e928359b071f3c354a194a31c2b3bdac8adb20d0 +Subproject commit 5f85fb4bc95b753a2f7d042db7dc2644ca1e8c49 diff --git a/rom/dev/Cargo.toml b/rom/dev/Cargo.toml index 2bdbc7704f..822075319e 100644 --- a/rom/dev/Cargo.toml +++ b/rom/dev/Cargo.toml @@ -61,7 +61,7 @@ no-fmc = [] fake-rom = [] no-cfi = ["caliptra-image-verify/no-cfi", "caliptra-drivers/no-cfi"] slow_tests = [] -"hw-1.0" = ["caliptra-builder/hw-1.0", "caliptra-drivers/hw-1.0", "caliptra-registers/hw-1.0"] +"hw-1.0" = ["caliptra-builder/hw-1.0", "caliptra-drivers/hw-1.0", "caliptra-registers/hw-1.0", "caliptra-hw-model/hw-1.0"] [[bin]] name = "asm_tests" diff --git a/rom/dev/tests/rom_integration_tests/test_version.rs b/rom/dev/tests/rom_integration_tests/test_version.rs index ea2be234ec..662a616d53 100755 --- a/rom/dev/tests/rom_integration_tests/test_version.rs +++ b/rom/dev/tests/rom_integration_tests/test_version.rs @@ -12,7 +12,7 @@ use crate::helpers; // TODO: Find a better way to get this or make it a don't-care for this test // This is not going to work when we start testing against multiple hw revs -const HW_REV_ID: u32 = 0x1; +const HW_REV_ID: u32 = if cfg!(feature = "hw-1.0") { 0x1 } else { 0x11 }; #[test] fn test_version() { diff --git a/runtime/tests/runtime_integration_tests/test_fips.rs b/runtime/tests/runtime_integration_tests/test_fips.rs index e674b32a86..a8756aa8bc 100644 --- a/runtime/tests/runtime_integration_tests/test_fips.rs +++ b/runtime/tests/runtime_integration_tests/test_fips.rs @@ -9,6 +9,8 @@ use caliptra_hw_model::HwModel; use caliptra_runtime::FipsVersionCmd; use zerocopy::{AsBytes, FromBytes}; +const HW_REV_ID: u32 = if cfg!(feature = "hw-1.0") { 0x1 } else { 0x11 }; + #[test] fn test_fips_version() { let mut model = run_rt_test( @@ -53,7 +55,11 @@ fn test_fips_version() { ((version::get_fmc_version() as u32) << 16) | (version::get_rom_version() as u32); assert_eq!( fips_version.fips_rev, - [0x01, fw_version_0_expected, version::get_runtime_version()] + [ + HW_REV_ID, + fw_version_0_expected, + version::get_runtime_version() + ] ); let name = &fips_version.name[..]; assert_eq!(name, FipsVersionCmd::NAME.as_bytes()); diff --git a/sw-emulator/lib/periph/Cargo.toml b/sw-emulator/lib/periph/Cargo.toml index 1d8045ec9b..c74f6814ca 100644 --- a/sw-emulator/lib/periph/Cargo.toml +++ b/sw-emulator/lib/periph/Cargo.toml @@ -22,4 +22,7 @@ lazy_static.workspace = true sha3.workspace = true smlang.workspace = true tock-registers.workspace = true -zerocopy.workspace = true \ No newline at end of file +zerocopy.workspace = true + +[features] +"hw-1.0" = [] diff --git a/sw-emulator/lib/periph/src/soc_reg.rs b/sw-emulator/lib/periph/src/soc_reg.rs index 49a4361224..73656051f1 100644 --- a/sw-emulator/lib/periph/src/soc_reg.rs +++ b/sw-emulator/lib/periph/src/soc_reg.rs @@ -812,7 +812,11 @@ impl SocRegistersImpl { cptra_clk_gating_en: ReadOnlyRegister::new(0), cptra_generic_input_wires: Default::default(), cptra_generic_output_wires: Default::default(), - cptra_hw_rev_id: ReadOnlyRegister::new(1), + cptra_hw_rev_id: ReadOnlyRegister::new(if cfg!(feature = "hw-1.0") { + 0x1 + } else { + 0x11 + }), cptra_fw_rev_id: Default::default(), cptra_hw_config: 0, fuse_uds_seed: words_from_bytes_be(&Self::UDS), diff --git a/test/Cargo.toml b/test/Cargo.toml index 3c21d59090..1d0f3738ff 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -36,4 +36,4 @@ itrng = ["caliptra-hw-model/itrng"] verilator = ["caliptra-hw-model/verilator"] fips_self_test = ["caliptra-runtime/fips_self_test"] test_env_immutable_rom = [] -"hw-1.0" = ["caliptra-builder/hw-1.0", "caliptra-drivers/hw-1.0"] +"hw-1.0" = ["caliptra-builder/hw-1.0", "caliptra-drivers/hw-1.0", "caliptra-hw-model/hw-1.0"] diff --git a/test/tests/fips_test_suite/common.rs b/test/tests/fips_test_suite/common.rs index ab0e886caf..da02598e59 100755 --- a/test/tests/fips_test_suite/common.rs +++ b/test/tests/fips_test_suite/common.rs @@ -30,7 +30,7 @@ pub struct HwExpVals { const HW_EXP_1_0_0: HwExpVals = HwExpVals { hw_revision: 0x1 }; -const HW_EXP_CURRENT: HwExpVals = HwExpVals { ..HW_EXP_1_0_0 }; +const HW_EXP_CURRENT: HwExpVals = HwExpVals { hw_revision: 0x11 }; // === ROM === pub struct RomExpVals { diff --git a/test/tests/fips_test_suite/jtag_locked.rs b/test/tests/fips_test_suite/jtag_locked.rs index 5d0ef00c58..8566ef2ebf 100644 --- a/test/tests/fips_test_suite/jtag_locked.rs +++ b/test/tests/fips_test_suite/jtag_locked.rs @@ -1,6 +1,7 @@ // Licensed under the Apache-2.0 license use crate::common::fips_test_init_to_rom; +use caliptra_hw_model::OpenOcdError; use caliptra_hw_model::{BootParams, InitParams, SecurityState}; use caliptra_hw_model_types::DeviceLifecycle; @@ -8,13 +9,13 @@ fn check_jtag_accessible( rom: &[u8], debug_locked: bool, device_lifecycle: DeviceLifecycle, - _expect_pass: bool, + expect_result: Result<(), OpenOcdError>, ) { let security_state = *SecurityState::default() .set_debug_locked(debug_locked) .set_device_lifecycle(device_lifecycle); - let mut _hw = fips_test_init_to_rom(Some(BootParams { + let mut hw = fips_test_init_to_rom(Some(BootParams { init_params: InitParams { rom, security_state, @@ -24,17 +25,11 @@ fn check_jtag_accessible( })); #[cfg(feature = "fpga_realtime")] - match _hw.launch_openocd() { - Ok(()) => assert!( - _expect_pass, - "Result Ok when expected to fail for debug_locked {debug_locked} {device_lifecycle:?}" - ), - Err(caliptra_hw_model::OpenOcdError::NotAccessible) => assert!( - !_expect_pass, - "Result NotAccessible when expected to pass for debug_locked {debug_locked} {device_lifecycle:?}" - ), - Err(e) => panic!("OpenOCD failed with an unexpected error: {e:?}"), - } + assert_eq!( + expect_result, + hw.launch_openocd(), + " for {device_lifecycle:?}:{debug_locked}" + ); } #[test] @@ -43,14 +38,34 @@ fn jtag_locked() { let rom = caliptra_builder::rom_for_fw_integration_tests().unwrap(); // When debug is locked JTAG is only accesisble in Manufacturing mode. - check_jtag_accessible(&rom, true, DeviceLifecycle::Unprovisioned, false); - check_jtag_accessible(&rom, true, DeviceLifecycle::Manufacturing, true); - check_jtag_accessible(&rom, true, DeviceLifecycle::Reserved2, false); - check_jtag_accessible(&rom, true, DeviceLifecycle::Production, false); + check_jtag_accessible( + &rom, + true, + DeviceLifecycle::Unprovisioned, + Err(OpenOcdError::CaliptraNotAccessible), + ); + check_jtag_accessible( + &rom, + true, + DeviceLifecycle::Manufacturing, + Err(OpenOcdError::VeerNotAccessible), + ); + check_jtag_accessible( + &rom, + true, + DeviceLifecycle::Reserved2, + Err(OpenOcdError::CaliptraNotAccessible), + ); + check_jtag_accessible( + &rom, + true, + DeviceLifecycle::Production, + Err(OpenOcdError::CaliptraNotAccessible), + ); // When debug not locked JTAG is accessible in any mode. - check_jtag_accessible(&rom, false, DeviceLifecycle::Unprovisioned, true); - check_jtag_accessible(&rom, false, DeviceLifecycle::Manufacturing, true); - check_jtag_accessible(&rom, false, DeviceLifecycle::Reserved2, true); - check_jtag_accessible(&rom, false, DeviceLifecycle::Production, true); + check_jtag_accessible(&rom, false, DeviceLifecycle::Unprovisioned, Ok(())); + check_jtag_accessible(&rom, false, DeviceLifecycle::Manufacturing, Ok(())); + check_jtag_accessible(&rom, false, DeviceLifecycle::Reserved2, Ok(())); + check_jtag_accessible(&rom, false, DeviceLifecycle::Production, Ok(())); } diff --git a/test/tests/fips_test_suite/main.rs b/test/tests/fips_test_suite/main.rs index a4dc943b17..155afa80bc 100644 --- a/test/tests/fips_test_suite/main.rs +++ b/test/tests/fips_test_suite/main.rs @@ -1,4 +1,5 @@ // Licensed under the Apache-2.0 license mod common; +#[cfg(feature = "fpga_realtime")] mod jtag_locked; mod services;