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 867257803CE for ; Tue, 5 Mar 2024 23:36:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KbaYopa2HHD6rfbLi1iir6RyYW3ZtsoTC9aWCFZYcZ8=; 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=20240206; t=1709681807; v=1; b=W7z/0HX1w6+QG/bfKPKZwnxRzvWrmlK1QCjowP0lccHdOAjUiqt3fRtm45P8kCLTxRegGZhC EWPuSnKb5zKZYkzH3z1BzWEXFRdxJAGgmsr9sc5egx+yCKffztfWH6xz083RUK7p0iDraeF/4sO anmTK9CPEOTyTuP2v/mqsnD2xqBXn34SQBNsr+5xrErbu4V78beP7feUzBDZ+kPU0beSC+TyOtQ FS0JuBfu1dsK3wbGcr34q+Ym+8P+Q3QT7pDMEKMRkvGJuQ2xBHZ146sxiwJU8UNfONoLGMdzl63 K8xefPhuMiTjiHXcgHovZ5y7jEHBOaXK7CG/b+71i0AnQ== X-Received: by 127.0.0.2 with SMTP id 1utJYY7687511xjKG2pCtDdQ; Tue, 05 Mar 2024 15:36:47 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.3765.1709681806645674424 for ; Tue, 05 Mar 2024 15:36:46 -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 16D2C12FC; Tue, 5 Mar 2024 15:37:23 -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 E9C593F73F; Tue, 5 Mar 2024 15:36:45 -0800 (PST) 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 v4 5/6] uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test Date: Tue, 5 Mar 2024 17:36:21 -0600 Message-Id: <20240305233622.747522-6-Abhi.Singh@arm.com> In-Reply-To: <20240305233622.747522-1-Abhi.Singh@arm.com> References: <20240305233622.747522-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: vmL1peqY1FpcBh1TuqBOGsutx7686176AA= 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="W7z/0HX1"; 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 MemoryOverwriteRequestControlLock Locked No Key State test cases -Add Assertions 21 - 31 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 | 61 +++ 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 | 25 ++ uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 472 ++++++++++++= ++++++++ 4 files changed, 569 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 1ca43a393f29..612e6ee436e0 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 @@ -85,6 +85,42 @@ Abstract: #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_020_GUID \=0D { 0x2eba284a, 0xf701, 0x4c19, {0xbe, 0x5c, 0x39, 0x27, 0xb0, 0x68, 0x4f, 0= xd7 }}=0D =0D +<<<<<<< HEAD=0D +=3D=3D=3D=3D=3D=3D=3D=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_021_GUID \=0D +{ 0x9a1b44ae, 0x08ce, 0x474c, {0xa5, 0x8e, 0xa6, 0xe2, 0xcf, 0xaf, 0x91, 0= x2c }}=0D +=0D +#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 +>>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Tes= t)=0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;=0D @@ -124,3 +160,28 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunction= AssertionGuid018; extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid019;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid020;=0D +<<<<<<< HEAD=0D +=3D=3D=3D=3D=3D=3D=3D=0D +=0D +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 +>>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Tes= t)=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 fe8853452979..7e00224c325c 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 @@ -67,3 +67,28 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertion= Guid018 =3D EFI_TEST_TCGMO EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid019 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_019_GUID;=0D =0D EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid020 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_020_GUID;=0D +<<<<<<< HEAD=0D +=3D=3D=3D=3D=3D=3D=3D=0D +=0D +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 +>>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Tes= t)=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 fe5ca180c104..7780b390a5f2 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 @@ -180,6 +182,16 @@ BBTestTCGMemoryOverwriteRequestFunctionTest ( }=0D CheckpointStepMatched =3D TRUE;=0D }=0D + if (ResetData->CheckpointStep =3D=3D LOCK_NO_KEY_STATE_TEST) {=0D + //=0D + // Test Checkpoint LOCK_NO_KEY_STATE_TEST=0D + //=0D + Status =3D TCGMemoryOverwriteRequestControlLockLockedNoKeyState (Stand= ardLib, RecoveryLib, 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 @@ -1247,3 +1259,463 @@ 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 + //=0D + // Check Step to see which part of test remains to be executed=0D + //=0D + switch (ResetData->Step) {=0D + case 0:=0D + goto INITIAL_RESET;=0D + case 1:=0D + goto MORLOCK_LOCKED_STATE;=0D + default:=0D + return EFI_INVALID_PARAMETER;=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 +=0D + SctPrint (L"System will cold reset after 1 second and test will be resum= ed after reboot.");=0D + Status =3D gtBS->Stall(1000000);=0D + if (EFI_ERROR(Status)) {=0D + // Handle stall error=0D + SctPrint(L"Error: Failed to stall the system.\n");=0D + return Status;=0D + }=0D + gtRT->ResetSystem (=0D + EfiResetCold,=0D + EFI_SUCCESS,=0D + 0,=0D + NULL=0D + );=0D + SctPrint(L"Error: Failed to perform a cold reset.\n");=0D + return EFI_DEVICE_ERROR;=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 || 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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031,= =0D + L"MemoryOverwriteRequestControl - When MORLOCK is locked= -without-key, an attempt to delete the MOR variable must return either EFI_= ACCESS_DENIED or EFI_INVALID_PARAMETER",=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 (#116411): https://edk2.groups.io/g/devel/message/116411 Mute This Topic: https://groups.io/mt/104756656/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-