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 7C9D37803CC for ; Tue, 9 Apr 2024 04:45:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=lom1GvNfyxF7U3qlVYwgq+LakUb6c+Fuc7bq8vsYMU0=; 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=1712637953; v=1; b=ESkeZWuOMwzYwgwpzosMJQHxZT0H9oy1LldugPndGtAdlv99PCT7BP1M8ofSSTK5YFtZoSKw TjrbBmbyFvdzrHZYIRcHFTB5aqO3w2g+qLHL1KAbWehv3MgPcZYv6e6jNU3lBe9cDAm3cPbjZEL uvj7N8vz+xuCCz1YvGGgnAOoEF5Bq6CHKNMqwFXqzQFtdbKmBDmKgL5NUorxujEI85rJOq/a5hj EPx6PPWA/PD7HnumF+QzIkNs3GFzYQ5JbDA+QsMZAjmxdWSfpe2zQHOKkqblvgaC0+P2O3WMMc9 bBbLBn2gJpq87UHME2gqh7ZVhWOY8bPnrm4ZQi2T0QCUg== X-Received: by 127.0.0.2 with SMTP id DetcYY7687511xXXgKs3ZFf3; Mon, 08 Apr 2024 21:45:53 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.129068.1712637952334793802 for ; Mon, 08 Apr 2024 21:45:52 -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 820B61596; Mon, 8 Apr 2024 21:46:22 -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 C0F663F64C; Mon, 8 Apr 2024 21:45:51 -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 6/6] uefi-sct/SctPkg: TCG MORLOCK Locked with Key State Test Date: Mon, 8 Apr 2024 23:45:23 -0500 Message-Id: <20240409044523.1033318-7-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:52 -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: GmtZeEMfp9H7hpJ9fLQUucZdx7686176AA= 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=ESkeZWuO; 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 with Key State test cases -Add remaining Assertions 32 - 49 from SCT spec -Add Test Case to MemoryOverwriteRequestFunctionTest -Changed several assertion strings to be more descriptive 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 | 90 +++ 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 | 36 + uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteReques= t/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 715 ++++++++++++= +++++++- 4 files changed, 828 insertions(+), 24 deletions(-) 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 065f197987cc..cf7f3e180f54 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 @@ -118,6 +118,60 @@ Abstract: #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 +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_033_GUID \=0D +{ 0x38a813ac, 0x8eb9, 0x46ce, {0xa8, 0x6b, 0x40, 0x8c, 0x07, 0x5f, 0xc7, 0= xed }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_034_GUID \=0D +{ 0x919b8392, 0xcb78, 0x49ff, {0xa3, 0x18, 0x49, 0x78, 0x76, 0xe0, 0xf8, 0= xf8 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_035_GUID \=0D +{ 0x219abaf2, 0x04a9, 0x407c, {0xb5, 0xde, 0xa0, 0x03, 0x6e, 0x65, 0xb0, 0= xb9 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_036_GUID \=0D +{ 0x9a51640a, 0xff14, 0x402b, {0xb0, 0x57, 0xa0, 0xc4, 0xf7, 0x20, 0x8e, 0= x44 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_037_GUID \=0D +{ 0x8ccd0dbb, 0x9b0a, 0x4bfb, {0xa0, 0x7e, 0xc6, 0x06, 0x8b, 0x91, 0x0d, 0= xfb }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_038_GUID \=0D +{ 0xde6f4e17, 0xe375, 0x4dcb, {0x8f, 0x07, 0x77, 0x7e, 0x62, 0x49, 0xea, 0= x2c }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_039_GUID \=0D +{ 0x4ab6927b, 0x5ee4, 0x4748, {0xa4, 0x9d, 0x2d, 0xf3, 0x70, 0x01, 0x41, 0= xd5 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_040_GUID \=0D +{ 0x33142ecf, 0x0f92, 0x4625, {0xb7, 0xf6, 0x7f, 0x15, 0x25, 0x74, 0xd3, 0= x03 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_041_GUID \=0D +{ 0xf73c04df, 0x2e42, 0x4174, {0x82, 0x18, 0x0f, 0x25, 0x46, 0x4a, 0x55, 0= xe9 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_042_GUID \=0D +{ 0xd4eacf82, 0x55d1, 0x4ba1, {0xbe, 0x89, 0x6a, 0x2e, 0x44, 0x0f, 0xc7, 0= xc0 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_043_GUID \=0D +{ 0xfd88fe63, 0x5ed4, 0x482a, {0x98, 0x44, 0x23, 0x90, 0xf9, 0x09, 0x1c, 0= x20 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_044_GUID \=0D +{ 0x176f16cb, 0xf3a4, 0x4f12, {0x8f, 0x96, 0x4a, 0xc1, 0x8b, 0xdd, 0x6e, 0= x3c }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_045_GUID \=0D +{ 0xf0d5e7b3, 0xdc0f, 0x4a18, {0xb9, 0x78, 0x09, 0x3b, 0x15, 0x55, 0x66, 0= xbf }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_046_GUID \=0D +{ 0x9bf14c4b, 0x2950, 0x4c4e, {0x8b, 0xa3, 0x06, 0x46, 0xf1, 0x27, 0x8c, 0= x05 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_047_GUID \=0D +{ 0xb0468dee, 0xb1d0, 0x4795, {0x9f, 0xbf, 0xbe, 0x3f, 0x40, 0x2f, 0x3d, 0= x6f }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_048_GUID \=0D +{ 0x1f7dd903, 0xcd58, 0x4d6f, {0x80, 0xd6, 0x4f, 0x6d, 0xcb, 0x4a, 0xd6, 0= xc9 }}=0D +=0D +#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_049_GUID \=0D +{ 0x439179c2, 0x744d, 0x43bc, {0xb0, 0x67, 0x7b, 0x65, 0x60, 0x62, 0x6f, 0= x5e }}=0D +=0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;=0D @@ -179,3 +233,39 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunction= AssertionGuid029; extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030;=0D =0D extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048;=0D +=0D +extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049;=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 94ed476f86ad..76b3c76340cf 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 @@ -50,11 +50,13 @@ typedef struct _RESET_DATA { =0D #define MOR_LOCK_DATA_UNLOCKED 0x0=0D #define MOR_LOCK_DATA_LOCKED_WITHOUT_KEY 0x1=0D +#define MOR_LOCK_DATA_LOCKED_WITH_KEY 0x2=0D =0D +#define MOR_LOCK_NO_KEY_SIZE 1=0D #define MOR_LOCK_WITH_KEY_SIZE 8=0D =0D #define MOR_LOCK_TEST_KEY 0x11111111=0D -=0D +#define MOR_LOCK_INVALID_TEST_KEY 0x22222222=0D =0D //=0D // TEST GUID for TCG Platform Reset Attack Mitigation MemoryOverwriteReque= st (MOR) Test=0D @@ -118,6 +120,13 @@ TCGMemoryOverwriteRequestControlLockLockedNoKeyState ( IN RESET_DATA *ResetData=0D );=0D =0D +EFI_STATUS=0D +TCGMemoryOverwriteRequestControlLockLockedWithKeyState (=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 f44e7de3c51d..6bde8f686a16 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 @@ -89,3 +89,39 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertion= Guid029 =3D EFI_TEST_TCGMO 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 +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_033_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_034_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_035_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_036_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_037_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_038_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_039_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_040_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_041_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_042_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_043_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_044_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_045_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_046_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_047_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_048_GUID;=0D +=0D +EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049 =3D EFI_TE= ST_TCGMORTESTFUNCTION_ASSERTION_049_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 7780b390a5f2..5bc40ac83214 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 @@ -192,6 +192,16 @@ BBTestTCGMemoryOverwriteRequestFunctionTest ( }=0D CheckpointStepMatched =3D TRUE;=0D }=0D + if (ResetData->CheckpointStep =3D=3D LOCK_WITH_KEY_STATE_TEST) {=0D + //=0D + // Test Checkpoint LOCK_WITH_KEY_STATE_TEST=0D + //=0D + Status =3D TCGMemoryOverwriteRequestControlLockLockedWithKeyState (Sta= ndardLib, 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 @@ -548,7 +558,7 @@ TCGMemoryOverwriteRequestControlSetVariable ( }=0D =0D //=0D - // MOR SetVariable() with invalid Attributes =3D=3D NV + BS returns EFI_= INVALID_PARAMETER and value is unchanged=0D + // MOR SetVariable() with invalid Attributes =3D NV + BS returns EFI_INV= ALID_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 @@ -589,7 +599,7 @@ TCGMemoryOverwriteRequestControlSetVariable ( StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid005,= =0D - L"MemoryOverwriteRequestControl - SetVariable() with Att= ributes =3D=3D NV returns EFI_INVALID_PARAMETER",=0D + L"MemoryOverwriteRequestControl - SetVariable() returns = EFI_INVALID_PARAMETER with invalid Attributes =3D (NV+BS)",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -617,7 +627,7 @@ TCGMemoryOverwriteRequestControlSetVariable ( StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid006,= =0D - L"MemoryOverwriteRequestControl - SetVariable() with Att= ributes =3D=3D NV variable value remains unchanged",=0D + L"MemoryOverwriteRequestControl - SetVariable() with inv= alid Attributes =3D (NV+BS), variable value remains unchanged",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -736,8 +746,8 @@ MORLOCK_SET_VARIABLE: }=0D =0D // MORLOCK SetVariable() to locked-without-key with valid GUID, variable= name, Data, and DataSize=0D - // except for invalid Attributes value =3D=3D 0=0D - // verify SetVariable() returns EFI_WRITE_PROTECTED and GetVariable() re= turns a Data Value =3D=3D 0=0D + // except for invalid Attributes value =3D 0=0D + // verify SetVariable() returns EFI_WRITE_PROTECTED and GetVariable() re= turns a Data Value =3D 0=0D DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D Attributes =3D 0;=0D MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY;=0D @@ -759,7 +769,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid007,= =0D - L"MemoryOverwriteRequestControlLock - SetVariable() with= Attributes =3D=3D 0 returns EFI_WRITE_PROTECTED",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() retu= rns EFI_WRITE_PROTECTED with invalid Attributes =3D 0",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -788,7 +798,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid008,= =0D - L"MemoryOverwriteRequestControlLock - Lock value remains= unlocked",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() with= invalid Attributes =3D 0, lock value remains unlocked",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -796,8 +806,8 @@ MORLOCK_SET_VARIABLE: );=0D =0D // MORLOCK SetVariable() to locked-without-key with valid GUID, variable= name, Data, and Attributes=0D - // except for invalid DataSize =3D=3D 0=0D - // verify SetVariable() returns EFI_WRITE_PROTECTED and GetVariable() re= turns a Data Value =3D=3D 0=0D + // except for invalid DataSize =3D 0=0D + // verify SetVariable() returns EFI_WRITE_PROTECTED and GetVariable() re= turns a Data Value =3D 0=0D DataSize =3D 0;=0D Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY;=0D @@ -819,7 +829,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid009,= =0D - L"MemoryOverwriteRequestControlLock - SetVariable() with= DataSize =3D=3D 0 returns EFI_WRITE_PROTECTED",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() retu= rns EFI_WRITE_PROTECTED with DataSize =3D 0",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -848,7 +858,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid010,= =0D - L"MemoryOverwriteRequestControlLock - Lock value remains= unlocked",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() with= DataSize =3D 0, lock value remains unlocked",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -856,8 +866,8 @@ MORLOCK_SET_VARIABLE: );=0D =0D // MORLOCK SetVariable() to locked-without-key with valid GUID,=0D - // variable name, DataSize, and Attributes, except for Data =3D=3D NULL= =0D - // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() = returns a Data Value =3D=3D 0=0D + // variable name, DataSize, and Attributes, except for Data =3D NULL=0D + // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() = returns a Data Value =3D 0=0D DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D =0D @@ -903,7 +913,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid012,= =0D - L"MemoryOverwriteRequestControlLock - Lock value remains= unlocked",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() with= Data as NULL, lock value remains unlocked",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -911,8 +921,8 @@ MORLOCK_SET_VARIABLE: );=0D =0D // MORLOCK SetVariable() to lock-without-key with valid GUID, variable n= ame, Data, and DataSize=0D - // except for invalid Attributes !=3D NV+BS+RT, this test will use inval= id Attributes =3D=3D NV + BS=0D - // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() = returns a Data Value =3D=3D 0=0D + // except for invalid Attributes !=3D NV+BS+RT, this test will use inval= id Attributes =3D NV + BS=0D + // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() = returns a Data Value =3D 0=0D DataSize =3D sizeof(MemoryOverwriteRequestControlLockData);=0D Attributes =3D EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCE= SS;=0D MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY;=0D @@ -934,7 +944,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid013,= =0D - L"MemoryOverwriteRequestControlLock - SetVariable() with= Attributes =3D=3D NV returns EFI_INVALID_PARAMETER",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() with= invalid attributes =3D (NV+BS) returns EFI_INVALID_PARAMETER",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -963,7 +973,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid014,= =0D - L"MemoryOverwriteRequestControlLock - Lock value remains= unlocked",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() with= invalid attributes =3D (NV+BS), lock value remains unlocked",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -971,8 +981,8 @@ MORLOCK_SET_VARIABLE: );=0D =0D // MORLOCK SetVariable() to locked-without-key with valid GUID, variable= name, Data, and Attributes=0D - // except for invalid DataSize !=3D 1 && !=3D 8, this test will use inva= lid DataSize =3D=3D 5=0D - // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() = returns a Data Value =3D=3D 0=0D + // except for invalid DataSize !=3D 1 && !=3D 8, this test will use inva= lid DataSize =3D 5=0D + // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() = returns a Data Value =3D 0=0D DataSize =3D 5;=0D Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D MemoryOverwriteRequestControlLockData =3D MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY;=0D @@ -994,7 +1004,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid015,= =0D - L"MemoryOverwriteRequestControlLock - SetVariable() with= DataSize =3D=3D 5 returns EFI_INVALID_PARAMETER",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() with= DataSize =3D 5 returns EFI_INVALID_PARAMETER",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -1023,7 +1033,7 @@ MORLOCK_SET_VARIABLE: StandardLib,=0D Result,=0D gTCGMemoryOverwriteRequestTestFunctionAssertionGuid016,= =0D - L"MemoryOverwriteRequestControlLock - Lock value remains= unlocked",=0D + L"MemoryOverwriteRequestControlLock - SetVariable() with= DataSize =3D 5, lock value remains unlocked",=0D L"%a:%d:Status - %r",=0D __FILE__,=0D (UINTN)__LINE__,=0D @@ -1688,7 +1698,7 @@ MORLOCK_LOCKED_STATE: =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 + // SetVariable() call to set MOR with DataSize =3D 0 must return EFI_ACC= ESS_DENIED=0D // MemoryOverwriteControlData is a don't care in this case=0D DataSize =3D 0;=0D Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D @@ -1719,3 +1729,662 @@ MORLOCK_LOCKED_STATE: =0D return EFI_SUCCESS;=0D }=0D +=0D +=0D +/**=0D + * MemoryOverwriteRequestControlLock in locked-with-key state test=0D + * When unlocked, a valid SetVariable() with an 8 byte key must return EF= I_SUCCESS=0D + * and the lock value must be 0x02 (MOR_LOCK_DATA_LOCKED_WITH_KEY), in or= der to=0D + * unlock, the same 8 byte key must be passed.=0D + *=0D + * When locked with an 8 byte key, SetVariable() with the same 8 byte key= =0D + * must return EFI_SUCCESS and the Lock value must be 0x00 or MOR_LOCK_DA= TA_UNLOCKED.=0D + *=0D + * When locked with an 8 byte Key, SetVariable() with DataSize !=3D 8 and= =0D + * Data =3D 0x01 (MOR_LOCK_DATA_LOCKED_WITHOUT_KEY) or 0x00 (MOR_LOCK_DAT= A_UNLOCKED)=0D + * must return EFI_ACCESS_DENIED=0D + * and value must still equal to 0x02 (MOR_LOCK_DATA_LOCKED_WITH_KEY).=0D + *=0D + * When locked with an 8 byte Key, SetVariable() with 8 byte key !=3D key= used to set=0D + * the lock, in this case 0x11111111 (MOR_LOCK_TEST_KEY), must return EFI= _ACCESS_DENIED=0D + * and lock value must be updated to 0x01 (MOR_LOCK_DATA_LOCKED_WITHOUT_K= EY)=0D + * to prevent dictonary attack.=0D + *=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 +TCGMemoryOverwriteRequestControlLockLockedWithKeyState (=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 MemoryOverwriteRequestControlLockDa= ta;=0D + UINTN MemoryOverwriteControlLockKeyValue;= =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_KEY_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 +=0D + ResetData->Step =3D 1;=0D + ResetData->CheckpointStep =3D LOCK_WITH_KEY_STATE_TEST;=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_KEY_STATE:=0D + //=0D + // MORLOCK Reboot system to clear lock, and invoke SetVariable() with va= lid 8 byte key=0D + // In this case =3D 0x11111111, must return EFI_SUCCESS and GetVariable(= ) value must =3D 0x02=0D + //=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_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032,= =0D + L"MemoryOverwriteRequestControlLock - Setting to locked-= with-key using key value =3D 0x11111111 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_WITH_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is now = locked-with-key with key value =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Currently locked-with-key, invoke SetVariable() with the same valid 8= byte key used to lock=0D + // In this case =3D 0x11111111, must return EFI_SUCCESS and GetVariable(= ) value must =3D 0x00=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_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034,= =0D + L"MemoryOverwriteRequestControlLock - Unlocking the lock= using key value =3D 0x11111111 when locked with the same key returns EFI_S= UCCESS",=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_UNLOCKED)) {=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is now = unlocked",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Lock with same 8 byte key again, verify EFI_SUCCESS is returned=0D + // unlock attempt: invoke SetVariable() with the same valid 8 byte=0D + // key used to lock =3D 0x11111111, but with invalid DataSize =3D 1=0D + // must return EFI_ACCESS_DENIED and GetVariable() value must remain =3D= 0x02=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_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036,= =0D + L"MemoryOverwriteRequestControlLock - Setting to locked-= with-key using key value =3D 0x11111111 when unlocked returns EFI_SUCCESS",= =0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + DataSize =3D MOR_LOCK_NO_KEY_SIZE; // invalid datasize =3D 1=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037,= =0D + L"MemoryOverwriteRequestControlLock - Attempting to unlo= ck by passing an invalid DataSize 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_WITH_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-with-key with key value =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // invoke MORLOCK SetVariable() with Data value =3D 0x00 to change to un= locked=0D + // must return EFI_ACCESS_DENIED and GetVariable() value must still =3D = 0x02=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039,= =0D + L"MemoryOverwriteRequestControlLock - Setting to unlocke= d when locked-with-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_WITH_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-with-key with key value =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // invoke MORLOCK SetVariable() with Data value =3D 0x01 to change to lo= cked-without-key=0D + // must return EFI_ACCESS_DENIED and GetVariable() value must still =3D = 0x02=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041,= =0D + L"MemoryOverwriteRequestControlLock - Setting to locked-= without-key when locked-with-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_WITH_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042,= =0D + L"MemoryOverwriteRequestControlLock - Lock state is stil= l locked-with-key with key value =3D 0x11111111",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once locked-with-key, MOR SetVariable() call to set MOR bit 0 must re= turn 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 value that will be used to check that the variabl= e 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 setting the 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 + 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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043,= =0D + L"MemoryOverwriteRequestControl - SetVariable() returns = EFI_ACCESS_DENIED when MORLOCK is locked-with-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()= =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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044,= =0D + L"MemoryOverwriteRequestControl - After SetVariable(), M= OR value remains unchanged when MORLOCK is locked-with-key",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // Once locked-with-key, MOR cannot be deleted=0D + // SetVariable() call to set MOR with DataSize =3D 0 must return EFI_ACC= ESS_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045,= =0D + L"MemoryOverwriteRequestControl - When MORLOCK is locked= -with-key, an attempt to delete the MOR variable must return either EFI_ACC= ESS_DENIED or EFI_INVALID_PARAMETER",=0D + L"%a:%d:Status - %r",=0D + __FILE__,=0D + (UINTN)__LINE__,=0D + Status=0D + );=0D +=0D + //=0D + // When locked-with-key, in this case key =3D 0x11111111,=0D + // SetVariable() with an invalid 8 byte key !=3D 0x11111111, must return= EFI_ACCESS_DENIED=0D + // and lock must be updated to Locked without key (Data value =3D 0x01) = to prevent dictonary attack=0D + // The invalid key to be used to attempt unlock is =3D 0x22222222=0D + //=0D + DataSize =3D MOR_LOCK_WITH_KEY_SIZE;=0D + Attributes =3D TCG_MOR_VARIABLE_ATTRIBUTES;=0D + MemoryOverwriteControlLockKeyValue =3D MOR_LOCK_INVALID_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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046,= =0D + L"MemoryOverwriteRequestControlLock - Unlocking lock wit= h invalid key !=3D 0x11111111 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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047,= =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 + // MORLOCK has been updated to locked-without-key (Data value =3D 0x01) = to prevent dictonary attack=0D + // Now check to see if the lock can still be unlocked with the initial k= ey used to set to lock-with-key state=0D + // The key to be used to attempt unlock is =3D 0x11111111=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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048,= =0D + L"MemoryOverwriteRequestControlLock - Attempt to unlock = after dictionary attack mitigation 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 + gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049,= =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 + return EFI_SUCCESS;=0D +}=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117525): https://edk2.groups.io/g/devel/message/117525 Mute This Topic: https://groups.io/mt/105416474/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-