From patchwork Fri Aug 30 11:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 823982 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c1:0:b0:367:895a:4699 with SMTP id p1csp730725wrs; Fri, 30 Aug 2024 04:41:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWrbxJNop9soLsNx6+ybmXHRcVmZmY2lvYU0nKy5f7GqWLhUG31BIybpSxS6FL1PQ7zQBvkWA==@linaro.org X-Google-Smtp-Source: AGHT+IFFAm95DcbUQQ2ul/agGlGZXVOtddygIznm1UVTy8V28IbRntO5E2vfyQSid/SME4DioqOg X-Received: by 2002:a05:651c:551:b0:2f5:ce9:14df with SMTP id 38308e7fff4ca-2f6108a77ebmr42559751fa.40.1725018104397; Fri, 30 Aug 2024 04:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725018104; cv=none; d=google.com; s=arc-20240605; b=YT8fS3O4PoFvPChdU1L2auPepZdmaIjI8vKhhXpwsg92vZAq3nWGdCaBANVzsx0oId S6SUQXBgrHFqCle3cbnN7jf04dZqarqNVitOMtn/DfSH3Wo5aXJo+GkCTTt3bqyUq3cj 5rhM8lOa2BnutaA3DfnUhJy5JMPSKgclE3RTFKuKlWl4Pb9ptgMCRUUUGje03feNHRkl ybeF4k9F1uANQRcE3QIwzT+Tue6X/xPjvJbXUmbKqdnS9M8RGzvT9um/+rcwxsJxIHNR YZ+obAsfbiWTbF3hkUZboFBz9Bok3rzSwfXC8jgccNdhsbDBSOhpULpowamimhx52uuX U9/g== 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=FpIKIeCZGHYlnsHoGK847YUmob1BkfmGgpoznuxSDG4=; fh=2L6lzFTxXJKn0sJyMiGOHr75auJVv+HSnsI1uFLsQPk=; b=UdNFXvLi3EGWMM+R44cQfttYW8hpVQWN80gjvrsohxCanaNxJefz1WCwqxq1Y8K4sS p+ou7Sze8EY6R9os2WYFxwQxBQTWQd+fmFB5qFkhER9J+wIpyrRbqknGFSL/tbcko0Tl DGQ4cVcrBGuRxzURdkO0SEmGIPUd8A8rBIyszAUfjZXJrgkibFroa/TFeUfCqE445xNr +mhuhLQupasVct+iILJdNxkyCVCBgMfpC/irVz8OERlBKhm+nnpvDv1yFqueBxMa3TUe eMS8IDwgOAxTOBJbHJDzu7Jaz5gVFRY8bqBKcfVVDVU9xdVmjHiL/qLO38LwKiMTLyPT VMYw==; 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 4fb4d7f45d1cf-5c226ce604asi2780239a12.341.2024.08.30.04.41.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 04:41:44 -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 2DDF088B1F; Fri, 30 Aug 2024 13:41:21 +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 73C4A88B40; Fri, 30 Aug 2024 13:41:19 +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_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 7BFD688A10 for ; Fri, 30 Aug 2024 13:41:17 +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 25100339; Fri, 30 Aug 2024 04:41:43 -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 148023F66E; Fri, 30 Aug 2024 04:41:14 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Michal Simek , Ilias Apalodimas , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH 3/6] fwu: v1: do a version check for the metadata Date: Fri, 30 Aug 2024 17:10:54 +0530 Message-Id: <20240830114057.891069-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240830114057.891069-1-sughosh.ganu@linaro.org> References: <20240830114057.891069-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 --- 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;