Skip to content

Add a compact native NVM store and drop the wolfHSM NVM layers from native builds - #101

Merged
dgarske merged 65 commits into
wolfSSL:mainfrom
aidangarske:storage-shrink
Dec 3, 2026
Merged

dgarske merged 65 commits into
wolfSSL:mainfrom
aidangarske:storage-shrink

Conversation

@aidangarske

@aidangarske aidangarske commented Nov 30, 2026 •

Copy link
Copy Markdown
Member
  • Native builds linked wolfHSM's full NVM stack (wh_nvm, wh_nvm_flash, wh_flash_unit, wh_lock) to hold a few small objects.
  • Adds nvm_native.c, a two-partition store of 16-byte program-once records with a directory, a backup header and a twinned commit unit per slot.
  • It becomes the native engine's default; WT_NVM_STORE=wolfhsm brings back the wolfHSM store, and the hsm engine always uses it.
  • A power cut at any program or erase step leaves the state before or after the operation; a damaged commit or header unit is read from its twin and never passes for a torn write.
  • A sealed vault object and its counter table entry commit as one transaction, so a sealed object never lands without its replay counter.
  • A locked device refuses to launch guests when the store cannot record that the rollback floors exist, so a lost floor table is never taken for a first boot.
  • Keystore keys go through vault key ops (KEY_PUT/GET/DEL) instead of the NVM client callback layer; one IPC helper is shared by the vault, storage and NVM client services.
  • New host suites nvm_native, key_face and vault_txn cut power at every step; the vault, PS, ITS, keystore and rollback suites run over both stores
  • Depends on Rewrite the Secure Partition Manager core around constant generated tables #97 so waiting on that and needs rebased after merge

STM32L562 by category:

Category Before After Change
Storage 17,224 13,142 -4,082 (-23.7%)
SPM 10,949 10,541 -408 (-3.7%)
Attestation 6,288 6,288 0
Guest management 4,808 4,808 0
Platform 3,490 3,490 0
Runtime, fill, linker 491 485 -6
Non-crypto total 43,250 38,754 -4,496 (-10.4%)
Crypto 20,954 20,662 -292
Secure image total 64,204 59,416 -4,788 (-7.5%)

Every port:

Port Storage before Storage after Non-crypto before Non-crypto after Non-crypto change
STM32L562 17,224 13,142 43,250 38,754 -4,496 (-10.4%)
STM32H563 17,210 13,128 43,823 39,335 -4,488 (-10.2%)
MIMXRT700 18,120 14,070 43,796 39,340 -4,456 (-10.2%)
MCX N947 17,032 12,982 42,380 37,924 -4,456 (-10.5%)

@aidangarske aidangarske self-assigned this Nov 30, 2026
@aidangarske aidangarske added the ci:all Run every M33MU scenario of every port on the PR (core change) label Nov 30, 2026

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #101

Scan targets checked: wolftrust-src, wolftrust-bugs
Not reviewed (no scan target covers them): .github/workflows/cross-compile.yml, .gitignore, Makefile, docs/Crypto-Engines.md, docs/Footprint.md, docs/Macros.md, docs/Porting.md, docs/Project-Structure.md, docs/Security-Model.md, docs/TF-M-Compatibility.md, lib/wolfCOSE, mk/common.mk, mk/layout.mk, port/mcxn947/port.json, port/mimxrt700/port.json, port/stm32h563/port.json, port/stm32l562/port.json, tests/fuzz/Makefile, tests/fuzz/wt_spm_fuzz.c, tests/host/Makefile and 53 more
Coverage: 70 of 125 in-scope changed file(s) opened by the reviewer; not opened: include/wolftrust/arch/armv8m/cmse.h, include/wolftrust/ffm.h, include/wolftrust/ffm_boot.h, include/wolftrust/ffm_domain.h, include/wolftrust/ffm_gateway.h, include/wolftrust/guest_verify.h, include/wolftrust/irq_claim.h, include/wolftrust/manifest.h, include/wolftrust/nvm_native.h, include/wolftrust/nvm_store.h and 45 more

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Max

Comment thread src/spm/core.c Resolved
Copilot AI balanced review requested due to automatic review settings December 1, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The footprint documentation still reports a 10 KiB crypto stack despite the new 6 KiB default, leaving allocation, measurement, and headroom guidance inconsistent.

1 open issue
What changed in this PR

