All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: "Pali Rohár" <pali@kernel.org>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Chris Packham" <judge.packham@gmail.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH u-boot-marvell v2 18/20] tools: kwbimage/kwboot: Check ext field for non-zero value
Date: Thu, 13 Jan 2022 07:46:03 +0100	[thread overview]
Message-ID: <3f3079f6-b84e-3bd5-8a84-d129fbab58e1@denx.de> (raw)
In-Reply-To: <20220112172054.5961-19-pali@kernel.org>

On 1/12/22 18:20, Pali Rohár wrote:
> Despite the official specification, BootROM does not look at the lowest bit
> of ext field but rather checks if ext field is non-zero.
> 
> Moreover original Marvell doimage tool puts into the mhdr->ext field the
> number of extended headers, so basically it sets ext filed to non-zero
> value if some extended header is present.
> 
> Fix U-Boot dumpimage and kwboot tools to parse correctly also kwbimage
> files created by Marvell doimage tool, in the same way as the BootROM is
> doing it when booting these images.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Marek Behún <marek.behun@nic.cz>

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

Thanks,
Stefan

> ---
>   tools/kwbimage.c | 2 +-
>   tools/kwbimage.h | 6 +++---
>   tools/kwboot.c   | 4 ++--
>   3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index de7e9acf7fe5..92d163b6050e 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1948,7 +1948,7 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size,
>   	if (kwbimage_version(ptr) == 0) {
>   		struct main_hdr_v0 *mhdr = (struct main_hdr_v0 *)ptr;
>   
> -		if (mhdr->ext & 0x1) {
> +		if (mhdr->ext) {
>   			struct ext_hdr_v0 *ext_hdr = (void *)(mhdr + 1);
>   
>   			csum = image_checksum8(ext_hdr, sizeof(*ext_hdr) - 1);
> diff --git a/tools/kwbimage.h b/tools/kwbimage.h
> index c000cba4b8d1..9ebc7d72d363 100644
> --- a/tools/kwbimage.h
> +++ b/tools/kwbimage.h
> @@ -208,7 +208,7 @@ static inline size_t kwbheader_size(const void *header)
>   		const struct main_hdr_v0 *hdr = header;
>   
>   		return sizeof(*hdr) +
> -		       (hdr->ext & 0x1) ? sizeof(struct ext_hdr_v0) : 0;
> +		       hdr->ext ? sizeof(struct ext_hdr_v0) : 0;
>   	} else {
>   		const struct main_hdr_v1 *hdr = header;
>   
> @@ -252,7 +252,7 @@ static inline struct opt_hdr_v1 *opt_hdr_v1_first(void *img) {
>   		return NULL;
>   
>   	mhdr = img;
> -	if (mhdr->ext & 0x1)
> +	if (mhdr->ext)
>   		return (struct opt_hdr_v1 *)(mhdr + 1);
>   	else
>   		return NULL;
> @@ -272,7 +272,7 @@ static inline struct opt_hdr_v1 *_opt_hdr_v1_next(struct opt_hdr_v1 *cur)
>   
>   static inline struct opt_hdr_v1 *opt_hdr_v1_next(struct opt_hdr_v1 *cur)
>   {
> -	if (*opt_hdr_v1_ext(cur) & 0x1)
> +	if (*opt_hdr_v1_ext(cur))
>   		return _opt_hdr_v1_next(cur);
>   	else
>   		return NULL;
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index d22e6ea96a5c..c3d8ab654417 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -1398,7 +1398,7 @@ kwboot_add_bin_ohdr_v1(void *img, size_t *size, uint32_t binsz)
>   	uint32_t ohdrsz;
>   	uint8_t *prev_ext;
>   
> -	if (hdr->ext & 0x1) {
> +	if (hdr->ext) {
>   		for_each_opt_hdr_v1 (ohdr, img)
>   			if (opt_hdr_v1_next(ohdr) == NULL)
>   				break;
> @@ -1422,7 +1422,7 @@ kwboot_add_bin_ohdr_v1(void *img, size_t *size, uint32_t binsz)
>   	ohdrsz = sizeof(*ohdr) + 4 + 4 * num_args + binsz + 4;
>   	kwboot_img_grow_hdr(hdr, size, ohdrsz);
>   
> -	*prev_ext |= 1;
> +	*prev_ext = 1;
>   
>   	ohdr->headertype = OPT_HDR_V1_BINARY_TYPE;
>   	ohdr->headersz_msb = ohdrsz >> 16;
> 

Viele Grüße,
Stefan Roese

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

  reply	other threads:[~2022-01-13  6:46 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21 15:54 [PATCH u-boot-marvell 00/16] tools: kwbimage: Load address fixes Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 01/16] tools: kwbimage: Mark all local functions as static Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 02/16] tools: kwbimage: Deduplicate v1 regtype header finishing Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 03/16] tools: kwbimage: Fix generating image with multiple DATA_DELAY commands Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 04/16] tools: kwbimage: Preserve order of BINARY, DATA and " Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 05/16] arm: mvebu: Generate kwbimage.cfg with $(call cmd, ...) Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 06/16] tools: kwbimage: Add support for specifying LOAD_ADDRESS for BINARY command Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 07/16] tools: kwbimage: Check the return value of image_headersz_v1() Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 08/16] arm: mvebu: Correctly set LOAD_ADDRESS for U-Boot SPL binary in kwbimage Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 09/16] arm: mvebu: Enable BootROM output on A38x Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 10/16] tools: kwbimage: Add missing check for maximal value for DATA_DELAY Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 11/16] tools: kwbimage: Show binary image address in mkimage -l, in addition to size Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 12/16] tools: kwbimage: Dump kwbimage config file on '-p -1' option Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 13/16] tools: kwbimage: Do not cast const pointers to non-const pointers Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 14/16] tools: kwbimage/kwboot: Check ext field for non-zero value Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 15/16] tools: kwbimage: Extract main data image without -p arg for dumpimage Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 16/16] tools: kwbimage: Fix mkimage/dumpimage -l argument Pali Rohár
2022-01-12  7:26 ` [PATCH u-boot-marvell 00/16] tools: kwbimage: Load address fixes Stefan Roese
2022-01-12 10:41   ` Pali Rohár
2022-01-12 10:55     ` Stefan Roese
2022-01-12 11:06       ` Stefan Roese
2022-01-12 11:34         ` Pali Rohár
2022-01-12 13:53           ` Stefan Roese
2022-01-12 14:16             ` Pali Rohár
2022-01-12 15:06               ` Stefan Roese
2022-01-12 15:09                 ` Pali Rohár
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 00/20] " Pali Rohár
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 01/20] tools: kwbimage: Mark all local functions as static Pali Rohár
2022-01-13  6:30     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 02/20] tools: kwbimage: Deduplicate v1 regtype header finishing Pali Rohár
2022-01-13  6:31     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 03/20] tools: kwbimage: Fix generating image with multiple DATA_DELAY commands Pali Rohár
2022-01-13  6:31     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 04/20] tools: kwbimage: Preserve order of BINARY, DATA and " Pali Rohár
2022-01-13  6:32     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 05/20] arm: mvebu: Generate kwbimage.cfg with $(call cmd, ...) Pali Rohár
2022-01-13  6:32     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 06/20] tools: kwbimage: Add support for specifying CPU core Pali Rohár
2022-01-13  6:33     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 07/20] tools: kwbimage: Add support for specifying LOAD_ADDRESS for BINARY command Pali Rohár
2022-01-13  6:35     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 08/20] tools: kwbimage: Check the return value of image_headersz_v1() Pali Rohár
2022-01-13  6:35     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 09/20] tools: kwbimage: Check for maximal kwbimage header size Pali Rohár
2022-01-13  6:38     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 10/20] arm: mvebu: Set CPU for U-Boot SPL binary in kwbimage Pali Rohár
2022-01-13  6:39     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 11/20] arm: mvebu: Correctly set LOAD_ADDRESS " Pali Rohár
2022-01-13  6:40     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 12/20] tools: kwbimage: Enforce 128-bit boundary alignment only for Sheeva CPU Pali Rohár
2022-01-13  6:40     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 13/20] arm: mvebu: Enable BootROM output on A38x Pali Rohár
2022-01-13  6:42     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 14/20] tools: kwbimage: Add missing check for maximal value for DATA_DELAY Pali Rohár
2022-01-13  6:43     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 15/20] tools: kwbimage: Show binary image offset in mkimage -l, in addition to size Pali Rohár
2022-01-13  6:43     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 16/20] tools: kwbimage: Dump kwbimage config file on '-p -1' option Pali Rohár
2022-01-13  6:44     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 17/20] tools: kwbimage: Do not cast const pointers to non-const pointers Pali Rohár
2022-01-13  6:45     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 18/20] tools: kwbimage/kwboot: Check ext field for non-zero value Pali Rohár
2022-01-13  6:46     ` Stefan Roese [this message]
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 19/20] tools: kwbimage: Extract main data image without -p arg for dumpimage Pali Rohár
2022-01-13  6:46     ` Stefan Roese
2022-01-12 17:20   ` [PATCH u-boot-marvell v2 20/20] tools: kwbimage: Fix mkimage/dumpimage -l argument Pali Rohár
2022-01-13  6:46     ` Stefan Roese
2022-01-14 15:40   ` [PATCH u-boot-marvell v2 00/20] tools: kwbimage: Load address fixes Stefan Roese

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=3f3079f6-b84e-3bd5-8a84-d129fbab58e1@denx.de \
    --to=sr@denx.de \
    --cc=judge.packham@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --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 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.