From: Alexandru Gagniuc <mr.nuke.me@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 1/7] spl: fit: Don't overwrite previous loadable if "load" is missing
Date: Wed, 10 Mar 2021 12:04:36 -0600 [thread overview]
Message-ID: <20210310180442.746517-2-mr.nuke.me@gmail.com> (raw)
In-Reply-To: <20210310180442.746517-1-mr.nuke.me@gmail.com>
spl_load_fit_image() will try to load an image at the address given
in the "load" property. Absent such property, it uses
image_info->load_addr
Correct use of this is demonstrated in spl_fit_append_fdt(), which
resets the 'load_addr' before each spl_load_fit_image() call.
On the other hand loading "loadables" loop in spl_load_simple_fit()
completely ignores this. It re-uses the same structure, but doesn't
reset load_addr. If loadable [i] does not have a "load" property, its
load address defaults to load_addr, which still contains the address
of loadable [i - 1].
A simple solution is to treat NULL as an invalid load address. The
caller can set load_addr = 0 to request an abort if the "load"
property is absent.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
---
common/spl/spl_fit.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 75c8ff065b..43fc43cf2b 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -223,7 +223,7 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
* @image_info: will be filled with information about the loaded image
* If the FIT node does not contain a "load" (address) property,
* the image gets loaded to the address pointed to by the
- * load_addr member in this struct.
+ * load_addr member in this struct, if load_addr is not NULL
*
* Return: 0 on success or a negative error number.
*/
@@ -258,8 +258,14 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
debug("%s ", genimg_get_comp_name(image_comp));
}
- if (fit_image_get_load(fit, node, &load_addr))
+ if (fit_image_get_load(fit, node, &load_addr)) {
+ if (!image_info->load_addr) {
+ printf("Can't load %s: No load address and no buffer\n",
+ fit_get_name(fit, node, NULL));
+ return -ENOBUFS;
+ }
load_addr = image_info->load_addr;
+ }
if (!fit_image_get_data_position(fit, node, &offset)) {
external_data = true;
@@ -697,6 +703,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
if (firmware_node == node)
continue;
+ image_info.load_addr = 0;
ret = spl_load_fit_image(info, sector, &ctx, node, &image_info);
if (ret < 0) {
printf("%s: can't load image loadables index %d (ret = %d)\n",
--
2.26.2
next prev parent reply other threads:[~2021-03-10 18:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 18:04 [PATCH 0/7] SPL: FIT: Bring the SPL_LOAD_FIT path in line with documentation Alexandru Gagniuc
2021-03-10 18:04 ` Alexandru Gagniuc [this message]
2021-03-15 7:25 ` [PATCH 1/7] spl: fit: Don't overwrite previous loadable if "load" is missing Simon Glass
2021-03-10 18:04 ` [PATCH 2/7] doc: FIT image: Introduce "u-boot,fpga-legacy" property Alexandru Gagniuc
2021-03-10 18:04 ` [PATCH 3/7] spl: fit: Move FPGA loading code to separate functions Alexandru Gagniuc
2021-03-15 7:25 ` Simon Glass
2021-03-10 18:04 ` [PATCH 4/7] spl: fit: Warn if FIT contains "fpga" property in config node Alexandru Gagniuc
2021-03-18 6:44 ` Simon Glass
2021-03-19 14:53 ` Alex G.
2021-03-19 23:54 ` Simon Glass
2021-03-10 18:04 ` [PATCH 5/7] spl: fit: Support loading FPGA images from list of "loadables" Alexandru Gagniuc
2021-03-29 7:43 ` Simon Glass
2021-03-29 15:35 ` Alex G.
2021-03-10 18:04 ` [PATCH 6/7] Kconfig: Document the limitations of the simple SPL_LOAD_FIT path Alexandru Gagniuc
2021-03-29 7:43 ` Simon Glass
2021-03-10 18:04 ` [PATCH 7/7] doc: FIT image: Update FPGA example to make use of "loadables" Alexandru Gagniuc
2021-03-29 7:43 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210310180442.746517-2-mr.nuke.me@gmail.com \
--to=mr.nuke.me@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox