mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Christian Eggers <ceggers@arri.de>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] FIT: do not decompress ramdisks even if asked
Date: Fri, 25 Aug 2023 12:22:46 +0200	[thread overview]
Message-ID: <20230825102246.4189465-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230825102246.4189465-1-a.fatoum@pengutronix.de>

Linux will decompress its own ramdisk, so a well-formed ITS would
specify compression = "none", so the bootloader doesn't unpack the
ramdisk and the kernel takes care of it.

Some older versions of the Yocto kernel-fitimage.bbclass did populate
compression != "none" for ramdisks, so now barebox will fail to boot
the FIT images generated by them.

Fix this issue by not acting on the compression property when the image
in question is a ramdisk. We still print a warning, so users can fix
their ITS.

This aligns us with U-Boot's behavior[1].

[1]: https://git.yoctoproject.org/poky/commit/?h=kirkstone&id=2c58079222310
[2]: https://github.com/u-boot/u-boot/commit/bddd985734653c366c8da073650930

Fixes: 2ab6780b80e3 ("FIT: add first support for compressed images")
Reported-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/image-fit.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 9ceebde02931..0352dc5cbd0c 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -565,6 +565,7 @@ static void fit_uncompress_error_fn(char *x)
 }
 
 static int fit_handle_decompression(struct device_node *image,
+				    const char *type,
 				    const void **data,
 				    int *data_len)
 {
@@ -576,6 +577,12 @@ static int fit_handle_decompression(struct device_node *image,
 	if (!compression || !strcmp(compression, "none"))
 		return 0;
 
+	if (!strcmp(type, "ramdisk")) {
+		pr_warn("compression != \"none\" for ramdisks is deprecated,"
+			" please fix your .its file!\n");
+		return 0;
+	}
+
 	if (!IS_ENABLED(CONFIG_UNCOMPRESS)) {
 		pr_err("image has compression = \"%s\", but support not compiled in\n",
 		       compression);
@@ -652,7 +659,7 @@ int fit_open_image(struct fit_handle *handle, void *configuration,
 	if (ret < 0)
 		return ret;
 
-	ret = fit_handle_decompression(image, &data, &data_len);
+	ret = fit_handle_decompression(image, type, &data, &data_len);
 	if (ret)
 		return ret;
 
-- 
2.39.2




  reply	other threads:[~2023-08-25 10:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25 10:22 [PATCH 1/2] FIT: refactor compression handling into separate function Ahmad Fatoum
2023-08-25 10:22 ` Ahmad Fatoum [this message]
2023-08-25 10:45   ` [PATCH 2/2] FIT: do not decompress ramdisks even if asked Christian Eggers
2023-08-28  7:52 ` [PATCH 1/2] FIT: refactor compression handling into separate function Sascha Hauer

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=20230825102246.4189465-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=ceggers@arri.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