Summary
The StMM SP heap size is hardcoded to 402 pages (1.6 MB) in core/arch/arm/kernel/stmm_sp.c. This is too small when StandaloneMm links AuthVariableLib + VarCheckPolicyLib (which pull in OpenSSL for Secure Boot certificate verification), causing allocation failures during MM initialization.
I worked around this by increasing to 800 pages in our fork, but it would be better to make this configurable via a build option like CFG_STMM_HEAP_SIZE.
Reproduction
Build OP-TEE with a StandaloneMm binary that includes edk2's AuthVariableLib and VarCheckPolicyLibStandaloneMm (i.e., any Secure Boot configuration). The SP fails to initialize because the heap runs out during OpenSSL library constructors.
Proposed fix
Add a CFG_STMM_HEAP_SIZE build option (in pages) with a default of 402 for backwards compatibility, allowing platforms that need Secure Boot to increase it. For example:
// stmm_sp.c
#ifndef CFG_STMM_HEAP_SIZE
#define CFG_STMM_HEAP_SIZE 402
#endif
Or alternatively, just increase the default — 800 pages (3.2 MB) works well in practice and the memory is only allocated when StMM is enabled.
Environment
Summary
The StMM SP heap size is hardcoded to 402 pages (1.6 MB) in
core/arch/arm/kernel/stmm_sp.c. This is too small when StandaloneMm linksAuthVariableLib+VarCheckPolicyLib(which pull in OpenSSL for Secure Boot certificate verification), causing allocation failures during MM initialization.I worked around this by increasing to 800 pages in our fork, but it would be better to make this configurable via a build option like
CFG_STMM_HEAP_SIZE.Reproduction
Build OP-TEE with a StandaloneMm binary that includes edk2's
AuthVariableLibandVarCheckPolicyLibStandaloneMm(i.e., any Secure Boot configuration). The SP fails to initialize because the heap runs out during OpenSSL library constructors.Proposed fix
Add a
CFG_STMM_HEAP_SIZEbuild option (in pages) with a default of 402 for backwards compatibility, allowing platforms that need Secure Boot to increase it. For example:Or alternatively, just increase the default — 800 pages (3.2 MB) works well in practice and the memory is only allocated when StMM is enabled.
Environment