Skip to content

Fix XSPI FIFO indexing, PIC32 PFSWAP toggle, and small-stack key zeroize#819

Open
aidangarske wants to merge 3 commits into
wolfSSL:masterfrom
aidangarske:fix-xspi-tfd-word-index
Open

Fix XSPI FIFO indexing, PIC32 PFSWAP toggle, and small-stack key zeroize#819
aidangarske wants to merge 3 commits into
wolfSSL:masterfrom
aidangarske:fix-xspi-tfd-word-index

Conversation

@aidangarske

Copy link
Copy Markdown
Member
F-6588, F-6560, F-6567

Copilot AI review requested due to automatic review settings July 7, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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() zeroizes ENCRYPT_CACHE even when WOLFBOOT_SMALL_STACK is 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.

@aidangarske aidangarske force-pushed the fix-xspi-tfd-word-index branch from 2f7d2ba to 95a3ad2 Compare July 7, 2026 19:36
@aidangarske aidangarske self-assigned this Jul 7, 2026
@aidangarske aidangarske requested a review from danielinux July 7, 2026 19:51
@aidangarske aidangarske marked this pull request as ready for review July 7, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants