Fix XSPI FIFO indexing, PIC32 PFSWAP toggle, and small-stack key zeroize#819
Open
aidangarske wants to merge 3 commits into
Open
Fix XSPI FIFO indexing, PIC32 PFSWAP toggle, and small-stack key zeroize#819aidangarske wants to merge 3 commits into
aidangarske wants to merge 3 commits into
Conversation
aidangarske
commented
Jul 7, 2026
Member
61b28cd to
2f7d2ba
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes three low-level correctness issues in wolfBoot’s hardware/crypto paths and adds unit tests to prevent regressions: LS1028A XSPI TX FIFO register indexing, PIC32C dual-bank PFSWAP toggling (bit preservation on RMW), and encryption key cache zeroization on the small-stack path.
Changes:
- Fix LS1028A XSPI TX FIFO fill to use word indexing (
j/4) instead of byte-stride pointer arithmetic. - Fix PIC32C FCW_SWAP PFSWAP update to clear/set only the PFSWAP bit while preserving other register bits.
- Ensure
hal_set_key()zeroizesENCRYPT_CACHEeven whenWOLFBOOT_SMALL_STACKis enabled, and add unit tests covering all three fixes.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/unit-tests/unit-xspi-tfd-index.c | Adds a unit test that reproduces the XSPI TX FIFO mis-indexing and verifies the corrected word-index behavior. |
| tools/unit-tests/unit-pic32-pfswap.c | Adds a unit test validating correct PFSWAP toggling and preservation of unrelated FCW_SWAP bits. |
| tools/unit-tests/unit-enc-key-zeroize.c | Adds a unit test ensuring hal_set_key() zeroizes the (static) encryption cache on the small-stack configuration. |
| tools/unit-tests/Makefile | Registers and builds the new unit tests, including required per-test flags and sources for the encryption test. |
| src/libwolfboot.c | Updates hal_set_key() to zeroize ENCRYPT_CACHE regardless of WOLFBOOT_SMALL_STACK (still respecting existing guards). |
| hal/pic32c.c | Fixes FCW_SWAP RMW masking to clear the PFSWAP bit correctly (&= ~FCW_SWAP_PFSWAP). |
| hal/nxp_ls1028a.c | Fixes XSPI TFD pointer arithmetic to use word indexing for FIFO writes in both full and remainder loops. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2f7d2ba to
95a3ad2
Compare
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.