Skip to content

Run Linux beside a bare-metal AMP hart on PolarFire SoC from M-mode wolfBoot or an HSS payload - #995

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:mpfs_smode_amp
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:mpfs_smode_amp

Conversation

@dgarske

@dgarske dgarske commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Description

Lets wolfBoot boot Linux on U54_1-3 of a PolarFire SoC while U54_4 runs a separate bare-metal application, both as the M-mode HSS replacement and as an S-mode HSS payload. It also fixes two problems that surfaced running wolfBoot as the HSS payload.

M-mode AMP hart

  • MPFS_AMP_HART, MPFS_AMP_MEM_BASE, MPFS_AMP_MEM_SIZE, MPFS_AMP_IMAGE: the application travels in the signed FIT as an extra image, so the one signature covers kernel, dtb and application. wolfBoot copies it into the AMP region, bounded by its size, and refuses to boot if it is missing.
  • Before releasing hart 1, wolfBoot zeroes the L2 LIM, whose ECC is unwritten after reset, and starts the AMP hart in M-mode at the image's first byte. The SBI refuses hart_start for that hart, and the kernel dtb gets the hart's cpu@ node disabled and a /memreserve/ entry for its memory.
  • Build guards for the hart number, the M-mode Linux boot, an SD or eMMC image source, MPFS_WDT_NODES_KEEP, and an AMP region that overlaps the L2 LIM (which is zeroed after the image is loaded). The parked E51 keeps refreshing all five watchdogs, the AMP hart's included.
  • make config keeps the AMP and watchdog settings (MPFS_AMP_*, MPFS_WDT_NODES_KEEP).

HSS payload fixes

  • A refresh of the MSS watchdogs locks TIME, MVRP and TRIGGER until reset, and the image load refreshed them in every build. The Linux mpfs_wdt driver then could not program them at probe, and the watchdog reset the board during the Linux boot. With MPFS_WDT_NODES_KEEP=1, now set in polarfire_mpfs250.config, an S-mode build leaves the watchdogs to the OS. Other HSS-payload flows still refresh them as before.
  • HSS passes the payload no dtb, and its OpenSBI domain does not fence another hart's memory, so Linux allocated the AMP application's DDR and overwrote it. The same MPFS_AMP_MEM_* reservation covers this case, and the disk loader refuses an image whose staging range at WOLFBOOT_LOAD_ADDRESS would reach the AMP memory, since that copy happens before the signature check.

Testing

Validated on the Video Kit (MPFS250TS) with a wolfTPM firmware TPM on U54_4 and Yocto Linux 6.12 on U54_1-3. M-mode from eNVM at the current head: DDR training, FIT verification, AMP start and Linux login on 3 CPUs, with TPM commands served from Linux, across repeated cold boots. HSS payload: the same Linux and TPM workload under HSS. All PolarFire example configs and the AMP variants build; the watchdog unit tests, the gate check and unit-update-disk-amp (staging overlap refused, adjacent image boots) pass, and an AMP region inside or straddling the L2 LIM stops the build. The rejection paths (staging overlap, LIM overlap) and make config were exercised by the unit tests and builds only, not on hardware.

@dgarske dgarske self-assigned this Nov 18, 2026
Copilot AI balanced review requested due to automatic review settings November 18, 2026 15:51

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.

🟡 Changes recommended

Unauthenticated payload staging can overwrite the running HSS AMP application, while configuration regeneration drops AMP memory reservations and watchdog handoff settings.

2 open issues
What changed in this PR

Adds PolarFire SoC support for running Linux alongside a bare-metal AMP application, using either M-mode wolfBoot or an HSS payload.

Changes:

  • Loads the AMP application from the verified FIT, starts its hart in M-mode, and reserves its memory in the Linux device tree.
  • Leaves watchdogs untouched in OS-owned S-mode builds and enables this policy in the HSS example configuration.
  • Documents both boot flows and adds watchdog ownership tests.
File Description
tools/​unit-tests/​unit-mpfs-wdt.c Tests that OS-owned watchdogs remain untouched.
tools/​unit-tests/​Makefile Adds the OS-owned watchdog test target.
src/​update_disk.c Loads the AMP image from the verified FIT.
options.mk Adds AMP configuration options and build guards.
hal/​mpfs250.h Defines LIM geometry and AMP interfaces.
hal/​mpfs250.c Implements AMP loading, hart startup, memory reservation, and watchdog ownership.
docs/​PolarFire.md Documents AMP setup and watchdog behavior.
config/​examples/​polarfire_mpfs250.config Enables OS-owned watchdogs for the HSS flow.
.gitignore Ignores the new watchdog test binary.

Review effort: Balanced

Comment thread hal/mpfs250.c Resolved
Comment thread options.mk Resolved

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.

🟡 Changes recommended

Running make config drops required M-mode AMP prerequisites and mishandles whitespace-containing compiler flags, leaving the saved configuration unable to pass the new boot-mode guards.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread tools/config.mk Resolved

@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 #995

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .gitignore, config/examples/polarfire_mpfs250.config, docs/PolarFire.md, hal/mpfs250.h, options.mk, tools/config.mk, tools/unit-tests/Makefile
Coverage: 4 of 4 in-scope changed file(s) opened by the reviewer

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 hal/mpfs250.c Resolved
@dgarske
dgarske requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot November 19, 2026 18:12

@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 #995

Scan targets checked: none
Unchanged since last review (not re-run): wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .gitignore, config/examples/polarfire_mpfs250.config, docs/PolarFire.md, hal/mpfs250.h, options.mk, tools/config.mk, tools/unit-tests/Makefile

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 19, 2026 18:12

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

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.

🟡 Changes recommended

Unprotected DDR aliases and insufficient FIT relocation/decompression bounds can let unauthenticated disk reads, subimage writes, or Linux allocations overwrite M-mode/AMP application memory.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment thread hal/mpfs250.c
Comment on lines +1423 to +1424
ret = fdt_add_mem_rsv(&ctx, (uint64_t)MPFS_AMP_MEM_BASE,
(uint64_t)MPFS_AMP_MEM_SIZE);
Comment thread src/update_disk.c
Comment on lines +1209 to +1212
if (((uint64_t)(uintptr_t)load_address <
(uint64_t)MPFS_AMP_MEM_BASE + (uint64_t)MPFS_AMP_MEM_SIZE) &&
((uint64_t)(uintptr_t)load_address + os_image.fw_size >
(uint64_t)MPFS_AMP_MEM_BASE)) {
Comment thread src/update_disk.c
Comment on lines +1209 to +1212
if (((uint64_t)(uintptr_t)load_address <
(uint64_t)MPFS_AMP_MEM_BASE + (uint64_t)MPFS_AMP_MEM_SIZE) &&
((uint64_t)(uintptr_t)load_address + os_image.fw_size >
(uint64_t)MPFS_AMP_MEM_BASE)) {
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