This PR reduces wolfTrust’s native storage footprint by introducing a compact NVM store and routing native key operations through the vault. It also carries the SPM integration changes from #97, adapting services, host fixtures and build checks to the new core.

Changes:

  • Adds native-store interfaces, transactional seal-key setup and vault key operations, while retaining the wolfHSM store option.
  • Migrates service transports and host fixtures to the SPM core, including restart and trimmed-API coverage.
  • Updates memory allocations, footprint classification, per-port size limits and CI checks.
File Description
tools/​secure_owners.txt Classifies new SPM, vault and key-client objects.
tools/​l3_layout_args.py Supplies SPM-private ranges to layout validation.
tools/​footprint/​wolftrust.rules Adds wolfTrust footprint categories.
tools/​footprint/​tfm.rules Adds corresponding TF-M footprint categories.
tools/​check-core-port-split.sh Guards the SPM core’s include boundary.
tests/​target/​lib/​scenarios.py Allows absent wolfHSM backend diagnostics.
tests/​host/​wolfhsm_relay/​Makefile Links the shared SPM host fixture.
tests/​host/​wolfhsm_relay/​main.c Migrates relay tests to SPM host calls.
tests/​host/​vnet_relay/​Makefile Links SPM support and shared vault IPC.
tests/​host/​vnet_relay/​main.c Adapts VNET fixtures and restart handling.
tests/​host/​vault_txn/​user_settings.h Configures crypto for vault transaction tests.
tests/​host/​vault_service/​Makefile Adds native-store and SPM fixture support.
tests/​host/​tpm_relay/​Makefile Builds TPM tests against the SPM core.
tests/​host/​tpm_relay/​main.c Migrates TPM calls to the host fixture.
tests/​host/​support/​test_nvm_store.h Adapts shared tests to either store.
tests/​host/​support/​spm_tables.h Declares host manifest-to-table helpers.
tests/​host/​support/​spm_host.mk Shares SPM host sources and build flags.
tests/​host/​support/​spm_host.h Defines the synchronous SPM host fixture.
tests/​host/​support/​secure_domain_resolve.h Declares host domain-reference helpers.
tests/​host/​support/​secure_domain_resolve.c Moves descriptive domain resolution into test support.
tests/​host/​storage_service/​Makefile Adds native-store and shared IPC support.
tests/​host/​stm32l562_flash/​Makefile Enables diagnostics required by flash tests.
tests/​host/​spm/​Makefile Updates production-manifest test dependencies.
tests/​host/​spm/​main.c Retains default-build manifest validation checks.
tests/​host/​spm_start/​Makefile Adds a no-restart test configuration.
tests/​host/​spm_gate/​trims_main.c Checks rejection of disabled partition APIs.
tests/​host/​spm_gate/​Makefile Builds the shared fixture and trimmed-API tests.
tests/​host/​spm_core/​Makefile Adds core, restart and guest-count configurations.
tests/​host/​psa_storage_client/​Makefile Adds native-store and SPM fixture support.
tests/​host/​psa_secure_crypto/​server.c Initializes keys through the vault keystore interface.
tests/​host/​psa_secure_crypto/​Makefile Explicitly selects native-engine compilation.
tests/​host/​psa_ffm_client/​Makefile Uses shared SPM and vault IPC support.
tests/​host/​psa_ff_upstream/​README.md Updates core state and test-path references.
tests/​host/​psa_ff_upstream/​psa_binding.h Defines host PSA identity bindings.
tests/​host/​psa_ff_upstream/​Makefile Replaces legacy runtime sources with SPM support.
tests/​host/​ps_service/​Makefile Adds native-store and shared fixture support.
tests/​host/​port_flash/​Makefile Enables flash diagnostics and SPM support.
tests/​host/​port_binding/​main.c Adapts fixtures to pointer-based memory windows.
tests/​host/​pkcs11_relay/​Makefile Links the shared SPM host fixture.
tests/​host/​pkcs11_relay/​main.c Migrates PKCS#11 transport tests to SPM calls.
tests/​host/​nvm_native/​Makefile Adds the native NVM host-suite build.
tests/​host/​nvm_boot/​Makefile Adds native-store and vault IPC dependencies.
tests/​host/​negatives/​Makefile Supports native-store negative tests.
tests/​host/​negatives/​main.c Uses the store adapter and neutral fixture text.
tests/​host/​native_wire/​Makefile Adds explicit native-engine and store selection.
tests/​host/​native_wire/​main.c Uses the store adapter and keystore interface.
tests/​host/​monitor/​Makefile Adds explicit restart and no-restart configurations.
tests/​host/​monitor/​main.c Updates stubs and tests no-restart quarantine.
tests/​host/​manifest_render/​test_manifest_render.py Refreshes expected manifest hashes.
tests/​host/​manifest_ports/​run.sh Links table derivation instead of the old runtime.
tests/​host/​manifest_ports/​main.c Checks constant guest rows and derived SPM tables.
tests/​host/​Makefile Registers new suites and native-store reruns.
tests/​host/​layout_config/​test_layout_config.py Checks per-guest sizing in manifest templates.
tests/​host/​keystore_isolation/​main.c Removes comparison branding from a comment.
tests/​host/​keystore_ipc/​Makefile Adds native-store, vault IPC and SPM support.
tests/​host/​irq_claim/​main.c Replaces callback fixtures with architecture symbols.
tests/​host/​ipc/​Makefile Removes the retired IPC-suite build.
tests/​host/​guest_verify/​main.c Adapts tests to pointer-based measurement records.
tests/​host/​fwu_service/​Makefile Links firmware-update tests to SPM support.
tests/​host/​fwu_restore/​main.c Captures restore hooks during scheduler registration.
tests/​host/​footprint_classify/​Makefile Adds footprint-classifier test entry points.
tests/​host/​ffm_veneer/​Makefile Adds shared SPM and vault IPC dependencies.
tests/​host/​ffm_domain/​Makefile Links host domain-reference helpers.
tests/​host/​ffm_domain/​main.c Uses the relocated domain helpers.
tests/​host/​boot_seed/​main.c Replaces legacy lifecycle stubs with core state.
tests/​host/​attestation_service/​Makefile Links attestation tests to SPM support.
tests/​host/​attestation_iak/​main.c Simplifies the key-isolation description only.
tests/​host/​attestation_golden/​Makefile Disables redundant claim-string UTF-8 checks.
tests/​host/​attest_restore/​main.c Updates restore registration and measurement stubs.
tests/​fuzz/​Makefile Targets SPM support and gateway code.
src/​sync/​mutex.c Shares queued acquisition and rejects recursive locking.
src/​spm.c Removes the generated-manifest bypass initializer.
src/​services/​wolfhsm/​wt_hsm_seal.c Uses store wrappers and native transactional key setup.
src/​services/​vnet/​vnet_relay_service.c Uses the platform-appropriate default transport.
src/​services/​nvm_client.c Reuses the shared vault IPC client helper.
src/​services/​native/​psa_crypto_service.c Adapts persistent-record reads to the new interface.
src/​services/​native/​key_client.c Adds vault key-operation IPC forwarding.
src/​services/​native/​crypto_native.c Initializes the vault keystore and omits native-store locks.
src/​services/​msg_relay.c Restores the platform-specific transport default.
src/​services/​initial_attestation.c Consolidates claim validation and requires target IPC binding.
src/​services/​hsm_relay_service.c Uses the platform-specific default transport.
src/​services/​boot_handoff.c Consolidates handoff validation and clearing.
src/​partition.c Simplifies a port-validation comment only.
src/​irq_claim.c Calls architecture interrupt operations directly.
src/​guest_verify.c Stores pointers to pinned measurement records.
src/​ffm_domain.c Removes descriptive resolution now kept in test support.
src/​client/​psa_storage_client.c Updates the transfer-budget name in a comment.
src/​boot.c Writes lifecycle state directly into the SPM core.
src/​arch/​common/​spm_sp_api.c Conditionally builds trimmable partition APIs.
src/​arch/​common/​measure_ops.c Extracts privileged measurement access.
src/​arch/​common/​fwu_ops.c Extracts privileged firmware-update operations.
src/​arch/​armv8m/​irq_armv8m.c Exposes architecture interrupt operations directly.
src/​arch/​armv8m/​ffm_nsc.c Uses consolidated guest-buffer validation.
src/​arch/​armv8m/​coroutine_armv8m.c Uses shared coroutine offsets in assembly.
port/​stm32l562/​port.json Adds non-crypto and SPM flash ceilings.
port/​stm32l562/​flash_drv.c Makes first-error diagnostics optional.
port/​stm32h563/​port.json Adds non-crypto and SPM flash ceilings.
port/​stm32h563/​flash_drv.c Makes first-error diagnostics optional.
port/​mimxrt700/​port.json Adds non-crypto and SPM flash ceilings.
port/​mcxn947/​port.json Adds non-crypto and SPM flash ceilings.
port/​common/​hsm_flash.h Guards optional forensic declarations.
port/​common/​hsm_flash_ctx.c Guards optional flash-gate diagnostic state.
port/​common/​armv8m/​secure_l3_bands.ld Places native-store and key-client partition data.
port/​common/​armv8m/​platform_armv8m.c Removes obsolete gateway installation.
port/​common/​armv8m/​l3_layout.h Reduces the default wolfHSM crypto stack.
mk/​layout.mk Adjusts crypto-stack and native-vault sizing.
Makefile Replaces legacy IPC/FF-M test targets with SPM-core targets.
include/​wolftrust/​vnet/​vnet_abi.h Updates the transfer-budget name in a comment.
include/​wolftrust/​spm.h Removes the generated-manifest initializer declaration.
include/​wolftrust/​spm_sp_mem.h Defines generated partition memory rows.
include/​wolftrust/​spm_sched.h Combines scheduling and restore-hook registration.
include/​wolftrust/​spm_ops.h Declares privileged service-operation helpers.
include/​wolftrust/​spm_gate.h Defines transport defaults and the run hook.
include/​wolftrust/​services/​vault_ipc.h Defines shared service and client IPC interfaces.
include/​wolftrust/​services/​storage_service.h Removes obsolete per-loop connection state.
include/​wolftrust/​services/​nvm_client.h Aliases the shared service-client context.
include/​wolftrust/​services/​msg_relay.h Uses platform-specific transport initialization.
include/​wolftrust/​services/​hsm.h Adds native vault contracts and conditional locking.
include/​wolftrust/​services/​crypto_native.h Declares vault-backed key-client interfaces.
include/​wolftrust/​sched/​tasklet.h Removes the obsolete tick wrapper.
include/​wolftrust/​sched/​coroutine.h Updates explicit-run and fault-recovery contracts.
include/​wolftrust/​sched/​coroutine_internal.h Sizes coroutine tables and centralizes assembly offsets.
include/​wolftrust/​partition.h Uses constant per-guest memory arrays.
include/​wolftrust/​nvm_store.h Omits the mutex declaration for native storage.
include/​wolftrust/​nvm_native.h Defines native-store state and transaction APIs.
include/​wolftrust/​manifest.h Defines when boot isolation validation runs.
include/​wolftrust/​irq_claim.h Replaces interrupt callbacks with architecture functions.
include/​wolftrust/​ipc.h Removes the retired IPC contract.
include/​wolftrust/​guest_verify.h Documents retained measurement-pointer lifetime.
include/​wolftrust/​ffm_gateway.h Removes the obsolete installation declaration.
include/​wolftrust/​ffm_domain.h Removes runtime resolution and stack fields.
include/​wolftrust/​ffm_boot.h Simplifies the SPM boot interface.
include/​wolftrust/​arch/​armv8m/​cmse.h Declares consolidated guest-buffer validation.
docs/​Security-Model.md Updates documented main-stack allocation and usage.
docs/​Project-Structure.md Documents SPM-core and footprint-tool locations.
docs/​Porting.md Documents per-port footprint ceilings.
docs/​Macros.md Documents store selection, restart and diagnostic controls.
docs/​Footprint.md Updates storage allocation and footprint descriptions.
.gitignore Removes the retired IPC build-directory entry.
.github/​workflows/​cross-compile.yml Adds footprint gates and store/feature build checks.

Review effort: Balanced

Comment thread docs/Footprint.md Resolved
@aidangarske
aidangarske marked this pull request as ready for review December 2, 2026 17:19

@dgarske dgarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked at e2c8a45. The full host suite and the ASan/UBSan runs pass. The wolfHSM-store double readback is gone: Program compares once, and Verify only checks the range. The other changes look good too: the stopped-store and lost-seal paths keep services up and launch no guest, a reformat happens only on a seal key and table mismatch, and the commit-twin write is safe because the slot was blank.

@dgarske
dgarske merged commit 9c74be2 into wolfSSL:main Dec 3, 2026
438 checks passed
@aidangarske
aidangarske deleted the storage-shrink branch December 3, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:all Run every M33MU scenario of every port on the PR (core change)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants