Repository navigation
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Cache-coherency and stateful-key changes need hardware validation, and stress-test payload-length regressions remain unresolved.
1 open issue
What changed in this PR
Adds non-coherent DMA support to wolfHSM while preserving direct DMA APIs and refusing unsafe wolfCrypt DMA dispatch.
Changes:
- Adds aligned, padded buffers and allocation helpers; corrects cache-range handling.
- Updates client dispatch, stateful-key transfers, and POSIX shared-memory handling.
- Adds regression tests, CI coverage, benchmark adjustments, and documentation.
| File | Description |
|---|---|
| wolfhsm/wh_utils.h | Declares DMA allocation helpers. |
| wolfhsm/wh_settings.h | Defines alignment configuration and macros. |
| wolfhsm/wh_client.h | Documents DMA dispatch restrictions. |
| wolfhsm/wh_client_cryptocb.h | Documents non-coherent callback behavior. |
| test/wh_test_posix_threadsafe_stress.c | Pads per-client DMA buffers. |
| test/wh_test_nvmflags.c | Aligns NVM outputs and preserves payload lengths. |
| test/wh_test_multiclient.c | Aligns multi-client DMA outputs. |
| test/wh_test_dma.c | Aligns bounce storage and checks outputs. |
| test/wh_test_crypto.c | Adapts DMA tests and adds refusal checks. |
| test/wh_test_common.h | Restricts DMA dispatch test modes. |
| test/wh_test_clientserver.c | Aligns client/server test buffers. |
| test/wh_test_cert.c | Aligns certificate export buffers. |
| test/Makefile | Adds non-coherent DMA build options. |
| test-refactor/wh_test_list.c | Registers new regression tests. |
| test-refactor/README.md | Documents stateful-signature test restrictions. |
| test-refactor/posix/wh_test_posix_shm_dma.c | Tests in-place shared-memory DMA buffers. |
| test-refactor/posix/wh_test_posix_main.c | Runs shared-memory DMA regression tests. |
| test-refactor/posix/Makefile | Adds non-coherent DMA build options. |
| test-refactor/misc/wh_test_multiclient.c | Aligns multi-client DMA outputs. |
| test-refactor/misc/wh_test_dma_noncoherent.c | Tests allocation and dispatch refusals. |
| test-refactor/misc/wh_test_crypto_affinity.c | Aligns DMA cipher outputs. |
| test-refactor/misc/wh_test_cache.c | Tests cache-line range coverage. |
| test-refactor/config/wolfhsm_cfg.h | Enables cache-operation recording. |
| test-refactor/client-server/wh_test_nvm_ops.c | Aligns NVM read storage. |
| test-refactor/client-server/wh_test_crypto_xmss.c | Skips unsupported wolfCrypt DMA tests. |
| test-refactor/client-server/wh_test_crypto_rng.c | Aligns outputs while preserving request lengths. |
| test-refactor/client-server/wh_test_crypto_mldsa.c | Aligns signature and export buffers. |
| test-refactor/client-server/wh_test_crypto_lms.c | Skips unsupported wolfCrypt DMA tests. |
| test-refactor/client-server/wh_test_crypto_keystore.c | Aligns exported-key buffers. |
| test-refactor/client-server/wh_test_crypto_ed25519.c | Aligns signature storage. |
| test-refactor/client-server/wh_test_crypto_ecc.c | Aligns public-key export storage. |
| test-refactor/client-server/wh_test_crypto_aes.c | Adapts buffers and DMA test guards. |
| src/wh_utils.c | Corrects cache ranges and adds DMA allocation. |
| src/wh_client.c | Rejects non-coherent DMA-preferred dispatch. |
| src/wh_client_dma.c | Adds test-only alignment and padding checks. |
| src/wh_client_cryptocb.c | Refuses non-coherent wolfCrypt DMA operations. |
| src/wh_client_crypto.c | Isolates and aligns DMA key outputs. |
| port/posix/posix_transport_shm.c | Aligns bounce allocations and validates in-place outputs. |
| docs/src/9-Configuration.md | Documents new configuration options. |
| docs/src/6-Utilities.md | Documents the benchmark build option. |
| docs/src/5-Features.md | Explains non-coherent DMA requirements. |
| benchmark/wh_bench_utils.h | Defines supported DMA benchmark guards. |
| benchmark/wh_bench_data.h | Enforces DMA buffer alignment constraints. |
| benchmark/wh_bench_data.c | Aligns built-in DMA storage. |
| benchmark/Makefile | Adds the non-coherent DMA option. |
| benchmark/bench_modules/wh_bench_mod_xmss.c | Guards unsupported DMA benchmarks. |
| benchmark/bench_modules/wh_bench_mod_sha3.c | Guards unsupported DMA benchmarks. |
| benchmark/bench_modules/wh_bench_mod_sha2.c | Guards unsupported DMA benchmarks. |
| benchmark/bench_modules/wh_bench_mod_mlkem.c | Aligns ciphertext buffers. |
| benchmark/bench_modules/wh_bench_mod_mldsa.c | Guards unsupported DMA benchmarks. |
| benchmark/bench_modules/wh_bench_mod_lms.c | Guards unsupported DMA benchmarks. |
| benchmark/bench_modules/wh_bench_mod_hmac.c | Guards unsupported DMA benchmarks. |
| benchmark/bench_modules/wh_bench_mod_cmac.c | Guards unsupported DMA benchmarks. |
| benchmark/bench_modules/wh_bench_mod_aes.c | Updates guards and DMA allocations. |
| .github/workflows/build-and-test.yml | Adds non-coherent DMA sanitizer coverage. |
| .github/workflows/build-and-test-refactor.yml | Adds refactored-suite sanitizer coverage. |
| .github/workflows/build-and-bench.yml | Adds non-coherent DMA benchmark coverage. |
Review effort: Balanced
4751e7c to
38dc29b
Compare
|
@rizlik , if possible can you ensure that the updates to |
|
@rizlik thanks for this, going to chew on it soon. Did a quick skim already. In the meantime, agree with @padelsbach about test-refactor. Ideally we are going to switch frameworks over in next release, so want to ensure coverage is in that suite. |
Added |
bigbrett
left a comment
There was a problem hiding this comment.
Nice work, I agree that there insn't much we can do about this problem when it comes to using DMA through the wolfCrypt API and the best option is just to prohibit it.
A few changes (including renaming the feature flag) otherwise it makes sense to me. I want to test this on some hardware ports once buttoned up too.
|
@JacobBarthelmeh @billphipps this touches some of the POSIX SHM stuff which I know you are using so could use one of your eyes before merge |

Adds
WOLFHSM_CFG_DMA_NONCOHERENTfor targets without hardware cache coherency.wh_Client_*DmaAPIs remain available.