public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: George Chan via B4 Relay <devnull+gchan9527.gmail.com@kernel.org>,
	Tom Rini <trini@konsulko.com>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>,
	Simon Glass <sjg@chromium.org>,
	Casey Connolly <casey.connolly@linaro.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Sumit Garg <sumit.garg@kernel.org>,
	Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io,
	George Chan <gchan9527@gmail.com>
Subject: Re: [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr
Date: Wed, 07 May 2025 09:47:24 +0200	[thread overview]
Message-ID: <87zffoamlv.fsf@kernel.org> (raw)
In-Reply-To: <20250505-android-boot-v2-1-92dcb5bf59c8@gmail.com>

Hi George,

Thank you for the patch.
I really prefer this solution to the one proposed in v1.

I have tested this on Khadas VIM3 board (using khadas-vim3_android_defconfig)

I have a couple of small remarks below.

On lun., mai 05, 2025 at 17:17, George Chan via B4 Relay <devnull+gchan9527.gmail.com@kernel.org> wrote:

> From: George Chan <gchan9527@gmail.com>
>
> Some androidboot image have invalid kernel/ramdisk load addr,
> force to ignore those value and use loadaddr instead.

Can we please elaborate a bit more in the commit message?
We have not explained/justified why repacking a boot image with proper
kernel ramdisk/load addr is not possible.

Is the following an acceptable justification for you?
"""
Since it's not always possible to change the load addr by repacking
the boot.img (due to AVB signature mismatch/<or_another_justification>),
we need a way to use kernel_addr_r and ramdisk_addr_r.
"""

Feel free to reformulate the above.

>
> Suggested-by: Casey Connolly <casey.connolly@linaro.org>
> Signed-off-by: George Chan <gchan9527@gmail.com>
> ---
>  boot/Kconfig         | 6 ++++++
>  boot/image-android.c | 9 ++++++---
>  2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/boot/Kconfig b/boot/Kconfig
> index fb37d912bc9..4bdac384181 100644
> --- a/boot/Kconfig
> +++ b/boot/Kconfig
> @@ -11,6 +11,12 @@ config ANDROID_BOOT_IMAGE
>  	  This enables support for booting images which use the Android
>  	  image format header.
>  
> +config ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR
> +	bool "Android Boot Image ignore addr"
> +	default n
> +	help
> +	  This ignore kernel/ramdisk load addr specified in androidboot header.

Please add a bit more context here, checkpatch.pl reports issues:
$ ./scripts/checkpatch.pl --u-boot --git master..HEAD

WARNING: please write a paragraph that describes the config symbol fully
#27: FILE: boot/Kconfig:14:
+config ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR

> +
>  config TIMESTAMP
>  	bool "Show image date and time when displaying image information"
>  	default y if CMD_DATE
> diff --git a/boot/image-android.c b/boot/image-android.c
> index 1746b018900..7b8eb6a4f64 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -268,7 +268,8 @@ 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) {
> +	if (img_data->kernel_addr  == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR ||
> +		IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR)) {

Please fix indentation, should be:

+	if (img_data->kernel_addr  == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR ||
+	    IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR)) {

(checkpatch.pl reports this)

>  		if (comp == IH_COMP_NONE)
>  			return img_data->kernel_ptr;
>  		return env_get_ulong("kernel_addr_r", 16, 0);
> @@ -464,7 +465,8 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
>  	 */
>  	if (img_data.header_version > 2) {
>  		/* Ramdisk can't be used in-place, copy it to ramdisk_addr_r */
> -		if (img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) {
> +		if (img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR ||
> +			(IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR))) {

Same here. Also, can we please drop the leading parenthesis (IS_ENABLED(
-> IS_ENABLED( to be consistent with the previous code change?

>  			ramdisk_ptr = env_get_ulong("ramdisk_addr_r", 16, 0);
>  			if (!ramdisk_ptr) {
>  				printf("Invalid ramdisk_addr_r to copy ramdisk into\n");
> @@ -488,7 +490,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 ||
> +			(IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR))) {

Same here. Also, can we please drop the leading parenthesis (IS_ENABLED(
-> IS_ENABLED( to be consistent with the previous code change?

>  			*rd_data = img_data.ramdisk_ptr;
>  		} else {
>  			ramdisk_ptr = img_data.ramdisk_addr;
>
> -- 
> 2.43.0

  parent reply	other threads:[~2025-05-07  7:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05  9:17 [PATCH v2 0/5] u-boot chain-loading LineageOS bootimg George Chan via B4 Relay
2025-05-05  9:17 ` [PATCH v2 1/5] boot/image-android: Workaround kernel/ramdisk invalid addr George Chan via B4 Relay
2025-05-05 12:22   ` Neil Armstrong
2025-05-07  9:30     ` Mattijs Korpershoek
2025-05-07  7:47   ` Mattijs Korpershoek [this message]
2025-05-08  4:22     ` george chan
2025-05-09 14:22       ` Mattijs Korpershoek
2025-05-05  9:17 ` [PATCH v2 2/5] mach-snapdragon: Enhance android image handling memory footprint George Chan via B4 Relay
2025-05-05 12:23   ` Neil Armstrong
2025-05-05  9:17 ` [PATCH v2 3/5] fdt_support: Add support for extra var for bootargs George Chan via B4 Relay
2025-05-05  9:17 ` [PATCH v2 4/5] qcom-phone.env: Example of new env var legacy_os_boot_param George Chan via B4 Relay
2025-05-05  9:17 ` [PATCH v2 5/5] mach-snapdragon: Enable workaround of ignoring androidboot addr George Chan via B4 Relay
2025-05-05 12:23   ` Neil Armstrong

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=87zffoamlv.fsf@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=casey.connolly@linaro.org \
    --cc=devnull+gchan9527.gmail.com@kernel.org \
    --cc=gchan9527@gmail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=rayagonda.kokatanur@broadcom.com \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@kernel.org \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --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