All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] image: android: Automatically detect more compression types
@ 2021-07-01 18:33 Stephan Gerhold
  2021-07-16 15:52 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Stephan Gerhold @ 2021-07-01 18:33 UTC (permalink / raw)
  To: u-boot; +Cc: Stephan Gerhold, Simon Glass

At the moment android_image_get_kcomp() can automatically detect
LZ4 compressed kernels and the compression specified in uImages.
However, especially on ARM64 Linux is often compressed with GZIP.
Attempting to boot an Android image with a GZIP compressed kernel
image currently results in a very strange crash, e.g.

  Starting kernel ...
  "Synchronous Abort" handler, esr 0x02000000
   ...
  Code: 5555d555 55555d55 555f5555 5d555d55 (00088b1f)

Note the 1f8b, which are the "magic" bytes for GZIP images.

U-Boot already has the image_decomp_type() function that checks for
the magic bytes of bzip2, gzip, lzma and lzo. It's easy to make use
of it here to increase the chance that we do the right thing and the
user does not become confused with strange crashes.

This allows booting Android boot images that contain GZIP-compressed
kernel images.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---

 common/image-android.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/image-android.c b/common/image-android.c
index d07b0e0f09..1fbbbba1eb 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -164,7 +164,7 @@ ulong android_image_get_kcomp(const struct andr_img_hdr *hdr)
 	else if (get_unaligned_le32(p) == LZ4F_MAGIC)
 		return IH_COMP_LZ4;
 	else
-		return IH_COMP_NONE;
+		return image_decomp_type(p, sizeof(u32));
 }
 
 int android_image_get_ramdisk(const struct andr_img_hdr *hdr,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] image: android: Automatically detect more compression types
  2021-07-01 18:33 [PATCH] image: android: Automatically detect more compression types Stephan Gerhold
@ 2021-07-16 15:52 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2021-07-16 15:52 UTC (permalink / raw)
  To: Stephan Gerhold; +Cc: u-boot, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]

On Thu, Jul 01, 2021 at 08:33:16PM +0200, Stephan Gerhold wrote:

> At the moment android_image_get_kcomp() can automatically detect
> LZ4 compressed kernels and the compression specified in uImages.
> However, especially on ARM64 Linux is often compressed with GZIP.
> Attempting to boot an Android image with a GZIP compressed kernel
> image currently results in a very strange crash, e.g.
> 
>   Starting kernel ...
>   "Synchronous Abort" handler, esr 0x02000000
>    ...
>   Code: 5555d555 55555d55 555f5555 5d555d55 (00088b1f)
> 
> Note the 1f8b, which are the "magic" bytes for GZIP images.
> 
> U-Boot already has the image_decomp_type() function that checks for
> the magic bytes of bzip2, gzip, lzma and lzo. It's easy to make use
> of it here to increase the chance that we do the right thing and the
> user does not become confused with strange crashes.
> 
> This allows booting Android boot images that contain GZIP-compressed
> kernel images.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-16 15:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 18:33 [PATCH] image: android: Automatically detect more compression types Stephan Gerhold
2021-07-16 15:52 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.