From 51bfb5cc0928232bdc555be15f1e4fef3f191d21 Mon Sep 17 00:00:00 2001 From: Anthony Rocha <116300062+rusty1968@users.noreply.github.com> Date: Wed, 20 Nov 2024 08:51:50 -0800 Subject: [PATCH] Miscellaneous fixes to the Soc Manager API (#1804) - Add hw-1.0 feature switch for support of hw-1.0 RTL. - Validate length of slice passed as an argument. --- api/Cargo.toml | 3 +++ api/src/soc_mgr.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/api/Cargo.toml b/api/Cargo.toml index 06cee6cc25..f8326cc863 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -15,3 +15,6 @@ caliptra-emu-types.workspace = true caliptra-registers.workspace = true caliptra-api-types.workspace = true ureg.workspace = true + +[features] +"hw-1.0" = ["caliptra-registers/hw-1.0"] diff --git a/api/src/soc_mgr.rs b/api/src/soc_mgr.rs index 2f20ab4f40..51dc967bd5 100644 --- a/api/src/soc_mgr.rs +++ b/api/src/soc_mgr.rs @@ -13,6 +13,8 @@ use core::mem; use ureg::MmioMut; use zerocopy::{AsBytes, FromBytes}; +pub const NUM_PAUSERS: usize = 5; + /// Implementation of the `SocManager` trait for a `RealSocManager`. /// /// # Example @@ -77,6 +79,10 @@ pub trait SocManager { /// Set up valid PAUSERs for mailbox access. fn setup_mailbox_users(&mut self, apb_pausers: &[u32]) -> Result<(), CaliptraApiError> { + if apb_pausers.len() > NUM_PAUSERS { + return Err(CaliptraApiError::UnableToSetPauser); + } + for (idx, apb_pauser) in apb_pausers.iter().enumerate() { if self .soc_ifc()