Skip to content

Commit 0e6738a

Browse files
authored
runtime: Force run_reset_flow to not inline (#3881)
The run_reset_flow was previously inlined as part of the runtime entry point. This method was only invoked once during initialization, but due to being inlined its stack requirements (~6Kb) persisted for the entire duration of the runtime execution. By forcing the function to no longer be inlined its stack usage is recovered after completion, saving ~6Kb of stack space, and ~400 bytes of instruction memory.
1 parent ef49bbf commit 0e6738a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

runtime/src/drivers.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ impl Drivers {
156156
}
157157

158158
#[cfg_attr(feature = "cfi", cfi_impl_fn)]
159+
// Keep the reset flow out-of-line. It runs once at boot, but if inlined into
160+
// the runtime entry point its large transient scratch (cert-chain assembly,
161+
// DPE initialization/validation) stays reserved on the entry frame for the
162+
// entire mailbox-command lifetime, inflating the stack floor every command
163+
// pays. Forcing it out-of-line lets that scratch be reclaimed before the
164+
// mailbox loop begins.
165+
#[inline(never)]
159166
pub fn run_reset_flow(&mut self) -> CaliptraResult<()> {
160167
Self::create_cert_chain(self)?;
161168
if self.persistent_data.get().attestation_disabled.get() {

0 commit comments

Comments
 (0)