Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues leave credentials and discarded responses in memory and allow NV storage to report success despite durability failures, risking stale or missing state after reboot.
3 open issues
What changed in this PR
Adds reusable components for hosting wolfTPM’s firmware TPM in an Arm EL2 monitor, with Linux access and encrypted NV persistence.
Changes:
- Defines the HVC interface and sealed NV storage with lineage checks.
- Adds a Linux driver, persistence daemon, and service integration.
- Adds host tests, port documentation, and distribution entries.
| File | Description |
|---|---|
wolftpm/include.am |
Installs the HVC header. |
wolftpm/fwtpm/fwtpm_hvc.h |
Defines HVC calls and sealed NV APIs. |
tests/include.am |
Registers the sealed NV host test. |
tests/hvc/fwtpm_hvc_nv_tests.c |
Tests sealing, tampering, keys, and lineage. |
src/fwtpm/ports/README.md |
Lists the Raspberry Pi reference port. |
src/fwtpm/ports/hvc/README.md |
Documents integration, setup, and security limits. |
src/fwtpm/ports/hvc/linux/tpm_fwtpm_hvc.c |
Implements Linux TPM, raw-command, and NV devices. |
src/fwtpm/ports/hvc/linux/Makefile |
Builds and installs Linux components. |
src/fwtpm/ports/hvc/linux/fwtpm-nvd.service |
Configures the persistence service. |
src/fwtpm/ports/hvc/linux/fwtpm-nvd.c |
Saves sealed NV images and lineage backups. |
src/fwtpm/ports/hvc/linux/60-fwtpm.rules |
Grants the tss group raw-device access. |
src/fwtpm/ports/hvc/fwtpm_hvc_nv.c |
Implements the RAM journal and authenticated sealing. |
src/fwtpm/include.am |
Packages HVC port files. |
.gitignore |
Tracks the port Makefile and ignores test outputs. |
Review effort: Balanced
Comment on lines
+207
to
+212
| dfd = open(dirname(dirBuf), O_RDONLY | O_DIRECTORY); | ||
| if (dfd >= 0) { | ||
| (void)fsync(dfd); | ||
| close(dfd); | ||
| } | ||
| return 0; |
Comment on lines
+214
to
+215
| if (len > count) | ||
| return -EMSGSIZE; |
Comment on lines
+294
to
+295
| } | ||
| mutex_unlock(&rf->lock); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Adds
src/fwtpm/ports/hvc, the platform-independent pieces of a fwTPM hosted in a bare-metal Arm hypervisor (EL2) monitor that runs an unmodified Linux at EL1 behind stage 2. Linux reaches the TPM by SMCCC hypervisor call, and the TPM's NV leaves the monitor only as an AES-256-GCM sealed image that Linux stores and the boot firmware hands back at the next boot. The reference port using it is RaspberryPi/fwtpm-el2 in wolftpm-examples (CM5 and CM4).wolftpm/fwtpm/fwtpm_hvc.h- the hypervisor call interface (function IDs, status codes, NV flags) and the sealed NV API and image layoutsrc/fwtpm/ports/hvc/fwtpm_hvc_nv.c- the NV journal in monitor RAM as anFWTPM_NV_HAL; keys derived by HKDF from a port-supplied root and domain; lineage and seed check so a new TPM never silently replaces a stored one; finding an image by its tail behind other data (an initramfs)src/fwtpm/ports/hvc/linux/-tpm_fwtpm_hvcdriver (/dev/tpm0,/dev/tpmrm0, a raw 8192-byte/dev/fwtpmfor ML-DSA-87,/dev/fwtpm-nv), with preempted commands resumed after the interrupt;fwtpm-nvddaemon that stores each change and an orderly-shutdown image; systemd unit and udev ruletests/hvc/fwtpm_hvc_nv_tests.c- host test of the sealed image (round trip, tampering, wrong key source, truncation, lineage), built under--enable-fwtpmsrc/fwtpm/ports/hvc/README.md, and the Raspberry Pi port in the ports tableTesting
make checkwith the new test in the default, v1.85, UBSan, ASan, ASan v1.85 andWOLFTPM_USE_SYMMETRICconfigurations; g++, no-wolfCrypt,--disable-wrapper,--disable-examples,--enable-st33and--enable-adviobuilds with-Werror; ibmswtpm2 unit tests and examples; codespell.fwtpm-nvdstored each change and stopped cleanly. NV was exercised with the public test key; the boards' OTP keys are not programmed.