From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web12.2881.1649399585999669084 for ; Thu, 07 Apr 2022 23:33:06 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaojie@byosoft.com.cn) Received: from DESKTOP6Q83COE ([223.167.21.157]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Fri, 08 Apr 2022 14:32:55 +0800 X-WM-Sender: gaojie@byosoft.com.cn X-Originating-IP: 223.167.21.157 X-WM-AuthFlag: YES X-WM-AuthUser: gaojie@byosoft.com.cn From: "Gao Jie" To: , References: <20220303085854.436-1-edhaya.chandran@arm.com> In-Reply-To: <20220303085854.436-1-edhaya.chandran@arm.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIDEvMV0gVUVGSS1TQ1Q6IFNjdFBrZzogVXBkYXRlZCB0aGUgY2hlY2sgZm9yIG1vbm90b25pYyBjb3VudCBhZnRlciByZXN0YXJ0?= Date: Fri, 8 Apr 2022 14:32:59 +0800 Message-ID: <001401d84b12$7d6f2480$784d6d80$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJ0ihTk7XWB4yzJ2qtWepNv4uvVPKutEA3Q Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Hi Eday, The patch looks good to me. Reviewed-by: Barton Gao Thanks Barton -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- =E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io = =E4=BB=A3=E8=A1=A8 G Edhaya Chandran =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2022=E5=B9=B43=E6=9C=883=E6=97=A5 16:= 59 =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io =E4=B8=BB=E9=A2=98: [edk2-devel] [PATCH 1/1] UEFI-SCT: SctPkg: Updated the = check for monotonic count after restart 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 hi= gh 32 bits and the low 32 bits. The low 32-bit value is volatile and is reset to zero on every system reset= . 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/show= _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/MiscBootService= s/BlackBoxTest/MiscBootServicesBBTestFunction.c b/uefi-sct/SctPkg/TestCase/= UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestF= unction.c index 5d631c16d58b..12703d46f98c 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/Black= BoxTest/MiscBootServicesBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/Black= BoxTest/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 c= ount. + //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