summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Armstrong <neil.armstrong@linaro.org>2024-10-17 16:44:43 +0200
committerMattijs Korpershoek <mkorpershoek@baylibre.com>2024-10-24 09:48:14 +0200
commitd5a85e8e95db57e350a092af62077917c7edd571 (patch)
tree0fc43127e3a5d45106f3f4878033e653bf27b118
parent8f8e646d790199f023f82b8100b6e160d510206d (diff)
image: android: do not boot XIP when kernel is compressed
When trying to boot an android boot image with a compressed kernel, if the kernel is used in-place because it was created with mkbootimg, the space will be too small to properly uncompress. Take in account the compressed state, and if compressed use the kernel_addr_r which should be big enough. Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Guillaume La Roque <glaroque@baylibre.com> Link: https://lore.kernel.org/r/20241017-topic-fastboot-fixes-mkbootimg-v2-2-c3927102d931@linaro.org Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
-rw-r--r--boot/image-android.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/boot/image-android.c b/boot/image-android.c
index bb5f4f84487..3adcc69a392 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -208,7 +208,8 @@ bool android_image_get_data(const void *boot_hdr, const void *vendor_boot_hdr,
return true;
}
-static ulong android_image_get_kernel_addr(struct andr_image_data *img_data)
+static ulong android_image_get_kernel_addr(struct andr_image_data *img_data,
+ ulong comp)
{
/*
* All the Android tools that generate a boot.img use this
@@ -221,8 +222,11 @@ static ulong android_image_get_kernel_addr(struct andr_image_data *img_data)
*
* Otherwise, we will return the actual value set by the user.
*/
- if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR)
- return img_data->kernel_ptr;
+ if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR) {
+ if (comp == IH_COMP_NONE)
+ return img_data->kernel_ptr;
+ return env_get_ulong("kernel_addr_r", 16, 0);
+ }
/*
* abootimg creates images where all load addresses are 0
@@ -258,11 +262,14 @@ int android_image_get_kernel(const void *hdr,
struct andr_image_data img_data = {0};
ulong kernel_addr;
const struct legacy_img_hdr *ihdr;
+ ulong comp;
if (!android_image_get_data(hdr, vendor_boot_img, &img_data))
return -EINVAL;
- kernel_addr = android_image_get_kernel_addr(&img_data);
+ comp = android_image_get_kcomp(hdr, vendor_boot_img);
+
+ kernel_addr = android_image_get_kernel_addr(&img_data, comp);
ihdr = (const struct legacy_img_hdr *)img_data.kernel_ptr;
/*
@@ -359,11 +366,14 @@ ulong android_image_get_kload(const void *hdr,
const void *vendor_boot_img)
{
struct andr_image_data img_data;
+ ulong comp;
if (!android_image_get_data(hdr, vendor_boot_img, &img_data))
return -EINVAL;
- return android_image_get_kernel_addr(&img_data);
+ comp = android_image_get_kcomp(hdr, vendor_boot_img);
+
+ return android_image_get_kernel_addr(&img_data, comp);
}
ulong android_image_get_kcomp(const void *hdr,