relocate uImage payload to ih_load under RAMBOOT#833
Open
dgarske wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a RAMBOOT-specific boot corruption when booting U-Boot legacy (uImage) payloads whose non-zero ih_load differs from the RAMBOOT staging location. Under WOLFBOOT_USE_RAMBOOT, wolfBoot_start() updates the jump target to ih_load but (prior to this change) did not relocate the already-staged payload there because the generic copy-to-RAM path is compiled out.
Changes:
- Relocate the staged uImage payload to
ih_loadvia overlap-safememmove()underWOLFBOOT_USE_RAMBOOTwhenih_load != 0and differs fromos_image.fw_base. - Add a host regression test that drives the real
wolfBoot_start()flow underWOLFBOOT_USE_RAMBOOT + WOLFBOOT_UBOOT_LEGACY, covering coincident, higher, lower-overlap, andih_load == 0cases. - Wire the new unit test into the unit-test build/run Makefile.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/update_ram.c | Adds RAMBOOT-only payload relocation to ih_load for uImage legacy boot to prevent jumping to unwritten memory. |
| tools/unit-tests/unit-update-ram-uboot.c | New regression test exercising uImage ih_load relocation behavior under RAMBOOT across multiple address/overlap cases. |
| tools/unit-tests/Makefile | Adds unit-update-ram-uboot to the test list and build rules with required defines and link objects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Under
WOLFBOOT_USE_RAMBOOT, aWOLFBOOT_UBOOT_LEGACY(uImage) payload with a non-zeroih_loadthat differs from the RAMBOOT staging address boots corrupt:wolfBoot_start()rewrites the jump target (load_address = ih_load) but never copies the payload there, because the generic copy-to-RAMmemcpyis compiled out under RAMBOOT -- sodo_boot()jumps to memory that was never written. This is reachable on the shippedzynqmp/zynq7000/versalconfigs (all setEXT_FLASH+NO_XIPand enableWOLFBOOT_UBOOT_LEGACY), just not on today's raw-zImage test path; any mkimage-wrapped kernel with a realih_loadhits it. The fix relocates the staged payload fromos_image.fw_basetoih_loadvia overlap-safememmovewhen the two differ, mirroring the non-RAMBOOT path (theih_load == 0Linux/PPC path is untouched). Added a host regression test (tools/unit-tests/unit-update-ram-uboot.c) that drives the realwolfBoot_start()flow with-DWOLFBOOT_UBOOT_LEGACYand asserts the payload lands atih_loadacross four cases (coincident / higher / lower-overlap /ih_load==0); verified it fails the relocation cases when the fix is reverted. No Zynq/Versal hardware locally -- validated via the hostcheckharness.Fixes #827