From 1c7e3dd8aa694a054205a464dfd7eb3c137756b7 Mon Sep 17 00:00:00 2001 From: Carl Lundin Date: Thu, 17 Oct 2024 11:10:43 -0700 Subject: [PATCH] Refactor `memory_layout` and `persistent_data` * Reserve a portion of DCCM for future changes to PersistentData. * Remove most hard coded addresses in memory layout. * Reserved 19KiB in `PersistentData`. * Left 8K in the Data section. Currently less than 4KiB is being used. This resolves https://github.com/chipsalliance/caliptra-sw/issues/1662. --- common/src/lib.rs | 2 +- cpu/gen/src/lib.rs | 8 - drivers/src/hand_off.rs | 5 +- drivers/src/memory_layout.rs | 119 ++----------- drivers/src/persistent.rs | 168 ++++++++++++++---- rom/dev/src/flow/cold_reset/idev_id.rs | 11 -- rom/dev/src/flow/fake.rs | 5 +- .../test_fmcalias_derivation.rs | 6 - 8 files changed, 149 insertions(+), 175 deletions(-) diff --git a/common/src/lib.rs b/common/src/lib.rs index ba4e884d24..8ae0376696 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -42,5 +42,5 @@ pub const FMC_SIZE: u32 = 20 * 1024; pub const RUNTIME_ORG: u32 = FMC_ORG + FMC_SIZE; pub const RUNTIME_SIZE: u32 = 97 * 1024; -pub use memory_layout::{DATA_ORG, FHT_ORG, FHT_SIZE, MAN1_ORG}; +pub use memory_layout::{DATA_ORG, PERSISTENT_DATA_ORG}; pub use wdt::{restart_wdt, start_wdt, stop_wdt, WdtTimeout}; diff --git a/cpu/gen/src/lib.rs b/cpu/gen/src/lib.rs index fe48c83286..0123914b76 100644 --- a/cpu/gen/src/lib.rs +++ b/cpu/gen/src/lib.rs @@ -9,16 +9,9 @@ pub fn gen_memory_x(iccm_org: u32, iccm_size: u32) -> String { STACK_ORG = 0x{STACK_ORG:08X}; ESTACK_ORG = 0x{ESTACK_ORG:08X}; NSTACK_ORG = 0x{NSTACK_ORG:08X}; - LDEVID_TBS_ORG = 0x{LDEVID_TBS_ORG:08X};; - FMCALIAS_TBS_ORG = 0x{FMCALIAS_TBS_ORG:08X};; - RTALIAS_TBS_ORG = 0x{RTALIAS_TBS_ORG:08X}; CFI_STATE_ORG = 0x{CFI_STATE_ORG:08X}; - LDEVID_TBS_SIZE = 0x{LDEVID_TBS_SIZE:08X}; - FMCALIAS_TBS_SIZE = 0x{FMCALIAS_TBS_SIZE:08X}; - RTALIAS_TBS_SIZE = 0x{RTALIAS_TBS_SIZE:08X}; - ICCM_SIZE = 0x{iccm_size:08X}; DCCM_SIZE = 0x{DCCM_SIZE:08X}; DATA_SIZE = 0x{DATA_SIZE:08X}; @@ -30,7 +23,6 @@ pub fn gen_memory_x(iccm_org: u32, iccm_size: u32) -> String { MEMORY {{ ICCM (rx) : ORIGIN = ICCM_ORG, LENGTH = ICCM_SIZE - RTALIAS_TBS (rw) : ORIGIN = RTALIAS_TBS_ORG, LENGTH = RTALIAS_TBS_SIZE DATA (rw) : ORIGIN = DATA_ORG, LENGTH = DATA_SIZE STACK (rw) : ORIGIN = STACK_ORG, LENGTH = STACK_SIZE ESTACK (rw) : ORIGIN = ESTACK_ORG, LENGTH = ESTACK_SIZE diff --git a/drivers/src/hand_off.rs b/drivers/src/hand_off.rs index a1162353f1..c27ddf4195 100644 --- a/drivers/src/hand_off.rs +++ b/drivers/src/hand_off.rs @@ -3,8 +3,8 @@ use crate::bounded_address::RomAddr; use crate::soc_ifc; use crate::{ - memory_layout, ColdResetEntry4, ColdResetEntry48, Ecc384PubKey, Ecc384Signature, KeyId, - ResetReason, WarmResetEntry4, WarmResetEntry48, + ColdResetEntry4, ColdResetEntry48, Ecc384PubKey, Ecc384Signature, KeyId, ResetReason, + WarmResetEntry4, WarmResetEntry48, }; use bitfield::{bitfield_bitrange, bitfield_fields}; use caliptra_error::CaliptraError; @@ -177,7 +177,6 @@ impl From for HandOffDataHandle { /// location in DCCM. It is initially populated by ROM and modified by FMC as a way /// to pass parameters and configuration information from one firmware layer to the next. const _: () = assert!(size_of::() == 2048); -const _: () = assert!(size_of::() <= memory_layout::FHT_SIZE as usize); #[repr(C)] #[derive(Clone, Debug, AsBytes, FromBytes, Zeroize)] pub struct FirmwareHandoffTable { diff --git a/drivers/src/memory_layout.rs b/drivers/src/memory_layout.rs index a4314bc336..d318b98540 100644 --- a/drivers/src/memory_layout.rs +++ b/drivers/src/memory_layout.rs @@ -12,12 +12,6 @@ Abstract: --*/ -#[cfg(test)] -use crate::FirmwareHandoffTable; - -#[cfg(test)] -use caliptra_image_types::ImageManifest; - // // Memory Addresses // @@ -28,20 +22,9 @@ pub const DCCM_ORG: u32 = 0x50000000; pub const ROM_DATA_ORG: u32 = 0x50000000; pub const CFI_STATE_ORG: u32 = 0x500003E4; // size = 6 words pub const BOOT_STATUS_ORG: u32 = 0x500003FC; -pub const MAN1_ORG: u32 = 0x50000400; -pub const MAN2_ORG: u32 = 0x50001C00; -pub const FHT_ORG: u32 = 0x50003400; -pub const LDEVID_TBS_ORG: u32 = 0x50003C00; -pub const FMCALIAS_TBS_ORG: u32 = 0x50004000; -pub const RTALIAS_TBS_ORG: u32 = 0x50004400; -pub const PCR_LOG_ORG: u32 = 0x50004800; -pub const MEASUREMENT_LOG_ORG: u32 = 0x50004C00; -pub const FUSE_LOG_ORG: u32 = 0x50005000; -pub const DPE_ORG: u32 = 0x50005400; -pub const PCR_RESET_COUNTER_ORG: u32 = 0x50006800; -pub const AUTH_MAN_IMAGE_METADATA_LIST_ORG: u32 = 0x50006C00; -pub const IDEVID_CSR_ORG: u32 = 0x50008800; -pub const DATA_ORG: u32 = 0x50008C00; +pub const PERSISTENT_DATA_ORG: u32 = 0x50000400; + +pub const DATA_ORG: u32 = 0x5000D800; pub const STACK_ORG: u32 = 0x5000f800; pub const ROM_STACK_ORG: u32 = 0x5001C000; @@ -55,26 +38,22 @@ pub const ROM_NSTACK_ORG: u32 = 0x5001FC00; // // Memory Sizes In Bytes // + +// Reserves a large chunk of DCCM for the PersistentData struct. +// +// The size was calculated by leaving a portion of the Data section +// reserved for future use and then allocating the rest of the DCCM. +// +// The `DATA_SIZE` variable reflects the leftover space. +pub const PERSISTENT_DATA_SIZE: u32 = 53 * 1024; + pub const ROM_RELAXATION_PADDING: u32 = 4 * 1024; pub const ROM_SIZE: u32 = 48 * 1024; pub const MBOX_SIZE: u32 = 128 * 1024; pub const ICCM_SIZE: u32 = 128 * 1024; pub const DCCM_SIZE: u32 = 128 * 1024; pub const ROM_DATA_SIZE: u32 = 996; -pub const MAN1_SIZE: u32 = 6 * 1024; -pub const MAN2_SIZE: u32 = 6 * 1024; -pub const FHT_SIZE: u32 = 2 * 1024; -pub const LDEVID_TBS_SIZE: u32 = 1024; -pub const FMCALIAS_TBS_SIZE: u32 = 1024; -pub const RTALIAS_TBS_SIZE: u32 = 1024; -pub const PCR_LOG_SIZE: u32 = 1024; -pub const MEASUREMENT_LOG_SIZE: u32 = 1024; -pub const FUSE_LOG_SIZE: u32 = 1024; -pub const DPE_SIZE: u32 = 5 * 1024; -pub const PCR_RESET_COUNTER_SIZE: u32 = 1024; -pub const AUTH_MAN_IMAGE_METADATA_MAX_SIZE: u32 = 7 * 1024; -pub const IDEVID_CSR_SIZE: u32 = 1024; -pub const DATA_SIZE: u32 = 27 * 1024; +pub const DATA_SIZE: u32 = 8 * 1024; pub const STACK_SIZE: u32 = 64 * 1024; pub const ROM_STACK_SIZE: u32 = 14 * 1024; pub const ESTACK_SIZE: u32 = 1024; @@ -89,76 +68,8 @@ pub const ICCM_RANGE: core::ops::Range = core::ops::Range { #[test] #[allow(clippy::assertions_on_constants)] -fn mem_layout_test_manifest() { - assert!(MAN1_SIZE as usize >= core::mem::size_of::()); - assert!(MAN2_SIZE as usize >= core::mem::size_of::()); - assert_eq!(MAN1_SIZE, MAN2_SIZE); - assert_eq!((MAN2_ORG - MAN1_ORG), MAN1_SIZE); - assert_eq!((FHT_ORG - MAN2_ORG), MAN2_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_fht() { - assert!(FHT_SIZE as usize >= core::mem::size_of::()); - assert_eq!((LDEVID_TBS_ORG - FHT_ORG), FHT_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_ldevid() { - assert_eq!((FMCALIAS_TBS_ORG - LDEVID_TBS_ORG), LDEVID_TBS_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_fmcalias() { - assert_eq!((RTALIAS_TBS_ORG - FMCALIAS_TBS_ORG), FMCALIAS_TBS_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_rtalias() { - assert_eq!((PCR_LOG_ORG - RTALIAS_TBS_ORG), RTALIAS_TBS_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_pcr_log() { - assert_eq!((MEASUREMENT_LOG_ORG - PCR_LOG_ORG), PCR_LOG_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_measurement_log() { - assert_eq!((FUSE_LOG_ORG - MEASUREMENT_LOG_ORG), MEASUREMENT_LOG_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_fuselog() { - assert_eq!((DPE_ORG - FUSE_LOG_ORG), FUSE_LOG_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_dpe() { - assert_eq!((PCR_RESET_COUNTER_ORG - DPE_ORG), DPE_SIZE); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_pcr_reset_counter() { - assert_eq!( - (AUTH_MAN_IMAGE_METADATA_LIST_ORG - PCR_RESET_COUNTER_ORG), - PCR_RESET_COUNTER_SIZE - ); -} - -#[test] -#[allow(clippy::assertions_on_constants)] -fn mem_layout_test_idevid_csr() { - assert_eq!((DATA_ORG - IDEVID_CSR_ORG), IDEVID_CSR_SIZE); +fn mem_layout_test_persistent_data() { + assert_eq!((DATA_ORG - PERSISTENT_DATA_ORG), PERSISTENT_DATA_SIZE); } #[test] diff --git a/drivers/src/persistent.rs b/drivers/src/persistent.rs index e0bb49de67..5af24ee86f 100644 --- a/drivers/src/persistent.rs +++ b/drivers/src/persistent.rs @@ -25,6 +25,21 @@ use crate::{ use crate::pcr_reset::PcrResetCounter; pub const MAX_CSR_SIZE: usize = 512; +pub const MAN1_SIZE: u32 = 6 * 1024; +pub const MAN2_SIZE: u32 = 6 * 1024; +pub const FHT_SIZE: u32 = 2 * 1024; +pub const LDEVID_TBS_SIZE: u32 = 1024; +pub const FMCALIAS_TBS_SIZE: u32 = 1024; +pub const RTALIAS_TBS_SIZE: u32 = 1024; +pub const PCR_LOG_SIZE: u32 = 1024; +pub const MEASUREMENT_LOG_SIZE: u32 = 1024; +pub const FUSE_LOG_SIZE: u32 = 1024; +pub const DPE_SIZE: u32 = 5 * 1024; +pub const PCR_RESET_COUNTER_SIZE: u32 = 1024; +pub const AUTH_MAN_IMAGE_METADATA_MAX_SIZE: u32 = 7 * 1024; +pub const IDEVID_CSR_SIZE: u32 = 1024; +pub const RESERVED_MEMORY_SIZE: u32 = 19 * 1024; + pub const PCR_LOG_MAX_COUNT: usize = 17; pub const FUSE_LOG_MAX_COUNT: usize = 62; pub const MEASUREMENT_MAX_COUNT: usize = 8; @@ -36,7 +51,7 @@ const DPE_DCCM_STORAGE: usize = size_of::() + size_of::(); #[cfg(feature = "runtime")] -const _: () = assert!(DPE_DCCM_STORAGE < memory_layout::DPE_SIZE as usize); +const _: () = assert!(DPE_DCCM_STORAGE < DPE_SIZE as usize); pub type PcrLogArray = [PcrLogEntry; PCR_LOG_MAX_COUNT]; pub type FuseLogArray = [FuseLogEntry; FUSE_LOG_MAX_COUNT]; @@ -45,6 +60,8 @@ pub type StashMeasurementArray = [MeasurementLogEntry; MEASUREMENT_MAX_COUNT]; pub type AuthManifestImageMetadataList = [AuthManifestImageMetadata; AUTH_MANIFEST_IMAGE_METADATA_MAX_COUNT]; +const _: () = assert!(MAX_CSR_SIZE < IDEVID_CSR_SIZE as usize); + #[derive(Clone, FromBytes, AsBytes, Zeroize)] #[repr(C)] pub struct IdevIdCsr { @@ -102,35 +119,47 @@ impl IdevIdCsr { } } -const _: () = assert!(size_of::() < memory_layout::IDEVID_CSR_SIZE as usize); +const _: () = assert!(size_of::() == memory_layout::PERSISTENT_DATA_SIZE as usize); +const _: () = assert!(size_of::() <= MAN1_SIZE as usize); +const _: () = assert!(size_of::() <= MAN2_SIZE as usize); +const _: () = assert!(size_of::() <= FHT_SIZE as usize); +const _: () = assert!(size_of::() <= PCR_LOG_SIZE as usize); +const _: () = assert!(size_of::() <= MEASUREMENT_LOG_SIZE as usize); +const _: () = assert!(size_of::() <= FUSE_LOG_SIZE as usize); +#[cfg(feature = "runtime")] +const _: () = assert!(size_of::() <= PCR_RESET_COUNTER_SIZE as usize); +#[cfg(feature = "runtime")] +const _: () = assert!( + size_of::() <= AUTH_MAN_IMAGE_METADATA_MAX_SIZE as usize +); +const _: () = assert!(size_of::() <= IDEVID_CSR_SIZE as usize); #[derive(FromBytes, AsBytes, Zeroize)] #[repr(C)] pub struct PersistentData { pub manifest1: ImageManifest, - reserved0: [u8; memory_layout::MAN1_SIZE as usize - size_of::()], + reserved0: [u8; MAN1_SIZE as usize - size_of::()], pub manifest2: ImageManifest, - reserved1: [u8; memory_layout::MAN2_SIZE as usize - size_of::()], + reserved1: [u8; MAN2_SIZE as usize - size_of::()], pub fht: FirmwareHandoffTable, - reserved2: [u8; memory_layout::FHT_SIZE as usize - size_of::()], + reserved2: [u8; FHT_SIZE as usize - size_of::()], // TODO: Do we want to hide these fields from the FMC/runtime and force them // to go through the FHT addresses? - pub ldevid_tbs: [u8; memory_layout::LDEVID_TBS_SIZE as usize], - pub fmcalias_tbs: [u8; memory_layout::FMCALIAS_TBS_SIZE as usize], - pub rtalias_tbs: [u8; memory_layout::RTALIAS_TBS_SIZE as usize], + pub ldevid_tbs: [u8; LDEVID_TBS_SIZE as usize], + pub fmcalias_tbs: [u8; FMCALIAS_TBS_SIZE as usize], + pub rtalias_tbs: [u8; RTALIAS_TBS_SIZE as usize], pub pcr_log: PcrLogArray, - reserved3: [u8; memory_layout::PCR_LOG_SIZE as usize - size_of::()], + reserved3: [u8; PCR_LOG_SIZE as usize - size_of::()], pub measurement_log: StashMeasurementArray, - reserved4: - [u8; memory_layout::MEASUREMENT_LOG_SIZE as usize - size_of::()], + reserved4: [u8; MEASUREMENT_LOG_SIZE as usize - size_of::()], pub fuse_log: FuseLogArray, - reserved5: [u8; memory_layout::FUSE_LOG_SIZE as usize - size_of::()], + reserved5: [u8; FUSE_LOG_SIZE as usize - size_of::()], #[cfg(feature = "runtime")] pub dpe: DpeInstance, @@ -141,65 +170,128 @@ pub struct PersistentData { #[cfg(feature = "runtime")] pub attestation_disabled: U8Bool, #[cfg(feature = "runtime")] - reserved6: [u8; memory_layout::DPE_SIZE as usize - DPE_DCCM_STORAGE], + reserved6: [u8; DPE_SIZE as usize - DPE_DCCM_STORAGE], #[cfg(not(feature = "runtime"))] - dpe: [u8; memory_layout::DPE_SIZE as usize], + dpe: [u8; DPE_SIZE as usize], #[cfg(feature = "runtime")] pub pcr_reset: PcrResetCounter, #[cfg(feature = "runtime")] - reserved7: [u8; memory_layout::PCR_RESET_COUNTER_SIZE as usize - size_of::()], + reserved7: [u8; PCR_RESET_COUNTER_SIZE as usize - size_of::()], #[cfg(not(feature = "runtime"))] - pcr_reset: [u8; memory_layout::PCR_RESET_COUNTER_SIZE as usize], + pcr_reset: [u8; PCR_RESET_COUNTER_SIZE as usize], #[cfg(feature = "runtime")] pub auth_manifest_image_metadata_col: AuthManifestImageMetadataCollection, #[cfg(feature = "runtime")] - reserved9: [u8; memory_layout::AUTH_MAN_IMAGE_METADATA_MAX_SIZE as usize + reserved9: [u8; AUTH_MAN_IMAGE_METADATA_MAX_SIZE as usize - size_of::()], #[cfg(not(feature = "runtime"))] - pub auth_manifest_image_metadata_col: - [u8; memory_layout::AUTH_MAN_IMAGE_METADATA_MAX_SIZE as usize], + pub auth_manifest_image_metadata_col: [u8; AUTH_MAN_IMAGE_METADATA_MAX_SIZE as usize], pub idevid_csr: IdevIdCsr, - reserved10: [u8; memory_layout::IDEVID_CSR_SIZE as usize - size_of::()], + reserved10: [u8; IDEVID_CSR_SIZE as usize - size_of::()], + + // Reserved memory for future objects. + // New objects should always source memory from this range. + // Taking memory from this reserve does NOT break hitless updates. + pub reserved_memory: [u8; RESERVED_MEMORY_SIZE as usize], } impl PersistentData { pub fn assert_matches_layout() { - const P: *const PersistentData = memory_layout::MAN1_ORG as *const PersistentData; - use memory_layout as layout; + const P: *const PersistentData = + memory_layout::PERSISTENT_DATA_ORG as *const PersistentData; unsafe { - assert_eq!(addr_of!((*P).manifest1) as u32, layout::MAN1_ORG); - assert_eq!(addr_of!((*P).manifest2) as u32, layout::MAN2_ORG); - assert_eq!(addr_of!((*P).fht) as u32, layout::FHT_ORG); - assert_eq!(addr_of!((*P).ldevid_tbs) as u32, layout::LDEVID_TBS_ORG); - assert_eq!(addr_of!((*P).fmcalias_tbs) as u32, layout::FMCALIAS_TBS_ORG); - assert_eq!(addr_of!((*P).rtalias_tbs) as u32, layout::RTALIAS_TBS_ORG); - assert_eq!(addr_of!((*P).pcr_log) as u32, memory_layout::PCR_LOG_ORG); + let mut persistent_data_offset = 0; + assert_eq!( + addr_of!((*P).manifest1) as u32, + memory_layout::PERSISTENT_DATA_ORG + ); + persistent_data_offset += MAN1_SIZE; + assert_eq!( + addr_of!((*P).manifest2) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + + persistent_data_offset += MAN2_SIZE; + assert_eq!( + addr_of!((*P).fht) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + + persistent_data_offset += FHT_SIZE; + assert_eq!( + addr_of!((*P).ldevid_tbs) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + + persistent_data_offset += LDEVID_TBS_SIZE; + assert_eq!( + addr_of!((*P).fmcalias_tbs) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + + persistent_data_offset += FMCALIAS_TBS_SIZE; + assert_eq!( + addr_of!((*P).rtalias_tbs) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + + persistent_data_offset += RTALIAS_TBS_SIZE; + assert_eq!( + addr_of!((*P).pcr_log) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + + persistent_data_offset += PCR_LOG_SIZE; assert_eq!( addr_of!((*P).measurement_log) as u32, - memory_layout::MEASUREMENT_LOG_ORG + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset ); - assert_eq!(addr_of!((*P).fuse_log) as u32, memory_layout::FUSE_LOG_ORG); - assert_eq!(addr_of!((*P).dpe) as u32, memory_layout::DPE_ORG); + + persistent_data_offset += MEASUREMENT_LOG_SIZE; + assert_eq!( + addr_of!((*P).fuse_log) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + + persistent_data_offset += FUSE_LOG_SIZE; + assert_eq!( + addr_of!((*P).dpe) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + + persistent_data_offset += DPE_SIZE; assert_eq!( addr_of!((*P).pcr_reset) as u32, - memory_layout::PCR_RESET_COUNTER_ORG + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset ); + + persistent_data_offset += PCR_RESET_COUNTER_SIZE; assert_eq!( addr_of!((*P).auth_manifest_image_metadata_col) as u32, - memory_layout::AUTH_MAN_IMAGE_METADATA_LIST_ORG + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset ); + + persistent_data_offset += AUTH_MAN_IMAGE_METADATA_MAX_SIZE; assert_eq!( addr_of!((*P).idevid_csr) as u32, - memory_layout::IDEVID_CSR_ORG + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset ); + + persistent_data_offset += IDEVID_CSR_SIZE; + assert_eq!( + addr_of!((*P).reserved_memory) as u32, + memory_layout::PERSISTENT_DATA_ORG + persistent_data_offset + ); + assert_eq!( P.add(1) as u32, - memory_layout::IDEVID_CSR_ORG + memory_layout::IDEVID_CSR_SIZE + memory_layout::PERSISTENT_DATA_ORG + memory_layout::PERSISTENT_DATA_SIZE ); + assert_eq!(P.add(1) as u32, memory_layout::DATA_ORG); } } } @@ -228,7 +320,7 @@ impl PersistentDataAccessor { pub fn get(&self) -> &PersistentData { // WARNING: The returned lifetime elided from `self` is critical for // safety. Do not change this API without review by a Rust expert. - unsafe { ref_from_addr(memory_layout::MAN1_ORG) } + unsafe { ref_from_addr(memory_layout::PERSISTENT_DATA_ORG) } } /// # Safety @@ -239,7 +331,7 @@ impl PersistentDataAccessor { pub fn get_mut(&mut self) -> &mut PersistentData { // WARNING: The returned lifetime elided from `self` is critical for // safety. Do not change this API without review by a Rust expert. - unsafe { ref_mut_from_addr(memory_layout::MAN1_ORG) } + unsafe { ref_mut_from_addr(memory_layout::PERSISTENT_DATA_ORG) } } } diff --git a/rom/dev/src/flow/cold_reset/idev_id.rs b/rom/dev/src/flow/cold_reset/idev_id.rs index 875b5de4a4..5ac5928c28 100644 --- a/rom/dev/src/flow/cold_reset/idev_id.rs +++ b/rom/dev/src/flow/cold_reset/idev_id.rs @@ -329,14 +329,3 @@ impl InitDevIdLayer { } } } - -#[cfg(test)] -mod tests { - use super::*; - use caliptra_drivers::memory_layout::IDEVID_CSR_SIZE; - - #[test] - fn verify_csr_fits_in_dccm() { - assert!(MAX_CSR_SIZE <= IDEVID_CSR_SIZE as usize); - } -} diff --git a/rom/dev/src/flow/fake.rs b/rom/dev/src/flow/fake.rs index 57dd203d53..cf02d15aeb 100644 --- a/rom/dev/src/flow/fake.rs +++ b/rom/dev/src/flow/fake.rs @@ -24,11 +24,8 @@ use crate::flow::update_reset; use crate::flow::warm_reset; use crate::print::HexBytes; use crate::rom_env::RomEnv; +use caliptra_common::FirmwareHandoffTable; use caliptra_common::RomBootStatus::*; -use caliptra_common::{ - memory_layout::{FMCALIAS_TBS_ORG, FMCALIAS_TBS_SIZE, LDEVID_TBS_ORG, LDEVID_TBS_SIZE}, - FirmwareHandoffTable, -}; use caliptra_drivers::cprintln; use caliptra_drivers::Lifecycle; use caliptra_drivers::LmsResult; diff --git a/rom/dev/tests/rom_integration_tests/test_fmcalias_derivation.rs b/rom/dev/tests/rom_integration_tests/test_fmcalias_derivation.rs index ce93544014..57518704ee 100644 --- a/rom/dev/tests/rom_integration_tests/test_fmcalias_derivation.rs +++ b/rom/dev/tests/rom_integration_tests/test_fmcalias_derivation.rs @@ -14,7 +14,6 @@ use caliptra_common::RomBootStatus::ColdResetComplete; use caliptra_common::RomBootStatus::*; use caliptra_common::{FirmwareHandoffTable, FuseLogEntry, FuseLogEntryId}; use caliptra_common::{PcrLogEntry, PcrLogEntryId}; -use caliptra_drivers::memory_layout::*; use caliptra_drivers::pcr_log::MeasurementLogEntry; use caliptra_drivers::{ColdResetEntry4, PcrId, RomVerifyConfig}; use caliptra_error::CaliptraError; @@ -744,11 +743,6 @@ fn test_fht_info() { let fht = FirmwareHandoffTable::read_from_prefix(data.as_bytes()).unwrap(); assert_eq!(fht.ldevid_tbs_size, 552); assert_eq!(fht.fmcalias_tbs_size, 753); - assert_eq!(fht.ldevid_tbs_addr, LDEVID_TBS_ORG); - assert_eq!(fht.fmcalias_tbs_addr, FMCALIAS_TBS_ORG); - assert_eq!(fht.pcr_log_addr, PCR_LOG_ORG); - assert_eq!(fht.meas_log_addr, MEASUREMENT_LOG_ORG); - assert_eq!(fht.fuse_log_addr, FUSE_LOG_ORG); } #[test]