Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FF01C433EF for ; Fri, 25 Feb 2022 20:36:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14D6D838B9; Fri, 25 Feb 2022 21:36:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="toZwWd+B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 83D9283BA7; Fri, 25 Feb 2022 21:36:12 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 29328836D2 for ; Fri, 25 Feb 2022 21:36:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 490F961957; Fri, 25 Feb 2022 20:36:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E02FC340E7; Fri, 25 Feb 2022 20:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645821366; bh=nipYUURH5gLzYd85Irh250qQNBnjD/VAnWB4HP5WbWY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=toZwWd+B+PSQ2c00RfiF+fUAIUGVHakoR+kqv2aGAosFZqxL60Yf+xA7wAMdb7Kka G+if+p7SMaYY8+uubzgbblly9ads7keneV3hNri/FLfMAtVUIc/vpqrDtSpKSSJV1H /LwttlOxhnS0zil+sRlX0amF2LkJl3OOAOeiBtXHf7Ay6l4vR225PXi389EMeR/4Hg 0r4VFuPvDHmb1skxBe47odOXbO1icTzlhlPunc4TWnwRFZF8FBUJviVnm5zutmU82q 3fyasna0Z2RWbkbb5GDpHku3F4YUUPjp6hc8ldpVaijrNvz4i3SEJwLUQgR/dhhGlt I+l05a1w4kl2Q== Received: by pali.im (Postfix) id 906AA7EF; Fri, 25 Feb 2022 21:36:03 +0100 (CET) Date: Fri, 25 Feb 2022 21:36:03 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: trini@konsulko.com Cc: Zhiqiang Hou , u-boot@lists.denx.de, sjg@chromium.org, marek.behun@nic.cz, priyanka.jain@nxp.com Subject: Re: [PATCH] tools: pblimage: fix image header verification function Message-ID: <20220225203603.2dedmjnnkmrekw2g@pali> References: <20220217035136.398564-1-Zhiqiang.Hou@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220217035136.398564-1-Zhiqiang.Hou@nxp.com> User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Thursday 17 February 2022 11:51:36 Zhiqiang Hou wrote: > From: Hou Zhiqiang > > 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/20220114173443.9877-1-pali@kernel.org > > Signed-off-by: Hou Zhiqiang Hello Tom! Could you look at this change? It should unblock applying my above patch. > --- > Makefile | 2 +- > tools/pblimage.c | 10 ++++++++-- > tools/pblimage.h | 3 ++- > 3 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/Makefile b/Makefile > index 4b152249ca..3c2bc9741c 100644 > --- a/Makefile > +++ b/Makefile > @@ -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 > diff --git a/tools/pblimage.c b/tools/pblimage.c > index 3c823e96cf..bd639c276f 100644 > --- a/tools/pblimage.c > +++ b/tools/pblimage.c > @@ -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; > diff --git a/tools/pblimage.h b/tools/pblimage.h > index 81c5492926..0222e8067b 100644 > --- a/tools/pblimage.h > +++ b/tools/pblimage.h > @@ -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 0x010e0100 > > struct pbl_header { > uint32_t preamble; > -- > 2.25.1 >