tools: pblimage: fix image header verification function
PATCH 1/1 tools: pblimage: fix image header verification function
From: Hou Zhiqiang <[email protected]>
The Layerscape platforms have different RCW header value from FSL PowerPC platforms, the current image header verification callback is only working on PowerPC, it will fail on Layerscape, this patch is to fix this issue.
This is a historical problem and exposed by the following patch:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]
--- Makefile | 2 +- tools/pblimage.c | 10 ++++++++-- tools/pblimage.h | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-)
Makefile +1 -1
@@ -1410,7 +1410,7 @@ MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \ $(if $(KEYDIR),-k $(KEYDIR)) MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ - -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage + -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -A $(ARCH) -T pblimage ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy) UBOOT_BIN := u-boot-with-dtb.bin
tools/pblimage.c +8 -2
@@ -230,19 +230,25 @@ static int pblimage_verify_header(unsigned char *ptr, int image_size, struct image_tool_params *params) {struct pbl_header *pbl_hdr = (struct pbl_header *) ptr; +uint32_t rcwheader; + +if (params->arch ==IH_ARCH_ARM ) + rcwheader =RCW_ARM_HEADER ; +else + rcwheader =RCW_PPC_HEADER ;/* Only a few checks can be done: search for magic numbers */ if (ENDIANNESS =='l' ) {if (pbl_hdr->preamble !=reverse_byte (RCW_PREAMBLE ))return -FDT_ERR_BADSTRUCTURE ; -if (pbl_hdr->rcwheader !=reverse_byte (RCW_HEADER )) +if (pbl_hdr->rcwheader !=reverse_byte (rcwheader))return -FDT_ERR_BADSTRUCTURE ; }else {if (pbl_hdr->preamble !=RCW_PREAMBLE )return -FDT_ERR_BADSTRUCTURE ; -if (pbl_hdr->rcwheader !=RCW_HEADER ) +if (pbl_hdr->rcwheader != rcwheader)return -FDT_ERR_BADSTRUCTURE ; }return 0 ;
tools/pblimage.h +2 -1
@@ -8,7 +8,8 @@#define RCW_BYTES 64#define RCW_PREAMBLE 0xaa55aa55 -#define RCW_HEADER 0x010e0100 +#define RCW_ARM_HEADER 0x01ee0100 +#define RCW_PPC_HEADER 0x010e0100struct pbl_header {uint32_t preamble;
Signature · 1 line
2.25.1
Quoted 11 lines · On Thursday 17 February 2022 11:51:36 Zhiqiang Hou wrote:
From: Hou Zhiqiang <[email protected]>
The Layerscape platforms have different RCW header value from FSL PowerPC platforms, the current image header verification callback is only working on PowerPC, it will fail on Layerscape, this patch is to fix this issue.
This is a historical problem and exposed by the following patch:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]Signed-off-by Hou Zhiqiang <[email protected]>
Hello Tom! Could you look at this change? It should unblock applying my above patch.
Quoted 68 lines
--- Makefile | 2 +- tools/pblimage.c | 10 ++++++++-- tools/pblimage.h | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-)Makefile +1
-1@@ -1410,7 +1410,7 @@ MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \ $(if $(KEYDIR),-k $(KEYDIR)) MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ - -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage + -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -A $(ARCH) -T pblimage ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy) UBOOT_BIN := u-boot-with-dtb.bintools/pblimage.c +8
-2@@ -230,19 +230,25 @@ static int pblimage_verify_header(unsigned char *ptr, int image_size, struct image_tool_params *params) {struct pbl_header *pbl_hdr = (struct pbl_header *) ptr; +uint32_t rcwheader; + +if (params->arch ==IH_ARCH_ARM ) + rcwheader =RCW_ARM_HEADER ; +else + rcwheader =RCW_PPC_HEADER ;/* Only a few checks can be done: search for magic numbers */ if (ENDIANNESS =='l' ) {if (pbl_hdr->preamble !=reverse_byte (RCW_PREAMBLE ))return -FDT_ERR_BADSTRUCTURE ; -if (pbl_hdr->rcwheader !=reverse_byte (RCW_HEADER )) +if (pbl_hdr->rcwheader !=reverse_byte (rcwheader))return -FDT_ERR_BADSTRUCTURE ; }else {if (pbl_hdr->preamble !=RCW_PREAMBLE )return -FDT_ERR_BADSTRUCTURE ; -if (pbl_hdr->rcwheader !=RCW_HEADER ) +if (pbl_hdr->rcwheader != rcwheader)return -FDT_ERR_BADSTRUCTURE ; }return 0 ;tools/pblimage.h +2
-1@@ -8,7 +8,8 @@#define RCW_BYTES 64#define RCW_PREAMBLE 0xaa55aa55 -#define RCW_HEADER 0x010e0100 +#define RCW_ARM_HEADER 0x01ee0100 +#define RCW_PPC_HEADER 0x010e0100struct pbl_header {uint32_t preamble;Signature · 1 line
2.25.1
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Thursday 17 February 2022 11:51:36 Zhiqiang Hou wrote:
From: Hou Zhiqiang <[email protected]>
The Layerscape platforms have different RCW header value from FSL PowerPC platforms, the current image header verification callback is only working on PowerPC, it will fail on Layerscape, this patch is to fix this issue.
Quoted 6 lines
Quoted 4 lines
This is a historical problem and exposed by the following patch:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]Signed-off-by Hou Zhiqiang <[email protected]>Hello Tom! Could you look at this change? It should unblock applying my above patch.
Yes, I expect this to get picked up in the layerscape tree for the next PR there. Thanks.
Signature · 1 line
Tom