All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] image: android: fix ramdisk default address
@ 2025-05-21 21:26 Eddie Kovsky
  2025-05-30  9:15 ` Mattijs Korpershoek
  2025-05-31 14:22 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Eddie Kovsky @ 2025-05-21 21:26 UTC (permalink / raw)
  To: u-boot
  Cc: Enric Balletbo i Serra, Aaron Kling, Julien Masson,
	Mattijs Korpershoek, Michael Walle, Neil Armstrong, Nicolas Belin,
	Roman Stratiienko, Simon Glass, Tom Rini

Commit 21e7fa0e3ac5 ("image: android: handle ramdisk default address")
changed the default behavior for header versions less than or equal to 2.

The ramdisk address (img_data.ramdisk_ptr) is only assigned to *rd_data
if the physical load address (img_data.ramdisk_addr) is equal to 0 or
the Android default ramdisk address.

    /* Ramdisk can be used in-place, use current ptr */
    if (img_data.ramdisk_addr == 0 ||
            img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) {
        *rd_data = img_data.ramdisk_ptr;
    } else {
        ramdisk_ptr = img_data.ramdisk_addr;
        *rd_data = ramdisk_ptr;
        memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr,
                img_data.ramdisk_size);
    }

When the img_data.ramdisk_addr and the img_data.kernel_addr are the same
*rd_data needs to be assigned to the ramdisk address (ramdisk_ptr), not
the physical address (ramdisk_addr).

As a result of the current behavior, we can no longer boot a kernel on
the Renesas R-Car S4 board.

Add an additional check to the if clause so that the ramdisk address is
assigned when the kernel address and the ramdisk address are the same,
restoring the previous default behavior.

Fixes: 21e7fa0e3ac5 ("image: android: handle ramdisk default address")
Signed-off-by: Eddie Kovsky <ekovsky@redhat.com>
---

 boot/image-android.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/boot/image-android.c b/boot/image-android.c
index 1746b0189008..459cdb8456c4 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -488,7 +488,8 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
 	} else {
 		/* Ramdisk can be used in-place, use current ptr */
 		if (img_data.ramdisk_addr == 0 ||
-		    img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) {
+		    img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR ||
+		    img_data.ramdisk_addr == img_data.kernel_addr) {
 			*rd_data = img_data.ramdisk_ptr;
 		} else {
 			ramdisk_ptr = img_data.ramdisk_addr;
-- 
2.49.0


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

* Re: [PATCH] image: android: fix ramdisk default address
  2025-05-21 21:26 [PATCH] image: android: fix ramdisk default address Eddie Kovsky
@ 2025-05-30  9:15 ` Mattijs Korpershoek
  2025-05-31 14:22 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Mattijs Korpershoek @ 2025-05-30  9:15 UTC (permalink / raw)
  To: Eddie Kovsky, u-boot
  Cc: Enric Balletbo i Serra, Aaron Kling, Julien Masson,
	Mattijs Korpershoek, Michael Walle, Neil Armstrong, Nicolas Belin,
	Roman Stratiienko, Simon Glass, Tom Rini

Hi Eddie,

Thank you for the patch.

On mer., mai 21, 2025 at 15:26, Eddie Kovsky <ekovsky@redhat.com> wrote:

> Commit 21e7fa0e3ac5 ("image: android: handle ramdisk default address")
> changed the default behavior for header versions less than or equal to 2.
>
> The ramdisk address (img_data.ramdisk_ptr) is only assigned to *rd_data
> if the physical load address (img_data.ramdisk_addr) is equal to 0 or
> the Android default ramdisk address.
>
>     /* Ramdisk can be used in-place, use current ptr */
>     if (img_data.ramdisk_addr == 0 ||
>             img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) {
>         *rd_data = img_data.ramdisk_ptr;
>     } else {
>         ramdisk_ptr = img_data.ramdisk_addr;
>         *rd_data = ramdisk_ptr;
>         memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr,
>                 img_data.ramdisk_size);
>     }
>
> When the img_data.ramdisk_addr and the img_data.kernel_addr are the same
> *rd_data needs to be assigned to the ramdisk address (ramdisk_ptr), not
> the physical address (ramdisk_addr).
>
> As a result of the current behavior, we can no longer boot a kernel on
> the Renesas R-Car S4 board.
>
> Add an additional check to the if clause so that the ramdisk address is
> assigned when the kernel address and the ramdisk address are the same,
> restoring the previous default behavior.
>
> Fixes: 21e7fa0e3ac5 ("image: android: handle ramdisk default address")
> Signed-off-by: Eddie Kovsky <ekovsky@redhat.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

Boot tested on Khadas VIM3 using khadas-vim3_android_defconfig

Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org> # khadas vim3

> ---
>
>  boot/image-android.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/boot/image-android.c b/boot/image-android.c
> index 1746b0189008..459cdb8456c4 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -488,7 +488,8 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
>  	} else {
>  		/* Ramdisk can be used in-place, use current ptr */
>  		if (img_data.ramdisk_addr == 0 ||
> -		    img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) {
> +		    img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR ||
> +		    img_data.ramdisk_addr == img_data.kernel_addr) {
>  			*rd_data = img_data.ramdisk_ptr;
>  		} else {
>  			ramdisk_ptr = img_data.ramdisk_addr;
> -- 
> 2.49.0

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

* Re: [PATCH] image: android: fix ramdisk default address
  2025-05-21 21:26 [PATCH] image: android: fix ramdisk default address Eddie Kovsky
  2025-05-30  9:15 ` Mattijs Korpershoek
@ 2025-05-31 14:22 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2025-05-31 14:22 UTC (permalink / raw)
  To: u-boot, Eddie Kovsky
  Cc: Enric Balletbo i Serra, Aaron Kling, Julien Masson,
	Mattijs Korpershoek, Michael Walle, Neil Armstrong, Nicolas Belin,
	Roman Stratiienko, Simon Glass

On Wed, 21 May 2025 15:26:59 -0600, Eddie Kovsky wrote:

> Commit 21e7fa0e3ac5 ("image: android: handle ramdisk default address")
> changed the default behavior for header versions less than or equal to 2.
> 
> The ramdisk address (img_data.ramdisk_ptr) is only assigned to *rd_data
> if the physical load address (img_data.ramdisk_addr) is equal to 0 or
> the Android default ramdisk address.
> 
> [...]

Applied to u-boot/master, thanks!

[1/1] image: android: fix ramdisk default address
      commit: b22a276f039f818d5564bec6637071cfc8a7e432
-- 
Tom



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

end of thread, other threads:[~2025-05-31 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 21:26 [PATCH] image: android: fix ramdisk default address Eddie Kovsky
2025-05-30  9:15 ` Mattijs Korpershoek
2025-05-31 14:22 ` 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.