From: Alexandru Gagniuc <mr.nuke.me@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v4 8/8] spl: fit: Load devicetree when a Linux payload is found
Date: Wed, 20 Jan 2021 10:46:56 -0600 [thread overview]
Message-ID: <20210120164656.1396639-9-mr.nuke.me@gmail.com> (raw)
In-Reply-To: <20210120164656.1396639-1-mr.nuke.me@gmail.com>
When a FIT config specifies a devicetree, we should load it, no
questions asked. In the case of the "simple" FIT loading path, a
difficulty arises in selecting the load address of the FDT.
The default FDT location is right after the "kernel" or "firmware"
image. However, if that is an OP-TEE image, then the FDT may end up in
secure DRAM, and not be accessible to normal world kernels.
Although the best solution is to be more careful about the FDT
address, a viable workaround is to only append the FDT after a u-boot
or Linux image. This is identical to the previous logic, except that
FDT loading is extended to IH_OS_LINUX images.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
---
common/spl/spl_fit.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 5de36510b7..711a4f2959 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -335,6 +335,18 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
return 0;
}
+static bool os_takes_devicetree(uint8_t os)
+{
+ switch (os) {
+ case IH_OS_U_BOOT:
+ return true;
+ case IH_OS_LINUX:
+ return IS_ENABLED(CONFIG_SPL_OS_BOOT);
+ default:
+ return false;
+ }
+}
+
static int spl_fit_append_fdt(struct spl_image_info *spl_image,
struct spl_load_info *info, ulong sector,
const struct spl_fit_info *ctx)
@@ -661,9 +673,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
* Booting a next-stage U-Boot may require us to append the FDT.
* We allow this to fail, as the U-Boot image might embed its FDT.
*/
- if (spl_image->os == IH_OS_U_BOOT) {
+ if (os_takes_devicetree(spl_image->os)) {
ret = spl_fit_append_fdt(spl_image, info, sector, &ctx);
- if (!IS_ENABLED(CONFIG_OF_EMBED) && ret < 0)
+ if (ret < 0 && spl_image->os != IH_OS_U_BOOT)
return ret;
}
@@ -694,7 +706,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
if (!spl_fit_image_get_os(ctx.fit, node, &os_type))
debug("Loadable is %s\n", genimg_get_os_name(os_type));
- if (os_type == IH_OS_U_BOOT) {
+ if (os_takes_devicetree(os_type)) {
spl_fit_append_fdt(&image_info, info, sector, &ctx);
spl_image->fdt_addr = image_info.fdt_addr;
}
--
2.26.2
next prev parent reply other threads:[~2021-01-20 16:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 16:46 [PATCH v4 0/8] spl: fit: Play nicely with OP-TEE and Linux Alexandru Gagniuc
2021-01-20 16:46 ` [PATCH v4 1/8] spl: fit: Drop 'length' argument to board_spl_fit_post_load() Alexandru Gagniuc
2021-02-19 16:55 ` Tom Rini
2021-01-20 16:46 ` [PATCH v4 2/8] spl: fit: Factor out FIT parsing and use a context struct Alexandru Gagniuc
2021-02-19 16:55 ` Tom Rini
2021-01-20 16:46 ` [PATCH v4 3/8] spl: fit: Pass FIT context via a structure pointer Alexandru Gagniuc
2021-02-19 16:55 ` Tom Rini
2021-01-20 16:46 ` [PATCH v4 4/8] spl: fit: Remove useless loop in spl_fit_get_image_name() Alexandru Gagniuc
2021-02-19 16:55 ` Tom Rini
2021-01-20 16:46 ` [PATCH v4 5/8] spl: fit: Only look up FIT configuration node once Alexandru Gagniuc
2021-02-19 16:55 ` Tom Rini
2021-01-20 16:46 ` [PATCH v4 6/8] image: Do not #if guard board_fit_image_post_process() prototype Alexandru Gagniuc
2021-02-19 16:55 ` Tom Rini
2021-01-20 16:46 ` [PATCH v4 7/8] spl: fit: Replace #ifdef blocks with more readable constructs Alexandru Gagniuc
2021-02-19 16:55 ` Tom Rini
2021-01-20 16:46 ` Alexandru Gagniuc [this message]
2021-02-19 16:55 ` [PATCH v4 8/8] spl: fit: Load devicetree when a Linux payload is found Tom Rini
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=20210120164656.1396639-9-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