From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.8939.1646297937000999844 for ; Thu, 03 Mar 2022 00:58:57 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: edhaya.chandran@arm.com) 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 C60511480 for ; Thu, 3 Mar 2022 00:58:55 -0800 (PST) Received: from A76640.Arm.com (unknown [10.162.43.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 116B23F73D for ; Thu, 3 Mar 2022 00:58:54 -0800 (PST) From: "G Edhaya Chandran" To: devel@edk2.groups.io Subject: [PATCH 1/1] UEFI-SCT: SctPkg: Updated the check for monotonic count after restart Date: Thu, 3 Mar 2022 14:28:54 +0530 Message-Id: <20220303085854.436-1-edhaya.chandran@arm.com> X-Mailer: git-send-email 2.34.1.windows.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Updated the check for montonic count in the case of after restart >>From the UEFI Spec: "The platform=E2=80=99s monotonic counter is comprised of two parts: the = high 32 bits and the low 32 bits. The low 32-bit value is volatile and is reset to zero on every system res= et. It is increased by 1 on every call to GetNextMonotonicCount(). The high 32-bit value is nonvolatile and is increased by one on whenever the system resets or the low 32-bit counter overflows." It was found in one case where the higher 32-bit increased by 2 presumably due to the overflow of lower 32-bit counter. Update the logic to handle this case and to print a warning. Please find more details in the ticket: https://bugzilla.tianocore.org/sh= ow_bug.cgi?id=3D2774 Cc: Barton Gao Cc: Carolyn Gjertsen Cc: Heinrich Schuchardt Cc: Samer El-Haj-Mahmoud Signed-off-by: G Edhaya Chandran --- .../MiscBootServicesBBTestFunction.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServi= ces/BlackBoxTest/MiscBootServicesBBTestFunction.c b/uefi-sct/SctPkg/TestC= ase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesB= BTestFunction.c index 5d631c16d58b..12703d46f98c 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/Bla= ckBoxTest/MiscBootServicesBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/Bla= ckBoxTest/MiscBootServicesBBTestFunction.c @@ -1707,12 +1707,20 @@ GetNextMonotonicCountStep2: TplArray[Index] ); =20 - if (SctRShiftU64 (Count2, 32) =3D=3D SctRShiftU64 (Count, 32) + 1) { - AssertionType =3D EFI_TEST_ASSERTION_PASSED; - } else { - AssertionType =3D EFI_TEST_ASSERTION_FAILED; - } - StandardLib->RecordAssertion ( + //The new count of upper 32 bits must be atleast 1 more than the old= count. + //Pass case: new count is equal to old count + 1 + if (SctRShiftU64 (Count2, 32) <=3D SctRShiftU64 (Count, 32)) { + AssertionType =3D EFI_TEST_ASSERTION_FAILED; + } else { + //If new count is more that old count + 1, then print warning. + if (SctRShiftU64 (Count2, 32) > SctRShiftU64 (Count, 32) + 1) { + AssertionType =3D EFI_TEST_ASSERTION_WARNING; + } else { + //new count =3D=3D old count + 1 + AssertionType =3D EFI_TEST_ASSERTION_PASSED; + } + } + StandardLib->RecordAssertion ( StandardLib, AssertionType, Index=3D=3D0? \ --=20 2.17.1