From patchwork Mon Sep 9 11:20:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 826582 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp1942926wrb; Mon, 9 Sep 2024 04:21:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX9Wf3uT5MjmDyo1HHhjglAs5wCvJScvhMHLd2ZDA6dqo9X7A3Lej/WUxfClYDBcfX34KsiJA==@linaro.org X-Google-Smtp-Source: AGHT+IGbpByfWvf1e1uYKKRGeUIDgSD4s7HFmtV4KEKPE6F7bWUP47OtcsjVwjJduhJcS2SQm1I+ X-Received: by 2002:a05:600c:1c99:b0:42c:b4a2:a1aa with SMTP id 5b1f17b1804b1-42cb4a2a3a4mr29288095e9.17.1725880883604; Mon, 09 Sep 2024 04:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725880883; cv=none; d=google.com; s=arc-20240605; b=CQqw+1uc2TV6OQRwFsx78W+Mevi62yW4/ow6G6f+47Ru7HInT9ToL2tUlMjrM29YuS QYOO3CAeTHPQQvDMLH/mWVafE0p14QuMImyNtkmylO3b7j/Cc00AOyLtRd76k64x6ARH 6eVLyxa+eHDliCh2f7JQrkFGHvo49NmZj/Q0am2m4VawE+RyOlZZdLhaw4YGTcIFip7i CY52DKY4o2f6uy7ebUc1qR5dKyLcRcDw/8iaV10I2ORtLZRTFEz5Y7kw9jJrDsT84OYi FqoO4YJugN2GYnJG1TNY0xeJzSMOwkK6FiRh4OgvvINd6Hocxy2MI891lIjrHKEYzFUl SBrA== 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=b+rz4FqrBcGHEwj9uREOogNXrvIimAezMiu2jvCGdBU=; fh=2L6lzFTxXJKn0sJyMiGOHr75auJVv+HSnsI1uFLsQPk=; b=GMk8VXbNl6lI1G790/N1AmLZZLZJM9NO5vIoc9TgLvVkaEbWVNWVspodoxZpmtZXM1 pMVMGnn9kZpxNBbTXUc8AP4AHSwTVbDkIpQ72SNZ7xTSzDSWPgVec162NtHJxYerkVdj crmOXPFMXu9mA4doZDK4dK9i7NTZ31mDH+w0nB2kZr0Ww/15dbWycVuR0AwrHWb/uFle tHFcmrgFKDGGZaZ2Km+wF6I6/KsB8W1iS7tUsaaV615KE+tL8R8tVC63LpTlObziK9Gp W7zH5qRBr5e16sY0rNrTfkDcS7U/+0Nriad0cW8DJAmXbXOqEwdjrcoOzk86Ldl7lZ+7 xzlg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 5b1f17b1804b1-42cb2274082si17978985e9.169.2024.09.09.04.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 04:21:23 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 D703B88DC1; Mon, 9 Sep 2024 13:20:49 +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 CED9D88DBF; Mon, 9 Sep 2024 13:20:48 +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 D9B6E88CBD for ; Mon, 9 Sep 2024 13:20:46 +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 E4C84FEC; Mon, 9 Sep 2024 04:21:14 -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 864F03F73B; Mon, 9 Sep 2024 04:20:44 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Michal Simek , Ilias Apalodimas , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH v2 5/6] fwu: do not allow capsule processing on exceeding Trial Counter threshold Date: Mon, 9 Sep 2024 16:50:20 +0530 Message-Id: <20240909112021.1962801-6-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 When in Trial State, the platform keeps a count of the number of times it has booted in the Trial State. Once the threshold of the maximum allowed count exceeds, the platform reverts to boot from a different bank on subsequent boot, thus coming out of the Trial State. It is expected that all the updated images would be accepted or rejected while the platform is in Trial State. Put in checks so that it is not possible to apply an empty capsule once the max Trial Count exceeds. Signed-off-by: Sughosh Ganu Tested-by: Michal Simek --- Changes since V1: None lib/fwu_updates/fwu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c index a94a769a2b..7f085a0211 100644 --- a/lib/fwu_updates/fwu.c +++ b/lib/fwu_updates/fwu.c @@ -113,6 +113,8 @@ static int fwu_trial_count_update(void) ret = fwu_revert_boot_index(); if (ret) log_err("Unable to revert active_index\n"); + + trial_counter_update(NULL); ret = 1; } else { log_info("Trial State count: attempt %d out of %d\n", @@ -762,8 +764,8 @@ static int fwu_boottime_checks(void) return 0; in_trial = in_trial_state(); - if (!in_trial || (ret = fwu_trial_count_update()) > 0) - ret = trial_counter_update(NULL); + + ret = in_trial ? fwu_trial_count_update() : trial_counter_update(NULL); if (!ret) boottime_check = 1;