Re: [PATCH u-boot-mvebu 1/5] tools: kwbimage: Fix invalid UART kwbimage v1 headersz

Stefan Roese
2023-03-24T08:22:44Z

On 3/23/23 20:57, Pali Rohár wrote:
> Armada 385 BootROM ignores low 7 bits of headersz when parsing kwbimage
> header of UART type, which effectively means that headersz is rounded down
> to multiply of 128 bytes. For all other image types BootROM reads and use
> all bits of headersz. Therefore fill into UART type of kwbimage v1 headersz
> aligned to 128 bytes.
>
> Fixes: 2b0980c24027 ("tools: kwbimage: Fill the real header size into the main header")
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
> tools/kwbimage.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 309657a5637b..177084adf825 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1231,6 +1231,16 @@ static size_t image_headersz_v1(int *hasext)
> if (count > 0)
> headersz += sizeof(struct register_set_hdr_v1) + 8 * count + 4;
>
> + /*
> + * For all images except UART, headersz stored in header itself should
> + * contains header size without padding. For UART image BootROM rounds
> + * down headersz to multiply of 128 bytes. Therefore align UART headersz
> + * to multiply of 128 bytes to ensure that remaining UART header bytes
> + * are not ignored by BootROM.
> + */
> + if (image_get_bootfrom() == IBR_HDR_UART_ID)
> + headersz = ALIGN(headersz, 128);
> +
> return headersz;
> }
>

Viele Grüße,
Stefan Roese

--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de