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 04B4AD802F3 for ; Tue, 30 Jan 2024 23:23:50 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=nj/ieo35lTlrvhqdpwOSPThDbcUZZmKt8vY7Jf16BNs=; 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:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1706657029; v=1; b=pAtkl0j5mFgb52hVBa7EqI98sMJlDFu1hhGycUjX2uNAWybQ+G2Q0UNf81KY5yMHpPkjNQ/U c6RrxSE8kuOU3iEgEUKbQmbwCQlxfX5ly8s+i2GLQAp7dTJWneX97dY0KKElaugDzbxy145/mJH +9vTLyCbp4CfDNbsX5YOlJ7g= X-Received: by 127.0.0.2 with SMTP id 4xgeYY7687511xTt4BYTBWH0; Tue, 30 Jan 2024 15:23:49 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1915.1706657028970509514 for ; Tue, 30 Jan 2024 15:23:49 -0800 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 1CF0716A3; Tue, 30 Jan 2024 15:24:32 -0800 (PST) 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 83E1C3F5A1; Tue, 30 Jan 2024 15:23:48 -0800 (PST) From: "Abhimanyu Singh" To: devel@edk2.groups.io Cc: Abhi Singh , G Edhaya Chandran , Barton Gao , Carolyn Gjertsen Subject: [edk2-devel] [PATCH v2 5/7] uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test Date: Tue, 30 Jan 2024 17:23:30 -0600 Message-Id: <20240130232332.235302-6-Abhi.Singh@arm.com> In-Reply-To: <20240130232332.235302-1-Abhi.Singh@arm.com> References: <20240130232332.235302-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 Reply-To: devel@edk2.groups.io,Abhi.Singh@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: GYYzhgEu3hoZBpWACj134BMSx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=pAtkl0j5; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) SCT spec: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4374 BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4419 -Implement MemoryOverwriteRequestControlLock Locked No Key State test cases -Add Assertions 23 - 32 from SCT spec -Add Test Case to MemoryOverwriteRequestFunctionTest Cc: G Edhaya Chandran Cc: Barton Gao Cc: Carolyn Gjertsen Signed-off-by: Abhi Singh Change-Id: I298f8a0f55376b00233c9ee9c6b0262dc8869ccb --- uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/Guid.h | 50 +++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h | 11 + uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/Guid.c | 20 + uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 457 ++++++++++++= ++++++++ 4 files changed, 538 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 daf17793c094..023e7a37322c 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 @@ -91,6 +91,36 @@ Abstract: #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_022_GUID \=0D { 0x490d7b39, 0xcad4, 0x4e8c, {0xb1, 0x5d, 0x63, 0xd2, 0x0c, 0xb3, 0xe9, 0= x45 }}=0D =0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_023_GUID \=0D +{ 0x397394ae, 0xce01, 0x4350, {0xa2, 0x0c, 0xe1, 0xb3, 0xe8, 0x74, 0xdc, 0= x01 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_024_GUID \=0D +{ 0x9cf27a60, 0x94b5, 0x4e2e, {0xb3, 0x2b, 0x51, 0x0f, 0x24, 0x7a, 0x80, 0= xd7 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_025_GUID \=0D +{ 0x766dc008, 0x2a88, 0x4eed, {0x91, 0x95, 0x46, 0x92, 0xdc, 0xcc, 0x1d, 0= xf6 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_026_GUID \=0D +{ 0x5f66c8e5, 0x1bf8, 0x4af4, {0x86, 0x45, 0xf4, 0x93, 0xa0, 0xee, 0x26, 0= x88 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_027_GUID \=0D +{ 0x1064f6ce, 0xb307, 0x4981, {0xac, 0x8f, 0xe5, 0xca, 0x20, 0x6c, 0x1b, 0= x8b }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_028_GUID \=0D +{ 0x40f2c4e9, 0xe937, 0x426e, {0x98, 0xc5, 0x62, 0xca, 0x23, 0x68, 0x52, 0= xd0 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_029_GUID \=0D +{ 0x6d5dcb4d, 0xe008, 0x41cc, {0x98, 0x32, 0xdf, 0xa8, 0x38, 0xb1, 0xb6, 0= x02 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_030_GUID \=0D +{ 0x29b81ee0, 0x368d, 0x447c, {0x9e, 0xd0, 0xa5, 0xfe, 0xd7, 0x02, 0x65, 0= x7b }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_031_GUID \=0D +{ 0xe88b22ce, 0x3de6, 0x49b0, {0xb2, 0x46, 0x9e, 0x35, 0x98, 0x2b, 0x9b, 0= x1c }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_032_GUID \=0D +{ 0xc8894201, 0x7a3a, 0x47d4, {0xa8, 0x8d, 0xdf, 0x4b, 0x03, 0xff, 0xde, 0= x4f }}=0D +=0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;=0D @@ -134,3 +164,23 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunction= AssertionGuid020; extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid022;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid023;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid024;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid025;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid026;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid027;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid028;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid029;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032;=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 15eedc60f19d..94ed476f86ad 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 @@ -51,6 +51,10 @@ typedef struct _RESET_DATA { #define MOR_LOCK_DATA_UNLOCKED 0x0=0D #define MOR_LOCK_DATA_LOCKED_WITHOUT_KEY 0x1=0D =0D +#define MOR_LOCK_WITH_KEY_SIZE 8=0D +=0D +#define MOR_LOCK_TEST_KEY 0x11111111=0D +=0D =0D //=0D // TEST GUID for TCG Platform Reset Attack Mitigation MemoryOverwriteReque= st (MOR) Test=0D @@ -107,6 +111,13 @@ TCGMemoryOverwriteRequestControlLockUnlockedState ( IN RESET_DATA *ResetData=0D );=0D =0D +EFI_STATUS=0D +TCGMemoryOverwriteRequestControlLockLockedNoKeyState (=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 c41a611d3a4e..11d49306059d 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 @@ -71,3 +71,23 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertion= Guid020 =3D EFI_TEST_TCGMO EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_021_GUID;=0D =0D EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid022 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_022_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid023 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_023_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid024 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_024_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid025 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_025_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid026 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_026_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid027 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_027_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid028 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_028_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid029 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_029_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_030_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_031_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_032_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 bd90d00e3263..5787faabd683 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 @@ -43,6 +43,8 @@ Abstract: =0D #define LOCK_NO_KEY_STATE_TEST 5=0D =0D +#define LOCK_WITH_KEY_STATE_TEST 6=0D +=0D =0D /**=0D * Entry point for TCG Platform Reset Attack Mitigation MemoryOverwrite E= FI Variables Function Test.=0D @@ -159,6 +161,15 @@ BBTestTCGMemoryOverwriteRequestFunctionTest ( return Status;=0D }=0D }=0D + if (ResetData->CheckpointStep =3D=3D LOCK_NO_KEY_STATE_TEST) {=0D + //=0D + // Test Checkpoint LOCK_NO_KEY_STATE_TEST=0D + //=0D + TCGMemoryOverwriteRequestControlLockLockedNoKeyState (StandardLib, Rec= overyLib, ResetData);=0D + if(EFI_ERROR(Status)) {=0D + return Status;=0D + }=0D + }=0D //=0D // After all Checkpoints have run=0D //=0D @@ -1177,3 +1188,449 @@ MORLOCK_UNLOCKED_STATE: =0D return EFI_SUCCESS;=0D }=0D +=0D +=0D +/**=0D + * MemoryOverwriteRequestControlLock in locked-without-key state test=0D + * When unlocked, a valid SetVariable() with Data value 0x01 must return = EFI_SUCCESS=0D + * and the lock value must be 0x01, value cannot change till the system i= s cold reset=0D + *=0D + * When locked-without-key, SetVariable() with Data =3D 0x01, 0x00, or 0x= 11111111 (key)=0D + * must return EFI_ACCESS_DENIED and value must still equal 0x01=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 + * @param ResetData A pointer to the ResetData Buffer which is used = throughout=0D + * the test=0D + * @return EFI_SUCCESS Successfully.=0D + * @return Other value Something failed.=0D + */=0D +EFI_STATUS=0D +TCGMemoryOverwriteRequestControlLockLockedNoKeyState (=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 + UINTN MemoryOverwriteControlLockKeyValue;= =0D + UINT8 MemoryOverwriteRequestControlLockDa= ta;=0D + UINT8 MemoryOverwriteRequestControlData;= =0D + UINT8 MemoryOverwriteRequestControlDataCa= ched;=0D + UINT32 Attributes;=0D +=0D + if (ResetData->Step =3D=3D 0) {=0D + goto INITIAL_RESET;=0D + } else if (ResetData->Step =3D=3D 1) {=0D + goto MORLOCK_LOCKED_STATE;=0D + }=0D +=0D +INITIAL_RESET:=0D + //=0D + // Reset MORLOCK variable by performing a cold reset=0D + //=0D + ResetData->Step =3D 1;=0D + ResetData->CheckpointStep =3D LOCK_NO_KEY_STATE_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 + SctPrint (L"System will cold reset after 1 second...");=0D + gtBS->Stall (1000000);=0D + gtRT->ResetSystem (=0D + EfiResetCold,=0D + EFI_SUCCESS,=0D + 0,=0D + NULL=0D + );=0D +=0D +MORLOCK_LOCKED_STATE:=0D + //change checkpoint to next function=0D + ResetData->Step =3D 0;=0D + ResetData->CheckpointStep =3D LOCK_WITH_KEY_STATE_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 + // After Cold Reset, MORLOCK SetVariable() with value 0x01 must return E= FI_SUCCESS=0D + // and MORLOCK GetVariable() value must now be MOR_LOCK_DATA_LOCKED_WITH= OUT_KEY=0D + //=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (Status =3D=3D EFI_SUCCESS) {=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021,= =0D + L"MemoryOverwriteRequestControlLock - Setting to locked-= without-key when unlocked returns EFI_SUCCESS",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITHOUT_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid022,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is now = locked-without-key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once locked-without-key, MORLOCK SetVariable() with value 0x00 must r= eturn EFI_ACCESS_DENIED=0D + // and MORLOCK GetVariable() value must still be 0x01=0D + //=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_UNLOCKED;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid023,= =0D + L"MemoryOverwriteRequestControlLock - Setting to unlocke= d when locked-without-key returns EFI_ACCESS_DENIED",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITHOUT_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid024,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-without-key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once locked-without-key, MORLOCK SetVariable() with value 0x01 must r= eturn EFI_ACCESS_DENIED=0D + // and MORLOCK GetVariable() value must still be 0x01=0D + //=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid025,= =0D + L"MemoryOverwriteRequestControlLock - Setting to locked-= without-key when already locked-without-key returns EFI_ACCESS_DENIED",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITHOUT_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid026,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-without-key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once locked-without-key, MORLOCK SetVariable() with 8 byte key =3D 0x= 11111111 must return EFI_ACCESS_DENIED=0D + // and MORLOCK GetVariable() value must still be 0x01=0D + //=0D + DataSize =3D MOR_LOCK_WITH_KEY_SIZE;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteControlLockKeyValue =3D MOR_LOCK_TEST_KEY;=0D +=0D + Status =3D gtRT->SetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + Attributes, // Attribut= es=0D + DataSize, // DataSize= =0D + &MemoryOverwriteControlLockKeyValue // Data=0D + );=0D + if (Status =3D=3D EFI_ACCESS_DENIED) {=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid027,= =0D + L"MemoryOverwriteRequestControlLock - Setting to locked-= with-key when locked-without-key returns EFI_ACCESS_DENIED",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=0D + Status =3D gtRT->GetVariable (=0D + L"MemoryOverwriteRequestControlLock", // Variable= Name=0D + &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGu= id=0D + &Attributes, // Attribut= es=0D + &DataSize, // DataSize= =0D + &MemoryOverwriteRequestControlLockData // Data=0D + );=0D + if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData !=3D MO= R_LOCK_DATA_LOCKED_WITHOUT_KEY)) {=0D + Result =3D EFI_TEST_ASSERTION_FAILED;=0D + } else {=0D + Result =3D EFI_TEST_ASSERTION_PASSED;=0D + }=0D +=0D + StandardLib->RecordAssertion (=0D + StandardLib,=0D + Result,=0D + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid028,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-without-key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once locked-without-key, MOR SetVariable() call to set MOR bit 0 must= return EFI_ACCESS_DENIED=0D + // and MOR value must not change=0D + //=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + // getting current MOR bit 0 value that will be used to check that the v= ariable is unchanged=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 MOR and then setting bit 0=0D + MemoryOverwriteRequestControlDataCached =3D MemoryOverwriteRequestContro= lData;=0D + MemoryOverwriteRequestControlData |=3D MOR_BIT_HIGH << MOR_CLEAR_MEMORY_= BIT_OFFSET;=0D +=0D + DataSize =3D sizeof(MemoryOverwriteRequestControlData);=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D +=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_ACCESS_DENIED) {=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid029,= =0D + L"MemoryOverwriteRequestControl - SetVariable() returns = EFI_ACCESS_DENIED when MORLOCK is locked-without-key",=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 +=0D + // verifying that the variable has not been modified with SetVariable(),= proving that MORLOCK acts as a lock=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030,= =0D + L"MemoryOverwriteRequestControl - When locked-without-ke= y, MOR bit 0 remains unchanged after an attempt to set it",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once locked-without-key, MOR cannot be deleted=0D + // SetVariable() call to set MOR with DataSize =3D=3D 0 must return EFI_= ACCESS_DENIED=0D + // MemoryOverwriteControlData is a don't care in this case=0D + DataSize =3D 0;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=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_ACCESS_DENIED) {=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031,= =0D + L"MemoryOverwriteRequestControl - When MORLOCK is locked= -without-key, an attempt to delete the MOR variable must return EFI_ACCESS_= DENIED",=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 (#114836): https://edk2.groups.io/g/devel/message/114836 Mute This Topic: https://groups.io/mt/104065287/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-