From patchwork Fri Aug 30 11:40:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 823985 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c1:0:b0:367:895a:4699 with SMTP id p1csp730897wrs; Fri, 30 Aug 2024 04:42:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV5haXBMlRdsV5mE++xCQ3uJK4U0eUArtz+NWH3JT3DFm1YG/W1epRJaiOV9FA4uDttxcUe8g==@linaro.org X-Google-Smtp-Source: AGHT+IHZmaswAdcHMymwBIh27ytonz+tXH54oGTwynl4mz2M4HlDyux9aY5oZkw1dEQyX30UQ6w7 X-Received: by 2002:a17:907:7254:b0:a7a:ab8a:386 with SMTP id a640c23a62f3a-a897fab75d9mr468077166b.63.1725018134797; Fri, 30 Aug 2024 04:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725018134; cv=none; d=google.com; s=arc-20240605; b=DPgvmqt5wP45tQU/ZKpiyvg56xA0ACQZEyR8szOK7murwFSFdm+WfFZIBPgN6mFJNT YN3ig7TeTSjzIhYuRDQ2zQsvvylDty2QyosBimYcCnukulI+xBtwN9P87L297u1TvQhd iH9/ttUWsdfmUd/kqwJaRowMkj/ksIf2GyLKxP1pF/6ZJw7F3Y0IfOZ7WD5wrTX+5fHc pXCXqvFKEEx193LByhWSvdXtDFX2OCZfwOdo+/oklbmVVjDBU9zB1zjnYcjw2zJtytSv 75/lCtlXc+MyOloL8p8h6ROUtNHm2hf0xtBH5JGkrbcgyp762IDFnWzrLKmECiiU2y1T ghuw== 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=+X4vqvF/psgQKFvtpoJWbCRn0bCCEBo+3Paq81cuLu0=; fh=2L6lzFTxXJKn0sJyMiGOHr75auJVv+HSnsI1uFLsQPk=; b=d5HE3d6Nw9kWZlElRUsl3F+B+GA5o8NN1IJUh9rrMWgyvDVQjpJmtgunqVSiCWWeV4 3SjzV/5thKGbqXVWw49+zcb2CwBrjuuvyPtMtPgySV9IJuVkQQjkAgzdL4Xu2hiAIImj XtlijGwvAPcPTJE1Pr1Lmwtt+DGfysIDozZA6lnV2FEMw4v5Ff1tPE53jZxM7COrPIi3 UMjN9tsTpEj9rLIs5ZWLPR+Qsz3qyoX/vvYswXVUQ0iatYLeoRZD2qtOLYE7817tiKAo Fc7DgEbJE4eIY+KiyHHNrYur2sXMl7Obsw11dE2l/s0KuGIBESrdfqYqkB8TLmVBLPks 47Zg==; 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 a640c23a62f3a-a89891cc503si279470866b.743.2024.08.30.04.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 04:42:14 -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 623DD88A8B; Fri, 30 Aug 2024 13:41:27 +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 6331688A92; Fri, 30 Aug 2024 13:41:26 +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 69BFF88A10 for ; Fri, 30 Aug 2024 13:41:24 +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 2BD31339; Fri, 30 Aug 2024 04:41:50 -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 1BBDC3F66E; Fri, 30 Aug 2024 04:41:21 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Michal Simek , Ilias Apalodimas , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH 6/6] fwu: do not allow capsule processing on exceeding Trial Counter threshold Date: Fri, 30 Aug 2024 17:10:57 +0530 Message-Id: <20240830114057.891069-7-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 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 --- 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;