From patchwork Thu Nov 11 15:59:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1554013 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Ju/L5G9a; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HqmfD0GwTz9s1l for ; Fri, 12 Nov 2021 03:00:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D577A83A61; Thu, 11 Nov 2021 17:00:33 +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="Ju/L5G9a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A98F783A34; Thu, 11 Nov 2021 17:00:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (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 7F91F83A4B for ; Thu, 11 Nov 2021 17:00:02 +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=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 251CA61261; Thu, 11 Nov 2021 16:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636646401; bh=umTGbiaB3gsCnJiJykwUyEuopHcHO4hbrNJlCijG7LE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ju/L5G9alN3+8iAX0TQ+bob9oG9854LKNkdRhOp25kzB6lKdS9zJIjFqSrb4MSpyu q/Lyh1P+YKnot6SuCweFGVuEDFZQ4Nhku9jBbanADksofxJb0vQEa4X1BNvwsmP52O z/oTO/4kCtvc0IBUCd6vUYaMWDYZTERLp358d96Nej3zJ5hHApak/Qg14MiOoFN3Zp uKBwJXBnxcytqX3WUZHV5ChzxRlm3IyJETIf6dGLxdg9Vs7u/elT/odMmItr1yJx6Q MPfuF+a4AAuctX5R3SeaV5+nsbejQoZ6IRHw3zv9/9pshJ1q06RGSxipSDvw/yRnJ3 gcdwslzV3NtvQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Stefan Roese Cc: u-boot@lists.denx.de, =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-marvell 3/5] arm: mvebu: Check that kwbimage blockid matches boot mode Date: Thu, 11 Nov 2021 16:59:51 +0100 Message-Id: <20211111155953.31526-4-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211111155953.31526-1-kabel@kernel.org> References: <20211111155953.31526-1-kabel@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Each boot mode has its own kwbimage specified by blockid. So check that kwbimage is valid by blockid. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Reviewed-by: Stefan Roese --- arch/arm/mach-mvebu/spl.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index deef6e76f3..662f430503 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -118,22 +118,36 @@ int spl_parse_board_header(struct spl_image_info *spl_image, * (including SPL content) which is not included in U-Boot image_header. */ if (mhdr->version != 1 || - ((mhdr->headersz_msb << 16) | mhdr->headersz_lsb) < sizeof(*mhdr) || - ( + ((mhdr->headersz_msb << 16) | mhdr->headersz_lsb) < sizeof(*mhdr)) { + printf("ERROR: Invalid kwbimage v1\n"); + return -EINVAL; + } + #ifdef CONFIG_SPL_SPI_FLASH_SUPPORT - mhdr->blockid != IBR_HDR_SPI_ID && + if (bootdev->boot_device == BOOT_DEVICE_SPI && + mhdr->blockid != IBR_HDR_SPI_ID) { + printf("ERROR: Wrong blockid in SPI kwbimage\n"); + return -EINVAL; + } #endif + #ifdef CONFIG_SPL_SATA - mhdr->blockid != IBR_HDR_SATA_ID && + if (bootdev->boot_device == BOOT_DEVICE_SATA && + mhdr->blockid != IBR_HDR_SATA_ID) { + printf("ERROR: Wrong blockid in SATA kwbimage\n"); + return -EINVAL; + } #endif + #ifdef CONFIG_SPL_MMC - mhdr->blockid != IBR_HDR_SDIO_ID && -#endif - 1 - )) { - printf("ERROR: Not valid SPI/NAND/SATA/SDIO kwbimage v1\n"); + if ((bootdev->boot_device == BOOT_DEVICE_MMC1 || + bootdev->boot_device == BOOT_DEVICE_MMC2 || + bootdev->boot_device == BOOT_DEVICE_MMC2_2) && + mhdr->blockid != IBR_HDR_SDIO_ID) { + printf("ERROR: Wrong blockid in SDIO kwbimage\n"); return -EINVAL; } +#endif spl_image->offset = mhdr->srcaddr;