Skip to content

Commit

Permalink
Inline execute methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
clundin25 authored and jhand2 committed Nov 13, 2024
1 parent 6cd0ebe commit 7ba955c
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/src/fips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ impl FipsVersionCmd {
pub const NAME: [u8; 12] = *b"Caliptra RTM";
pub const MODE: u32 = 0x46495053;

#[cfg_attr(feature = "runtime", inline(never))]
pub fn execute(soc_ifc: &SocIfc) -> CaliptraResult<FipsVersionResp> {
cprintln!("[rt] FIPS Version");

Expand Down
1 change: 1 addition & 0 deletions runtime/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use caliptra_error::CaliptraResult;

pub struct CapabilitiesCmd;
impl CapabilitiesCmd {
#[inline(never)]
pub(crate) fn execute() -> CaliptraResult<MailboxResp> {
let mut capabilities = Capabilities::default();
capabilities |= Capabilities::RT_BASE;
Expand Down
1 change: 1 addition & 0 deletions runtime/src/certify_key_extended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use crate::{

pub struct CertifyKeyExtendedCmd;
impl CertifyKeyExtendedCmd {
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
let cmd = CertifyKeyExtendedReq::read_from(cmd_args)
.ok_or(CaliptraError::RUNTIME_INSUFFICIENT_MEMORY)?;
Expand Down
4 changes: 4 additions & 0 deletions runtime/src/dice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use zerocopy::AsBytes;

pub struct IDevIdCertCmd;
impl IDevIdCertCmd {
#[inline(never)]
pub(crate) fn execute(cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
if cmd_args.len() <= core::mem::size_of::<GetIdevCertReq>() {
let mut cmd = GetIdevCertReq::default();
Expand Down Expand Up @@ -65,6 +66,7 @@ impl IDevIdCertCmd {

pub struct GetLdevCertCmd;
impl GetLdevCertCmd {
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers) -> CaliptraResult<MailboxResp> {
let mut resp = GetLdevCertResp::default();

Expand All @@ -80,6 +82,7 @@ impl GetLdevCertCmd {

pub struct GetFmcAliasCertCmd;
impl GetFmcAliasCertCmd {
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers) -> CaliptraResult<MailboxResp> {
let mut resp = GetFmcAliasCertResp::default();

Expand All @@ -95,6 +98,7 @@ impl GetFmcAliasCertCmd {

pub struct GetRtAliasCertCmd;
impl GetRtAliasCertCmd {
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers) -> CaliptraResult<MailboxResp> {
let mut resp = GetRtAliasCertResp::default();

Expand Down
1 change: 1 addition & 0 deletions runtime/src/fips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ pub mod fips_self_test_cmd {
pub struct FipsShutdownCmd;
impl FipsShutdownCmd {
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
#[inline(never)]
pub(crate) fn execute(env: &mut Drivers) -> CaliptraResult<MailboxResp> {
FipsModule::zeroize(env);
env.is_shutdown = true;
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use caliptra_image_types::RomInfo;

pub struct FwInfoCmd;
impl FwInfoCmd {
#[inline(never)]
pub(crate) fn execute(drivers: &Drivers) -> CaliptraResult<MailboxResp> {
let pdata = drivers.persistent_data.get();

Expand Down Expand Up @@ -51,6 +52,7 @@ impl FwInfoCmd {

pub struct IDevIdInfoCmd;
impl IDevIdInfoCmd {
#[inline(never)]
pub(crate) fn execute(drivers: &Drivers) -> CaliptraResult<MailboxResp> {
let pdata = drivers.persistent_data.get();
let pub_key = pdata.fht.idev_dice_pub_key;
Expand Down
1 change: 1 addition & 0 deletions runtime/src/invoke_dpe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use zerocopy::{AsBytes, FromBytes};
pub struct InvokeDpeCmd;
impl InvokeDpeCmd {
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
if cmd_args.len() <= core::mem::size_of::<InvokeDpeReq>() {
let mut cmd = InvokeDpeReq::default();
Expand Down
3 changes: 3 additions & 0 deletions runtime/src/pcr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use zerocopy::FromBytes;
pub struct IncrementPcrResetCounterCmd;
impl IncrementPcrResetCounterCmd {
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
let cmd = IncrementPcrResetCounterReq::read_from(cmd_args)
.ok_or(CaliptraError::RUNTIME_INSUFFICIENT_MEMORY)?;
Expand All @@ -45,6 +46,7 @@ impl IncrementPcrResetCounterCmd {
pub struct GetPcrQuoteCmd;
impl GetPcrQuoteCmd {
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_bytes: &[u8]) -> CaliptraResult<MailboxResp> {
let args: QuotePcrsReq = QuotePcrsReq::read_from(cmd_bytes)
.ok_or(CaliptraError::RUNTIME_MAILBOX_INVALID_PARAMS)?;
Expand Down Expand Up @@ -73,6 +75,7 @@ impl GetPcrQuoteCmd {
pub struct ExtendPcrCmd;
impl ExtendPcrCmd {
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
let cmd =
ExtendPcrReq::read_from(cmd_args).ok_or(CaliptraError::RUNTIME_INSUFFICIENT_MEMORY)?;
Expand Down
1 change: 1 addition & 0 deletions runtime/src/populate_idev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::{Drivers, MAX_CERT_CHAIN_SIZE, PL0_PAUSER_FLAG};

pub struct PopulateIDevIdCertCmd;
impl PopulateIDevIdCertCmd {
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
if cmd_args.len() <= core::mem::size_of::<PopulateIdevCertReq>() {
let mut cmd = PopulateIdevCertReq::default();
Expand Down
1 change: 1 addition & 0 deletions runtime/src/subject_alt_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl AddSubjectAltNameCmd {
pub const DMTF_OID: &'static [u8] =
&[0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1C, 0x82, 0x12, 0x01];

#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
if cmd_args.len() <= core::mem::size_of::<AddSubjectAltNameReq>() {
let mut cmd = AddSubjectAltNameReq::default();
Expand Down
1 change: 1 addition & 0 deletions runtime/src/tagging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::{dpe_crypto::DpeCrypto, CptraDpeTypes, DpePlatform, Drivers};
pub struct TagTciCmd;
impl TagTciCmd {
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
let cmd =
TagTciReq::read_from(cmd_args).ok_or(CaliptraError::RUNTIME_INSUFFICIENT_MEMORY)?;
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use zerocopy::{BigEndian, FromBytes, LittleEndian, U32};
pub struct EcdsaVerifyCmd;
impl EcdsaVerifyCmd {
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
let cmd = EcdsaVerifyReq::read_from(cmd_args)
.ok_or(CaliptraError::RUNTIME_INSUFFICIENT_MEMORY)?;
Expand Down Expand Up @@ -60,6 +61,7 @@ impl EcdsaVerifyCmd {
pub struct LmsVerifyCmd;
impl LmsVerifyCmd {
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
#[inline(never)]
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> {
// Re-run LMS KAT once (since LMS is more SW-based than other crypto)
if let Err(e) =
Expand Down

0 comments on commit 7ba955c

Please sign in to comment.