From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: eric.jin@intel.com) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by groups.io with SMTP; Wed, 31 Jul 2019 08:04:14 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jul 2019 08:04:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,330,1559545200"; d="scan'208";a="191262322" Received: from jjin9-mobl.ccr.corp.intel.com ([10.255.29.207]) by fmsmga001.fm.intel.com with ESMTP; 31 Jul 2019 08:04:12 -0700 From: "Eric Jin" To: devel@edk2.groups.io Cc: Sean Brogan , Bret Barkelew , Michael D Kinney , Jian J Wang , Hao A Wu Subject: [PATCH 2/3] MdeModulePkg/EsrtFmpDxe: Correct LastAttemptVersion algorithm in ESRT Date: Wed, 31 Jul 2019 23:03:37 +0800 Message-Id: <20190731150337.21036-1-eric.jin@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525 Update the ESRT entry with the last attempt status and last attempt version from the first FMP instance whose last attempt status is not SUCCESS. If all FMP instances are SUCCESS, then set last attempt version to the smallest value from all FMP instances Cc: Sean Brogan Cc: Bret Barkelew Cc: Michael D Kinney Cc: Jian J Wang Cc: Hao A Wu Signed-off-by: Eric Jin --- MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c index d48f205797..804c6d2ca3 100644 --- a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c +++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c @@ -179,20 +179,22 @@ CreateEsrtEntry ( // VERSION 3 supports last attempt values // if (FmpVersion >= 3) { - Entry->LastAttemptVersion = - MIN ( - FmpImageInfoBuf->LastAttemptVersion, - Entry->LastAttemptVersion - ); // // Update the ESRT entry with the last attempt status and last attempt // version from the first FMP instance whose last attempt status is not - // SUCCESS. + // SUCCESS. If all FMP instances are SUCCESS, then set version to the + // smallest value from all FMP instances. // if (Entry->LastAttemptStatus == LAST_ATTEMPT_STATUS_SUCCESS) { if (FmpImageInfoBuf->LastAttemptStatus != LAST_ATTEMPT_STATUS_SUCCESS) { Entry->LastAttemptStatus = FmpImageInfoBuf->LastAttemptStatus; Entry->LastAttemptVersion = FmpImageInfoBuf->LastAttemptVersion; + } else { + Entry->LastAttemptVersion = + MIN ( + FmpImageInfoBuf->LastAttemptVersion, + Entry->LastAttemptVersion + ); } } } -- 2.20.1.windows.1