Skip to content

Commit

Permalink
CI: Update Caliptra RTL (#1608)
Browse files Browse the repository at this point in the history
* CI: Update Caliptra RTL

* CI fixes to handle hw_rev changing to 1.1

Set FIPS environment variables in CI when targetting 1.0
Update FIPS HW_EXP_CURRENT for 1.1
Change sw-emulator hw-rev based on hw-1.0 feature

* Update FPGA JTAG test for new HW behavior

Only Caliptra registers accessible in Manufacturing mode with debug
locked.

---------

Co-authored-by: GitHub CI <username@users.noreply.github.com>
Co-authored-by: Luke Mahowald <Luke.Mahowald@amd.com>
  • Loading branch information
3 people authored Jul 10, 2024
1 parent 418f56f commit 03ec988
Show file tree
Hide file tree
Showing 33 changed files with 150 additions and 58 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/fpga.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/fw-test-emu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions hw-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions hw-model/src/model_fpga_realtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use crate::{HwModel, SecurityState, TrngMode};
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum OpenOcdError {
Closed,
NotAccessible,
CaliptraNotAccessible,
VeerNotAccessible,
WrongVersion,
}

Expand Down Expand Up @@ -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(())
}
Expand Down
22 changes: 21 additions & 1 deletion hw/fpga/openocd_caliptra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion hw/latest/registers/src/csrng.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/doe.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/dv.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/ecc.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/el2_pic_ctrl.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/entropy_src.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/hmac.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/kv.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions hw/latest/registers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/mbox.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/pv.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/sha256.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/sha512.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/sha512_acc.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
37 changes: 34 additions & 3 deletions hw/latest/registers/src/soc_ifc.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -689,6 +689,8 @@ impl<TMmio: ureg::Mmio> RegisterBlock<TMmio> {
}
}
/// SOC provided count in cycles for WDT1 timeout.
/// [br]Caliptra Access: RW
/// [br]SOC Access: RW
///
/// Read value: [`u32`]; Write value: [`u32`]
#[inline(always)]
Expand All @@ -703,6 +705,8 @@ impl<TMmio: ureg::Mmio> RegisterBlock<TMmio> {
}
}
/// 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)]
Expand All @@ -717,6 +721,8 @@ impl<TMmio: ureg::Mmio> RegisterBlock<TMmio> {
}
}
/// 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)]
Expand All @@ -731,6 +737,8 @@ impl<TMmio: ureg::Mmio> RegisterBlock<TMmio> {
}
}
/// Set of reserved registers for survivability
/// [br]Caliptra Access: RW
/// [br]SOC Access: RW
///
/// Read value: [`u32`]; Write value: [`u32`]
#[inline(always)]
Expand Down Expand Up @@ -1016,7 +1024,7 @@ impl<TMmio: ureg::Mmio> RegisterBlock<TMmio> {
)
}
}
/// 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
///
Expand Down Expand Up @@ -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<u32> for CptraHwConfigReadVal {
#[inline(always)]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<u32> for CptraHwErrorFatalWriteVal {
#[inline(always)]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/soc_ifc_trng.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/spi_host.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/registers/src/uart.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion hw/latest/rtl
Submodule rtl updated 271 files
2 changes: 1 addition & 1 deletion rom/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion rom/dev/tests/rom_integration_tests/test_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading

0 comments on commit 03ec988

Please sign in to comment.