From mboxrd@z Thu Jan 1 00:00:00 1970 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 EEE80C74A5B for ; Thu, 23 Mar 2023 19:59:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE0E685D38; Thu, 23 Mar 2023 20:58:50 +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="fS2Fx8LO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5098F85757; Thu, 23 Mar 2023 20:58:40 +0100 (CET) Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::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 8119085D66 for ; Thu, 23 Mar 2023 20:58:34 +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 sin.source.kernel.org (Postfix) with ESMTPS id DCE35CE1E6C; Thu, 23 Mar 2023 19:58:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11FC1C4339B; Thu, 23 Mar 2023 19:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679601510; bh=HS9dwoE9CVhMH8+kDJ0U5nY7i9yXJ/wIH2VTHtfkyUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fS2Fx8LOz2Q+QhP2BSkoUVasxI0ybuynnWvN9MdudCEEM9cfIB0woBzCu/fRepPjM grKRYh/qYQruSgn3cxPXMz0S2S4V5OuL7rcY1NVSYIZ7sca+AimXesBNLtgr7rvsE7 MgIpK+PhWPuKj72ZPkOv8QrDyDT8/twSv7cpBVbMFFK4uuwnIjjXcEW39vV0cs64l0 GAL3dHry9ef8dMC0MHUjv8xUk4MTymUUrcWUgUnubUNEYDHNtRTMkA19O63DXpOvu/ yMZlVFZd55Kr3zbV6hslBytMfAkaXP8xEC5y2rKb/LjtidLlpRm5A6EpcVDqESWL0k FafPtM058xkhA== Received: by pali.im (Postfix) id 5B735E4A; Thu, 23 Mar 2023 20:58:27 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , Martin Rowe Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-mvebu 1/5] tools: kwbimage: Fix invalid UART kwbimage v1 headersz Date: Thu, 23 Mar 2023 20:57:51 +0100 Message-Id: <20230323195755.5131-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230323195755.5131-1-pali@kernel.org> References: <20230323195755.5131-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean 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 --- 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; } -- 2.20.1