From patchwork Mon Sep 9 11:20:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 826579 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp1942706wrb; Mon, 9 Sep 2024 04:20:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwc7iM24kx35Om4FW3ylz9i4JECipynlF7mv2rxiUpEOkz9NzOM0WoVDzwaeutX4Tfs+PvEA==@linaro.org X-Google-Smtp-Source: AGHT+IGVBcFx7Ti0YtbK5dLFeUjEkBE6Qcoki3/Xz31BJeYIn8TxuKMkEMO3SWHfe2G5ICMcBf4C X-Received: by 2002:a5d:4447:0:b0:374:c4c2:5ad5 with SMTP id ffacd0b85a97d-37888847f85mr7059180f8f.27.1725880854966; Mon, 09 Sep 2024 04:20:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725880854; cv=none; d=google.com; s=arc-20240605; b=YZfYEcQT0lbm9fn2040W+vOsYuzZE2BHaq+NgG6Gk1nJsJlxKTpMwmhUNV+voeANMs gGSro5tGmbXztKHMyOiN4v1Qn6jwCDVONP1rjVqFfHgkHBBiymwW4MVedmMsdwUvqupM yh14wW71Vd1XFQ8cQPAfUTbjQ+mLXk/1iXkPItSsA1oC0FwqkzuF3WMr40m0XkWZwnti +FyDDWetE7IcVHFQHN1MS9nrAp50HcpBxmTGJmbpJ5lnLkcLvL9UeB+zqHNn/tzaFcpz o6qUGNRLSBSUJ6P2ooPvLl1li3eP+4ccbZr8OjwW/Tkf8A2ubz0yanqtHyScZ794MkQl 3h7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=VRcGvJCQNqeZ6W70LjicGMC+HksFaaDbdf7/JQwCckk=; fh=2L6lzFTxXJKn0sJyMiGOHr75auJVv+HSnsI1uFLsQPk=; b=AyPNobXB84a6OayOZrwpyq0VCzsm2ymembdIpP27JvFGJSS+GfGJpQRu+Bmy22u3jR WUY1OzsPZvoewtpPFCvTcIz2x3s/XQw5ZPdlwHPxz/CHXEi8aHTpnfLpkeECoS9mjXVg 8eWnqnti6j/xLxex1lOE6lmWkRvlLkGoDzhzHKqa0feObV0N9F0+PAiq3OPAxlG4YBSa 5EgatFZsV0yWTh4diT0VnQjIhqkvwmtknDaVqeuSmgBwmewvIe/xxB3t9fM9hcF2/+BY 5Mp4yfFh9JrQj2TmynXA2TGLRWYeAPGLKQ7TtWQ8s3BJrBrVj72qHnlMEIi+StguoOk9 LhVQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ffacd0b85a97d-378956dec4asi2076833f8f.977.2024.09.09.04.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 04:20:54 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B8AF088DC6; Mon, 9 Sep 2024 13:20:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id C1EEE88DBE; Mon, 9 Sep 2024 13:20:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id D3C5388CBD for ; Mon, 9 Sep 2024 13:20:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E3E2BFEC; Mon, 9 Sep 2024 04:21:07 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 85A6A3F73B; Mon, 9 Sep 2024 04:20:37 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Michal Simek , Ilias Apalodimas , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH v2 2/6] fwu: v1: do a version check for the metadata Date: Mon, 9 Sep 2024 16:50:17 +0530 Message-Id: <20240909112021.1962801-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240909112021.1962801-1-sughosh.ganu@linaro.org> References: <20240909112021.1962801-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 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 Do a sanity check that the version of the FWU metadata that has been read aligns with the version enabled in the image. This allows to indicate an early failure as part of the FWU module initialisation. Signed-off-by: Sughosh Ganu --- Changes since V1: None lib/fwu_updates/fwu_v1.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/fwu_updates/fwu_v1.c b/lib/fwu_updates/fwu_v1.c index efb8d51500..023e43728d 100644 --- a/lib/fwu_updates/fwu_v1.c +++ b/lib/fwu_updates/fwu_v1.c @@ -146,6 +146,7 @@ int fwu_init(void) { int ret; uint32_t mdata_size; + struct fwu_mdata mdata = {0}; fwu_get_mdata_size(&mdata_size); @@ -157,10 +158,16 @@ int fwu_init(void) * Now read the entire structure, both copies, and * validate that the copies. */ - ret = fwu_get_mdata(NULL); + ret = fwu_get_mdata(&mdata); if (ret) return ret; + if (mdata.version != 0x1) { + log_err("FWU metadata version %u. Expected value of %u\n", + mdata.version, FWU_MDATA_VERSION); + return -EINVAL; + } + fwu_data_init(); return 0;