From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1DD6B74003A for ; Tue, 9 Apr 2024 04:45:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=L2w5bkiCAynT04fOBeahrSFLiN6v3ZH/G89OCWXQSMM=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1712637946; v=1; b=ZcLSYQ71JmqUibMDfuHh850zxCBp1PyHKtSGiB9fralYsaJhoUmAtsjyyGrb0Ot/p67B5O/q YcyXU4MB7HtESVHfxuE19jblBVcZpEw3w9qgmQBAFP8kvjHOCL3CDdBY2j+TsimUwDJv6g49GIe 6Nt1qNyj1qN2vuccg9YzKxw/RUm8w2PxZhSMPSc4C173oJr59yf/kaPj/9JDMLvyThDuwu1JEcH FarjQ/AfR7bvDGSRtID+wLeGJ/6va4/BCE74Q7FbGyKgr3fRDLrGp3/wczKrIUp4f5dNWbLq4ib /lnjNlTaMIrOPgSTDFGEnBuQcuh7KRawx0Nv7/HMRsx2w== X-Received: by 127.0.0.2 with SMTP id jzeAYY7687511xPkS3dUDuZN; Mon, 08 Apr 2024 21:45:46 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.129064.1712637946242886633 for ; Mon, 08 Apr 2024 21:45:46 -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 5009B1007; Mon, 8 Apr 2024 21:46:16 -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 95F713F64C; Mon, 8 Apr 2024 21:45:45 -0700 (PDT) From: "Abhimanyu Singh" To: devel@edk2.groups.io Cc: Abhi Singh , G Edhaya Chandran , Barton Gao , Carolyn Gjertsen , Abhi Singh , Stuart Yoder Subject: [edk2-devel] [PATCH v5 2/6] uefi-sct/SctPkg: TCG MOR SetVariable Test Date: Mon, 8 Apr 2024 23:45:19 -0500 Message-Id: <20240409044523.1033318-3-Abhi.Singh@arm.com> In-Reply-To: <20240409044523.1033318-1-Abhi.Singh@arm.com> References: <20240409044523.1033318-1-Abhi.Singh@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Mon, 08 Apr 2024 21:45:46 -0700 Resent-From: Abhi.Singh@arm.com Reply-To: devel@edk2.groups.io,Abhi.Singh@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: mQfAtalqxNswAEWzZ3kmO7b3x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=ZcLSYQ71; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io SCT spec: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4374 BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4419 -Implement MemoryOverwriteRequestControlSetVariable test cases -Add Assertions 5 and 6 from SCT spec -Add Test Case to MemoryOverwriteRequestFunctionTest Cc: G Edhaya Chandran Cc: Barton Gao Cc: Carolyn Gjertsen Signed-off-by: Abhi Singh Reviewed-by: Stuart Yoder --- uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/Guid.h | 10 ++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h | 7 + uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/Guid.c | 4 + uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 141 ++++++++++++= ++++++++ 4 files changed, 162 insertions(+) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOve= rwriteRequest/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Runti= meServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h index a3d87a3eb764..1d6d86ebed07 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/Guid.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/Guid.h @@ -37,6 +37,12 @@ Abstract: #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_004_GUID \=0D { 0x002519c6, 0x859f, 0x4d25, {0xb1, 0x36, 0xb2, 0xef, 0x61, 0xe5, 0xd9, 0= x6f }}=0D =0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_005_GUID \=0D +{ 0x13e97668, 0xe905, 0x452d, {0xa0, 0x72, 0x03, 0xde, 0xbf, 0x53, 0xdf, 0= xa2 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_006_GUID \=0D +{ 0x94811e97, 0x7513, 0x4099, {0xae, 0xb8, 0x5a, 0x7e, 0x7d, 0x50, 0xb4, 0= x99 }}=0D +=0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;=0D @@ -44,3 +50,7 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAss= ertionGuid002; extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid003;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid004;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid005;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid006;=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOve= rwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h b/uefi-sct= /SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBo= xTest/TCGMemoryOverwriteRequestBBTestMain.h index 45bd921ecca4..46c2c2faa388 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h @@ -85,6 +85,13 @@ TCGMemoryOverwriteRequestPlatformResetCheck ( IN RESET_DATA *ResetData=0D );=0D =0D +EFI_STATUS=0D +TCGMemoryOverwriteRequestControlSetVariable (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib,=0D + IN RESET_DATA *ResetData=0D + );=0D +=0D // ***********************************************************************= *****=0D // Entry GUIDs for Test=0D // ***********************************************************************= *****=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOve= rwriteRequest/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Runti= meServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c index 59c798a710f1..649de8196990 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/Guid.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/Guid.c @@ -35,3 +35,7 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionG= uid002 =3D EFI_TEST_TCGMO EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid003 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_003_GUID;=0D =0D EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid004 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_004_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid005 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_005_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid006 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_006_GUID;=0D diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOve= rwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c b/uefi= -sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/Bla= ckBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c index 8acad88b2365..2b9f5dd93a32 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteR= equest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c @@ -37,6 +37,8 @@ Abstract: =0D #define CONTROL_SET_VARIABLE_TEST 2=0D =0D +#define LOCK_SET_VARIABLE_TEST 3=0D +=0D =0D /**=0D * Entry point for TCG Platform Reset Attack Mitigation MemoryOverwrite E= FI Variables Function Test.=0D @@ -144,6 +146,16 @@ BBTestTCGMemoryOverwriteRequestFunctionTest ( }=0D CheckpointStepMatched =3D TRUE;=0D }=0D + if (ResetData->CheckpointStep =3D=3D CONTROL_SET_VARIABLE_TEST) {=0D + //=0D + // Test Checkpoint CONTROL_SET_VARIABLE_TEST=0D + //=0D + Status =3D TCGMemoryOverwriteRequestControlSetVariable (StandardLib, R= ecoveryLib, ResetData);=0D + if(EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D + CheckpointStepMatched =3D TRUE;=0D + }=0D =0D if (!CheckpointStepMatched) {=0D return EFI_INVALID_PARAMETER; // incase of invalid CheckpointStep, ret= urn EFI_INVALID_PARAMETER=0D @@ -449,3 +461,132 @@ MOR_BIT_CLEAR_ON_RESET: =0D return EFI_SUCCESS;=0D }=0D +=0D +=0D +/**=0D + * MemoryOverwriteRequestControl EFI variable SetVariable() requests with= a single invalid parameter=0D + * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL= =0D + * instance.=0D + * @param RecoveryLib A pointer to EFI_TEST_RECOVERY_LIBRARY_PROTOCOL= =0D + * instance.=0D + * @return EFI_SUCCESS Successfully.=0D + * @return Other value Something failed.=0D + */=0D +EFI_STATUS=0D +TCGMemoryOverwriteRequestControlSetVariable (=0D + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,=0D + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib,=0D + IN RESET_DATA *ResetData=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_TEST_ASSERTION Result;=0D + UINTN DataSize;=0D + UINT8 MemoryOverwriteRequestControlData;= =0D + UINT8 MemoryOverwriteRequestControlDataCa= ched;=0D + UINT32 Attributes;=0D +=0D + //=0D + // Write reset record to initiate checkpoint LOCK_SET_VARIABLE_TEST afte= r these assertions are complete=0D + //=0D + ResetData->Step =3D 0;=0D + ResetData->CheckpointStep =3D LOCK_SET_VARIABLE_TEST;=0D +=0D + Status =3D RecoveryLib->WriteResetRecord (=0D + RecoveryLib,=0D + sizeof (RESET_DATA),=0D + (UINT8*)ResetData=0D + );=0D + if (EFI_ERROR(Status)) {=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + EFI_TEST_ASSERTION_FAILED,=0D + gTestGenericFailureGuid,=0D + L"TestRecoveryLib - WriteResetRecord",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D + return Status;=0D + }=0D +=0D + //=0D + // MOR SetVariable() with invalid Attributes =3D=3D NV + BS returns EFI_= INVALID_PARAMETER and value is unchanged=0D + // SetVariable() with MOR bit 0 set and invalid Attributes =3D NV + BS=0D + //=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControl", // VariableName=0D + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid=0D + &Attributes, // Attributes=0D + &DataSize, // DataSize=0D + &MemoryOverwriteRequestControlData // Data=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + // caching variable for later comparison with the second GetVariable() v= alue=0D + MemoryOverwriteRequestControlDataCached =3D MemoryOverwriteRequestContro= lData;=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCE= SS;=0D + MemoryOverwriteRequestControlData |=3D MOR_BIT_HIGH << MOR_CLEAR_MEMORY_= BIT_OFFSET;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControl", // VariableName=0D + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid=0D + Attributes, // Attributes=0D + DataSize, // DataSize=0D + &MemoryOverwriteRequestControlData // Data=0D + );=0D + if (Status =3D=3D EFI_INVALID_PARAMETER) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid005,= =0D + L"MemoryOverwriteRequestControl - SetVariable() with Att= ributes =3D=3D NV returns EFI_INVALID_PARAMETER",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControl", // VariableName=0D + &gEfiMemoryOverwriteControlDataGuid, // VendorGuid=0D + &Attributes, // Attributes=0D + &DataSize, // DataSize=0D + &MemoryOverwriteRequestControlData // Data=0D + );=0D + // verifying that the MOR variable has not been modified with SetVariabl= e()=0D + if (MemoryOverwriteRequestControlDataCached =3D=3D MemoryOverwriteReques= tControlData) {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid006,= =0D + L"MemoryOverwriteRequestControl - SetVariable() with Att= ributes =3D=3D NV variable value remains unchanged",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117521): https://edk2.groups.io/g/devel/message/117521 Mute This Topic: https://groups.io/mt/105416470/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-