From nobody Sun May 19 18:09:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103429+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103429+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1682106404; cv=none; d=zohomail.com; s=zohoarc; b=jIsid/RzlffjnjcC7ir9XyxGu/B/TSHfi+KJGyNVwLduKfgvVB+tOKxUiGUZ8wggG5NBYjVLlnpxXT/OzRVFQrnEeAn3uqr9ipa+kJl4uYmr+Em+KoDnUSMdavufG/9iEPTiX+85dtYoGH6hEC8eAhRcTOtrZndQYzq1jPPvnKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682106404; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=l+ijcTa5AnlAuiIREtRp2nSnyuhVUDZywM7J/DMWYh4=; b=cDNhV9ksXqAy8fT53asTbj49WlW8fJ850uZ01ZWhJaJ9PVKNt3dp6nrvb0lWVq2ks2QKv6orBFNRnmXTAo2a3JRBHdpSlYBpbrmXvrUqDRJ3VHF+/zpwoP/3FSwOAq1dN7cQD52fLHPdXTqmXtlbxh55q0ApBnKhUuPEoy0PoOk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103429+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682106404403136.19414051867568; Fri, 21 Apr 2023 12:46:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7xPkYY1788612xTBdgOZyJMr; Fri, 21 Apr 2023 12:46:44 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.22188.1682106402824704041 for ; Fri, 21 Apr 2023 12:46:43 -0700 X-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 29DBD150C; Fri, 21 Apr 2023 12:47:26 -0700 (PDT) X-Received: from beelzebub.ast.arm.com (abhsin07-ThinkStation-P720.austin.arm.com [10.118.30.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3D1223F793; Fri, 21 Apr 2023 12:46:42 -0700 (PDT) From: "Abhimanyu Singh" To: devel@edk2.groups.io Cc: Edhaya.Chandran@arm.com, gaojie@byosoft.com.cn, Carolyn.Gjertsen@amd.com, =Samer.El-Haj-Mahmoud@arm.com, stuart.yoder@arm.com, Samer El-Haj-Mahmoud Subject: [edk2-devel] [PATCH v1 1/1] uefi-sct/SctPkg: TCGMOR Platform Reset Check Test Date: Fri, 21 Apr 2023 14:46:38 -0500 Message-Id: <20230421194638.1778378-2-Abhi.Singh@arm.com> In-Reply-To: <20230421194638.1778378-1-Abhi.Singh@arm.com> References: <20230421194638.1778378-1-Abhi.Singh@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Abhi.Singh@arm.com X-Gm-Message-State: zah0DnwSDvIUkqxg0e8mZOBbx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682106404; bh=89BnRicoItKD1kZJWoIWPBRgifepH3z+TjMimH5g/So=; h=Cc:Date:From:Reply-To:Subject:To; b=AT1vO5sje6NQI3jXCp6/MPX1FqLzN4iOal41ACQsuRApkK7YUPekxVAuw2eqyt6yA/R VoClIckDM9Mw34H5YnGIkHIMTUdyWcOctZCCbL8cIpBesYTtt0213UsDopBbsgpAUI84C tqNqHZPcxkFtB6Vi/lLUnE3hGuKEb8JxRpo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682106405371100005 Content-Type: text/plain; charset="utf-8" -implement initial test infrastructure for TCG MOR test cases including updates to: CommonGenFramework.sh, UEFI_SCT.dsc, and Category.ini -add initial TCG MOR Platform Reset Check Test -Test Assertion that checks if the platform creates the MOR EFI variable as in the TCG Platform Reset Mitigation Spec -Test Assertion that sets MOR bit0 and checks if the platform clears the MOR bit0 upon reset Cc: G Edhaya Chandran Cc: Barton Gao Cc: Carolyn Gjertsen Cc: Samer El-Haj-Mahmoud Signed-off-by: Abhi Singh --- uefi-sct/SctPkg/CommonGenFramework.sh = | 1 + uefi-sct/SctPkg/Config/Data/Category.ini = | 7 + uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest/Guid= .c | 33 +++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest/Guid= .h | 36 +++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest/TCGM= ORBBTest.inf | 53 ++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest/TCGM= ORBBTestFunction.c | 312 ++++++++++++++++++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest/TCGM= ORBBTestMain.c | 109 +++++++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest/TCGM= ORBBTestMain.h | 89 ++++++ uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc = | 1 + 9 files changed, 641 insertions(+) diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh b/uefi-sct/SctPkg/Common= GenFramework.sh index fb9043b56bca..6e5cd301bdfa 100755 --- a/uefi-sct/SctPkg/CommonGenFramework.sh +++ b/uefi-sct/SctPkg/CommonGenFramework.sh @@ -226,6 +226,7 @@ then if [ -e $ProcessorType/RiscVBootProtocolBBTest.efi ]; then cp $ProcessorType/RiscVBootProtocolBBTest.efi $Framewor= k/Test/ > NUL fi + cp $ProcessorType/TCGMORBBTest.efi $Framework/= Test/ > NUL =20 # ********************************************* # Copy ENTS binary diff --git a/uefi-sct/SctPkg/Config/Data/Category.ini b/uefi-sct/SctPkg/Con= fig/Data/Category.ini index b34d35db9ac8..ead527a783ac 100644 --- a/uefi-sct/SctPkg/Config/Data/Category.ini +++ b/uefi-sct/SctPkg/Config/Data/Category.ini @@ -165,6 +165,13 @@ InterfaceGuid =3D AFF115FB-387B-4C18-8C41-6AFC7F03BB90 Name =3D RuntimeServicesTest\MiscRuntimeServicesTest Description =3D =20 +[Category Data] +Revision =3D 0x00010000 +CategoryGuid =3D 265E661D-D51E-454B-BBC9-665F46EC0A04 +InterfaceGuid =3D AFF115FB-387B-4C18-8C41-6AFC7F03BB90 +Name =3D RuntimeServicesTest\TCGMORTest +Description =3D Tests that check if Platform supports and correctly impl= ements TCG MOR + [Category Data] Revision =3D 0x00010000 CategoryGuid =3D 5B1B31A1-9562-11D2-8E3F-00A0C969723B diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/Black= BoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/B= lackBoxTest/Guid.c new file mode 100644 index 000000000000..8f967a2a62f2 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest= /Guid.c @@ -0,0 +1,33 @@ +/** @file + + Copyright 2006 - 2013 Unified EFI, Inc.
+ Copyright (c) 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ +/*++ + +Module Name: + + guid.c + +Abstract: + + GUIDs auto-generated for EFI test assertion. + +--*/ + +#include "Efi.h" +#include "Guid.h" + +EFI_GUID gTcgMorTestFunctionAssertionGuid001 =3D EFI_TEST_TCGMORTESTFUNCTI= ON_ASSERTION_001_GUID; + +EFI_GUID gTcgMorTestFunctionAssertionGuid002 =3D EFI_TEST_TCGMORTESTFUNCTI= ON_ASSERTION_002_GUID; diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/Black= BoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/B= lackBoxTest/Guid.h new file mode 100644 index 000000000000..90c60e476945 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest= /Guid.h @@ -0,0 +1,36 @@ +/** @file + + Copyright 2006 - 2016 Unified EFI, Inc.
+ Copyright (c) 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ +/*++ + +Module Name: + + guid.h + +Abstract: + + GUIDs auto-generated for EFI test assertion. + +--*/ + +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_001_GUID \ +{ 0xd1c31d5f, 0x944f, 0x434c, {0x88, 0x26, 0xa6, 0xfb, 0x00, 0xd4, 0xbb, 0= x97 }} + +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_002_GUID \ +{ 0xa6c191b1, 0x9bfb, 0x4231, {0xb9, 0x2d, 0x4e, 0xa2, 0x21, 0xf6, 0x4b, 0= x5d }} + +extern EFI_GUID gTcgMorTestFunctionAssertionGuid001; + +extern EFI_GUID gTcgMorTestFunctionAssertionGuid002; diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/Black= BoxTest/TCGMORBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeService= s/TCGMOR/BlackBoxTest/TCGMORBBTest.inf new file mode 100644 index 000000000000..8fb71a5fb883 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest= /TCGMORBBTest.inf @@ -0,0 +1,53 @@ +## @file +# +# Copyright 2006 - 2015 Unified EFI, Inc.
+# Copyright (c) 2013, Intel Corporation. All rights reserved.
+# Copyright (c) 2023, Arm Inc. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## +#/*++ +# +# Module Name: +# +# TCGMORBBTest.inf +# +# Abstract: +# +# Component description file for TCG MOR Test. +# +#--*/ + +[defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D TCGMORBBTest + FILE_GUID =3D ACA989CD-4AEE-45A3-B80F-E9A523BB7164 + MODULE_TYPE =3D UEFI_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeTestTCGMOR + +[sources.common] + TCGMORBBTestMain.c + TCGMORBBTestMain.h + TCGMORBBTestFunction.c + Guid.c + +[Packages] + MdePkg/MdePkg.dec + SctPkg/SctPkg.dec + SctPkg/UEFI/UEFI.dec + +[LibraryClasses] + UefiDriverEntryPoint + SctLib + EfiTestLib + +[Protocols] + gEfiTestRecoveryLibraryGuid diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/Black= BoxTest/TCGMORBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeS= ervices/TCGMOR/BlackBoxTest/TCGMORBBTestFunction.c new file mode 100644 index 000000000000..e924165919b1 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest= /TCGMORBBTestFunction.c @@ -0,0 +1,312 @@ +/** @file + + Copyright 2006 - 2016 Unified EFI, Inc.
+ Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at=20 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ +/*++ + +Module Name: + + TCGMORBBTestFunction.c + +Abstract: + + Function Test Cases for the TCG MOR and MORLock EFI Variables + +--*/ +#include "SctLib.h" +#include "TCGMORBBTestMain.h" + +#define RECOVER_BUFFER_SIZE 2048 + +#define TCG_MOR_VARIABLE_ATTRIBUTES 0x00000007 + + +/** + * Entry point for TCGMOR Function Test. + * @param This A pointer to the EFI_BB_TEST_PROTOCOL instance. + * @param ClientInterface A pointer to the interface to be tested. + * @param TestLevel Test "thoroughness" control. + * @param SupportHandle A handle containing support protocols. + * @return EFI_SUCCESS Successfully. + * @return Other value Something failed. + */ +EFI_STATUS +BBTestTCGMORFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; + EFI_STATUS Status; + + // + // Get the Standard Library Interface + // + Status =3D gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Get the Recovery Library Interface + // + Status =3D gtBS->HandleProtocol ( + SupportHandle, + &gEfiTestRecoveryLibraryGuid, + (VOID **) &RecoveryLib + ); + if (EFI_ERROR(Status)) { + StandardLib->RecordAssertion ( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.HandleProtocol - Handle recovery library", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + return Status; + } + + // + // TCGMOR EFI Variable and Platform Reset Checks + // + Status =3D TCGMORPlatformResetCheck (StandardLib, RecoveryLib); + + return EFI_SUCCESS; +} + + +/** + * MOR EFI variable is correctly created by platform and Set MOR bit0 is = cleared upon reset + * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL + * instance. + * @param RecoveryLib A pointer to EFI_TEST_RECOVERY_LIBRARY_PROTOCOL + * instance. + * @return EFI_SUCCESS Successfully. + * @return Other value Something failed. + */ +EFI_STATUS +TCGMORPlatformResetCheck ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib + ) +{ + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataSize; + UINTN MemoryOverwriteRequestControlData; + UINT32 Attributes; + RESET_DATA *ResetData; + UINT8 Buffer[RECOVER_BUFFER_SIZE]; + UINTN Size; + + + ResetData =3D (RESET_DATA *)Buffer; + // + // Read reset record + // + Status =3D RecoveryLib->ReadResetRecord ( + RecoveryLib, + &Size, + Buffer + ); + if (EFI_ERROR(Status) || (Size < sizeof(RESET_DATA))) { + goto INITIAL_RESET; + } else if (ResetData->Step =3D=3D 1) { + goto MOR_VARIABLE_CHECK; + } else if (ResetData->Step =3D=3D 2) { + goto MOR_BIT_CLEAR_ON_RESET; + + return EFI_LOAD_ERROR; + } + + +INITIAL_RESET: + // + // Perform initial plaform reset + // + ResetData->Step =3D 1; + ResetData->TplIndex =3D 0; + Status =3D RecoveryLib->WriteResetRecord ( + RecoveryLib, + sizeof (RESET_DATA), + (UINT8*)ResetData + ); + if (EFI_ERROR(Status)) { + StandardLib->RecordAssertion ( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"TestRecoveryLib - WriteResetRecord", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + return Status; + } + SctPrint (L"System will cold reset after 1 second..."); + gtBS->Stall (1000000); + gtRT->ResetSystem ( + EfiResetCold, + EFI_SUCCESS, + 0, + NULL + ); + + +MOR_VARIABLE_CHECK: + // + // Post system reset, Check if the MOR EFI var is correctly created by p= latform + // + + // Write reset record before the second reset (MOR_BIT_CLEAR_ON_RESET) + ResetData->Step =3D 2; + ResetData->TplIndex =3D 0; + Status =3D RecoveryLib->WriteResetRecord ( + RecoveryLib, + sizeof (RESET_DATA), + (UINT8*)ResetData + ); + if (EFI_ERROR(Status)) { + StandardLib->RecordAssertion ( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"TestRecoveryLib - WriteResetRecord", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + return Status; + } + + // GetVariable and check if the DataSize and Attributes are as expected + DataSize =3D sizeof(MemoryOverwriteRequestControlData); + Attributes =3D EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; + + Status =3D gtRT->GetVariable ( + L"MemoryOverwriteRequestControl", // VariableName + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + &MemoryOverwriteRequestControlData // Data + ); + if (EFI_ERROR (Status) || (DataSize !=3D 1) || (Attributes !=3D TCG_MOR_= VARIABLE_ATTRIBUTES)) { + Result =3D EFI_TEST_ASSERTION_FAILED; + } else { + Result =3D EFI_TEST_ASSERTION_PASSED; + } + + StandardLib->RecordAssertion ( + StandardLib, + Result, + gTcgMorTestFunctionAssertionGuid001, + L"MemoryOverwriteRequestControl - Validate that the MOR = Variable is correctly created by the platform", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Check if platform clears Bit0 upon system reset when Bit0 is initiall= y set + // + MemoryOverwriteRequestControlData |=3D 1<<0; + // Set Bit0 + Status =3D gtRT->SetVariable ( + L"MemoryOverwriteRequestControl", // VariableName + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid + Attributes, // Attributes + DataSize, // DataSize + &MemoryOverwriteRequestControlData // Data + ); + if (EFI_ERROR (Status) || !(MemoryOverwriteRequestControlData & 1<<0)) { + SctPrint (L"Unable to set MemoryOverwriteAction_BitValue Bit0!"); + return Status; + } + + // Cold reset system again for step 2 + SctPrint (L"System will cold reset after 1 second and test will be resum= ed after reboot."); + gtBS->Stall (1000000); + gtRT->ResetSystem ( + EfiResetCold, + EFI_SUCCESS, + 0, + NULL + ); + + +MOR_BIT_CLEAR_ON_RESET: + // + // Check if the platform has cleared the set MOR bit0 on reset + // + Status =3D RecoveryLib->WriteResetRecord ( + RecoveryLib, + 0, + (UINT8*)ResetData + ); + if (EFI_ERROR(Status)) { + return Status; + } + + DataSize =3D sizeof(MemoryOverwriteRequestControlData); + Attributes =3D EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; + + Status =3D gtRT->GetVariable ( + L"MemoryOverwriteRequestControl", // VariableName + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + &MemoryOverwriteRequestControlData // Data + ); + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlData & 1<<0)) { + Result =3D EFI_TEST_ASSERTION_FAILED; + } else { + Result =3D EFI_TEST_ASSERTION_PASSED; + } + + StandardLib->RecordAssertion ( + StandardLib, + Result, + gTcgMorTestFunctionAssertionGuid002, + L"MemoryOverwriteRequestControl - Validate that MOR bit0= is cleared after a cold reset when the bit0 is initially set", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status + ); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/Black= BoxTest/TCGMORBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServi= ces/TCGMOR/BlackBoxTest/TCGMORBBTestMain.c new file mode 100644 index 000000000000..8c128b15ced4 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest= /TCGMORBBTestMain.c @@ -0,0 +1,109 @@ +/** @file + + Copyright 2006 - 2016 Unified EFI, Inc.
+ Copyright (c) 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ +/*++ + +Module Name: + + TCG2MORTestMain.c + +Abstract: + + for EFI Driver TCG MOR Basic Test + +--*/ +#include "SctLib.h" +#include "TCGMORBBTestMain.h" + +EFI_GUID gEfiMemoryOverwriteControlDataGuid =3D MEMORY_ONLY_RESET_CONTROL_= GUID; + +EFI_BB_TEST_PROTOCOL_FIELD gEfiTCGMORTestProtField =3D { + TCG_MOR_TEST_REVISION, + EFI_TCG_MOR_TEST_GUID, + L"TCG MOR Test", + L"TCG MOR EFI Variable Functionality Test" +}; + +EFI_GUID gSupportProtocolGuid1[2] =3D { + EFI_STANDARD_TEST_LIBRARY_GUID, + EFI_NULL_GUID +}; + +EFI_BB_TEST_ENTRY_FIELD gLoadTCGMOREntryField[] =3D { + + { + EFI_TCG_MOR_TEST_ENTRY_GUID0101, + L"Test-TCG MOR Platform Reset Check", + L"Test for MemoryOverwriteRequestControl EFI variable in accordance wi= th TCG spec", + EFI_TEST_LEVEL_DEFAULT, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestTCGMORFunctionTest + }, + + + EFI_NULL_GUID +}; + +EFI_BB_TEST_PROTOCOL *gTCGMORTestProt; + +EFI_STATUS +EFIAPI +UnloadTCGMORTest ( + IN EFI_HANDLE ImageHandle + ); + +/** + * Creates/installs the BlackBox Interface and eminating Entry Point node= list. + * @param ImageHandle The test driver image handle + * @param SystemTable Pointer to System Table + * @return EFI_SUCCESS Indicates the interface was installed + * @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could = not be allocated + * @return EFI_INVALID_PARAMETER: One of the parameters has an invalid va= lue. + */ +EFI_STATUS +EFIAPI +InitializeTestTCGMOR ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + // + // initialize test utility lib + // + EfiInitializeTestLib (ImageHandle, SystemTable); + SctInitializeLib (ImageHandle, SystemTable); + + return EfiInitAndInstallBBTestInterface ( + &ImageHandle, + &gEfiTCGMORTestProtField, + gLoadTCGMOREntryField, + UnloadTCGMORTest, + &gTCGMORTestProt + ); +} + + + +EFI_STATUS +EFIAPI +UnloadTCGMORTest ( + IN EFI_HANDLE ImageHandle + ) +{ + return EfiUninstallAndFreeBBTestInterface ( + ImageHandle, + gTCGMORTestProt + ); +} diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/Black= BoxTest/TCGMORBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServi= ces/TCGMOR/BlackBoxTest/TCGMORBBTestMain.h new file mode 100644 index 000000000000..d38e07e38bbc --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest= /TCGMORBBTestMain.h @@ -0,0 +1,89 @@ +/** @file + + Copyright 2006 - 2017 Unified EFI, Inc.
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2023, Arm Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at=20 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ +/*++ + +Module Name: + + TCGMORTest.h + +Abstract: + + Test Driver of TCG MOR EFI variables from TCG spec + +--*/ + +#ifndef _TCG_MOR_BB_TEST_MAIN +#define _TCG_MOR_BB_TEST_MAIN + +#include "Efi.h" +#include "Guid.h" +#include +#include + +typedef struct _RESET_DATA { + UINTN Step; + UINTN TplIndex; + UINT32 RepeatTimes; +} RESET_DATA; + +#include EFI_TEST_PROTOCOL_DEFINITION(TestRecoveryLibrary) + +#define TCG_MOR_TEST_REVISION 0x00010000 + +#define EFI_TCG_MOR_TEST_GUID \ + { 0x265e661d, 0xd51e, 0x454b, {0xbb, 0xc9, 0x66, 0x5f, 0x46, 0xec, 0x0a,= 0x04 }} + +#define MEMORY_ONLY_RESET_CONTROL_GUID \ + { 0xE20939BE, 0x32D4, 0x41BE, {0xA1, 0x50, 0x89, 0x7F, 0x85, 0xD4, 0x98,= 0x29 }} + +extern EFI_GUID gEfiMemoryOverwriteControlDataGuid; + +EFI_STATUS +EFIAPI +InitializeTestTCGMOR ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +EFI_STATUS +EFIAPI +UnloadTCGMORTest ( + IN EFI_HANDLE ImageHandle + ); + +EFI_STATUS +BBTestTCGMORFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +TCGMORPlatformResetCheck ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib + ); + + +// ***********************************************************************= ***** +// Entry GUIDs for Test +// ***********************************************************************= ***** + +#define EFI_TCG_MOR_TEST_ENTRY_GUID0101 \ + { 0x2104436a, 0x77c8, 0x4514, {0xb7, 0xd7, 0xaa, 0x8a, 0x6b, 0xd1, 0x8d,= 0xa4 }} + +#endif diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc b/uefi-sct/SctPkg/UEFI/UEFI_= SCT.dsc index 155490fa39d3..adeec06ec2e8 100644 --- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc +++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc @@ -235,6 +235,7 @@ SctPkg/TestCase/UEFI/EFI/BootServices/ProtocolHandlerSe= rvices/BlackBoxTest/Proto SctPkg/TestCase/UEFI/EFI/RuntimeServices/MiscRuntimeServices/BlackBoxTest/= MiscRuntimeServicesBBTest.inf SctPkg/TestCase/UEFI/EFI/RuntimeServices/TimeServices/BlackBoxTest/TimeSer= vicesBBTest.inf SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/Var= iableServicesBBTest.inf +SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMOR/BlackBoxTest/TCGMORBBTest.= inf =20 SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutp= utBBTest.inf SctPkg/TestCase/UEFI/EFI/Protocol/Bis/BlackBoxTest/BisBBTest.inf --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103429): https://edk2.groups.io/g/devel/message/103429 Mute This Topic: https://groups.io/mt/98418488/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-