spl: Fix the uninitialised /fit-images entry point
Get series with b4
b4 am [email protected]Versions newest first
- v2 Latest2 patches 2 repliesIn review
Changes in v2 from the cover letter
- 1/2: drop the int return type. Tom pointed out that neither call site checked it, and there is nothing for them to do: the accessors leave the out parameter untouched on failure, so the default the caller already set up stands. The function is void and the commit message now spells out that mechanism. Subject reworded to match.
- 2/2: unchanged.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | spl: atf: Keep the caller's default when the entry lookup failscommon/ | +12 | 0 replies | |
| 2/2 | spl: opensbi: Check the return of the entry/load lookupcommon/ | +5 | 1 reply |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Yao Zi |
|---|---|
| 1/2 | |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/2] spl: Fix the uninitialised /fit-images entry point
Both the ATF and the OpenSBI hand-off paths look up the next stage's entry point in a /fit-images node, trying fit_image_get_entry() and falling back to fit_image_get_load(). Neither site tests the result of the fallback.
fit_image_get_address() returns -1 before it reaches the assignment to *load in two cases: the property is absent, and the value does not fit in a target ulong. The caller's ulong is left untouched in both, so a node with neither property leaves the entry point uninitialised. It reaches bl31_entry() as the BL33 entry point on ARM, and opensbi_info.next_addr, the S-mode entry point, on RISC-V.
Both sites came from the same conversion in commit caa7fc2c5775 ("spl: Use standard FIT entries"). fdt_getprop_u32() returned the value and yielded FDT_ERROR on failure, so the variable was always assigned; the fit_image_get_*() accessors moved the failure signal into a return value that was then ignored.
The two paths differ in what a failed lookup means, so they are fixed differently. In spl_invoke_atf() the caller has already initialised a sane default (0 for BL32, CONFIG_TEXT_BASE for BL33), so the out parameter is the whole fix and there is no status worth returning. In spl_invoke_opensbi() there is no default, so the boot fails.
Changes in v2:
- 1/2: drop the int return type. Tom pointed out that neither call site checked it, and there is nothing for them to do: the accessors leave the out parameter untouched on failure, so the default the caller already set up stands. The function is void and the commit message now spells out that mechanism. Subject reworded to match.
- 2/2: unchanged.
v1: https://lore.kernel.org/u-boot/[email protected]/
Build-tested with no new warnings:
sifive_unmatched_defconfig (riscv64, spl/u-boot-spl)
cm3588-nas-rk3588_defconfig (aarch64, spl/u-boot-spl, covers spl_atf.c)
Sebastian Alba Vives (2):
spl: atf: Keep the caller's default when the entry lookup fails
spl: opensbi: Check the return of the entry/load lookup
common/spl/spl_atf.c | 21 ++++++++++++--------- common/spl/spl_opensbi.c | 5 +++++ 2 files changed, 17 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0