From: "Abhimanyu Singh" <Abhi.Singh@arm.com>
To: devel@edk2.groups.io
Cc: Abhi Singh <Abhi.Singh@arm.com>,
G Edhaya Chandran <edhaya.chandran@arm.com>,
Barton Gao <gaojie@byosoft.com.cn>,
Carolyn Gjertsen <carolyn.gjertsen@amd.com>,
Abhi Singh <abhi.singh@arm.com>,
Stuart Yoder <stuart.yoder@arm.com>
Subject: [edk2-devel] [PATCH v4 3/6] uefi-sct/SctPkg: TCG MORLOCK SetVariable Test
Date: Tue, 5 Mar 2024 17:36:19 -0600 [thread overview]
Message-ID: <20240305233622.747522-4-Abhi.Singh@arm.com> (raw)
In-Reply-To: <20240305233622.747522-1-Abhi.Singh@arm.com>
SCT spec: https://bugzilla.tianocore.org/show_bug.cgi?id=4374
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4419
-Implement MemoryOverwriteRequestControlLockSetVariable test
cases
-Add Assertions 7 through 16 from SCT spec
-Add Test Case to MemoryOverwriteRequestFunctionTest
Cc: G Edhaya Chandran <edhaya.chandran@arm.com>
Cc: Barton Gao <gaojie@byosoft.com.cn>
Cc: Carolyn Gjertsen <carolyn.gjertsen@amd.com>
Signed-off-by: Abhi Singh <abhi.singh@arm.com>
Reviewed-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h | 50 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h | 8 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c | 20 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 418 ++++++++++++++++++++
4 files changed, 496 insertions(+)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h
index 1d6d86ebed07..891f494dbc70 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h
@@ -43,6 +43,36 @@ Abstract:
#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_006_GUID \
{ 0x94811e97, 0x7513, 0x4099, {0xae, 0xb8, 0x5a, 0x7e, 0x7d, 0x50, 0xb4, 0x99 }}
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_007_GUID \
+{ 0x15378290, 0x17dd, 0x4cbf, {0x8e, 0x8f, 0xc2, 0x4b, 0xc9, 0x09, 0xb4, 0x14 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_008_GUID \
+{ 0x5f0b42ef, 0x3cec, 0x46ad, {0xbc, 0x5b, 0xc3, 0x7a, 0x1d, 0x45, 0x41, 0x29 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_009_GUID \
+{ 0x9665c8d9, 0x267c, 0x4393, {0xa4, 0x72, 0x10, 0x54, 0x43, 0x56, 0x20, 0x21 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_010_GUID \
+{ 0xce655812, 0xcc40, 0x42b0, {0x80, 0xd1, 0xa7, 0x26, 0xdb, 0x14, 0x9e, 0xa8 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_011_GUID \
+{ 0xd34348ad, 0x5d46, 0x4961, {0x91, 0x3e, 0xb1, 0xf2, 0xc5, 0xe7, 0x0f, 0x7d }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_012_GUID \
+{ 0x838311e0, 0x419a, 0x4c92, {0x90, 0x60, 0xbf, 0x94, 0x59, 0xd3, 0xc3, 0x59 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_013_GUID \
+{ 0x12998a9c, 0xc863, 0x4572, {0x80, 0x6c, 0xb6, 0x40, 0x97, 0x91, 0x89, 0x7f }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_014_GUID \
+{ 0xebd4ba26, 0x44c3, 0x464a, {0x88, 0xe3, 0x3b, 0x44, 0x94, 0x88, 0xbb, 0xb8 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_015_GUID \
+{ 0x00920c8e, 0x241d, 0x4da0, {0x8b, 0x59, 0xc3, 0xad, 0xe0, 0xd6, 0x4e, 0xc9 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_016_GUID \
+{ 0x169a43cc, 0x23fa, 0x4887, {0x8b, 0x4f, 0x11, 0xb2, 0xa0, 0x88, 0x4f, 0x63 }}
+
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;
@@ -54,3 +84,23 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid004;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid005;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid006;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid007;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid008;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid009;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid010;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid011;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid012;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid013;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid014;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid015;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid016;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h
index 46c2c2faa388..553959762be8 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h
@@ -49,6 +49,7 @@ typedef struct _RESET_DATA {
#define MOR_BIT_HIGH 0x1
#define MOR_LOCK_DATA_UNLOCKED 0x0
+#define MOR_LOCK_DATA_LOCKED_WITHOUT_KEY 0x1
//
@@ -92,6 +93,13 @@ TCGMemoryOverwriteRequestControlSetVariable (
IN RESET_DATA *ResetData
);
+EFI_STATUS
+TCGMemoryOverwriteRequestControlLockSetVariable (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib,
+ IN RESET_DATA *ResetData
+ );
+
// ****************************************************************************
// Entry GUIDs for Test
// ****************************************************************************
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c
index 649de8196990..d861c44e3960 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c
@@ -39,3 +39,23 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid004 = EFI_TEST_TCGMO
EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid005 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_005_GUID;
EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid006 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_006_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid007 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_007_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid008 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_008_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid009 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_009_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid010 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_010_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid011 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_011_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid012 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_012_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid013 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_013_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid014 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_014_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid015 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_015_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid016 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_016_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c
index 2b9f5dd93a32..f0c6029c9afb 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c
@@ -39,6 +39,8 @@ Abstract:
#define LOCK_SET_VARIABLE_TEST 3
+#define LOCK_UNLOCKED_STATE_TEST 4
+
/**
* Entry point for TCG Platform Reset Attack Mitigation MemoryOverwrite EFI Variables Function Test.
@@ -156,6 +158,16 @@ BBTestTCGMemoryOverwriteRequestFunctionTest (
}
CheckpointStepMatched = TRUE;
}
+ if (ResetData->CheckpointStep == LOCK_SET_VARIABLE_TEST) {
+ //
+ // Test Checkpoint LOCK_SET_VARIABLE_TEST
+ //
+ Status = TCGMemoryOverwriteRequestControlLockSetVariable (StandardLib, RecoveryLib, ResetData);
+ if(EFI_ERROR(Status)) {
+ return Status;
+ }
+ CheckpointStepMatched = TRUE;
+ }
if (!CheckpointStepMatched) {
return EFI_INVALID_PARAMETER; // incase of invalid CheckpointStep, return EFI_INVALID_PARAMETER
@@ -590,3 +602,409 @@ TCGMemoryOverwriteRequestControlSetVariable (
return EFI_SUCCESS;
}
+
+
+/**
+ * MemoryOverwriteRequestControlLock SetVariable() with different variations
+ * of only a single invalid parameter being passed, with the rest parameters being valid
+ * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL
+ * instance.
+ * @param RecoveryLib A pointer to EFI_TEST_RECOVERY_LIBRARY_PROTOCOL
+ * instance.
+ * @param ResetData A pointer to the ResetData buffer which is used throughout the
+ * test
+ * @return EFI_SUCCESS Successfully.
+ * @return Other value Something failed.
+ */
+EFI_STATUS
+TCGMemoryOverwriteRequestControlLockSetVariable (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib,
+ IN RESET_DATA *ResetData
+ )
+{
+ EFI_STATUS Status;
+ EFI_TEST_ASSERTION Result;
+ UINTN DataSize;
+ UINT8 MemoryOverwriteRequestControlLockData;
+ UINT32 Attributes;
+
+ //
+ // Check Step to see which part of test remains to be executed
+ //
+ switch (ResetData->Step) {
+ case 0:
+ goto INITIAL_RESET;
+ case 1:
+ goto MORLOCK_SET_VARIABLE;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+
+INITIAL_RESET:
+ //
+ // Reset MORLOCK variable by performing a cold reset
+ //
+
+ ResetData->Step = 1;
+ ResetData->CheckpointStep = LOCK_SET_VARIABLE_TEST;
+
+ Status = RecoveryLib->WriteResetRecord (
+ RecoveryLib,
+ sizeof (RESET_DATA),
+ (UINT8*)ResetData
+ );
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_FAILED,
+ gTestGenericFailureGuid,
+ L"TestRecoveryLib - WriteResetRecord",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ return Status;
+ }
+
+ SctPrint (L"System will cold reset after 1 second and test will be resumed after reboot.");
+ Status = gtBS->Stall(1000000);
+ if (EFI_ERROR(Status)) {
+ // Handle stall error
+ SctPrint(L"Error: Failed to stall the system.\n");
+ return Status;
+ }
+ gtRT->ResetSystem (
+ EfiResetCold,
+ EFI_SUCCESS,
+ 0,
+ NULL
+ );
+ SctPrint(L"Error: Failed to perform a cold reset.\n");
+ return EFI_DEVICE_ERROR;
+
+MORLOCK_SET_VARIABLE:
+ //
+ // reset step count and Update Checkpoint to LOCK_UNLOCKED_STATE_TEST
+ //
+
+ ResetData->Step = 0;
+ ResetData->CheckpointStep = LOCK_UNLOCKED_STATE_TEST;
+
+ Status = RecoveryLib->WriteResetRecord (
+ RecoveryLib,
+ sizeof (RESET_DATA),
+ (UINT8*)ResetData
+ );
+ if (EFI_ERROR(Status)) {
+ StandardLib->RecordAssertion (
+ StandardLib,
+ EFI_TEST_ASSERTION_FAILED,
+ gTestGenericFailureGuid,
+ L"TestRecoveryLib - WriteResetRecord",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+ return Status;
+ }
+
+ // MORLOCK SetVariable() to locked-without-key with valid GUID, variable name, Data, and DataSize
+ // except for invalid Attributes value == 0
+ // verify SetVariable() returns EFI_WRITE_PROTECTED and GetVariable() returns a Data Value == 0
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ Attributes = 0;
+ MemoryOverwriteRequestControlLockData = MOR_LOCK_DATA_LOCKED_WITHOUT_KEY;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (Status == EFI_WRITE_PROTECTED) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid007,
+ L"MemoryOverwriteRequestControlLock - SetVariable() with Attributes == 0 returns EFI_WRITE_PROTECTED",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // change Attributes to valid before GetVariable() to check that MORLOCK value is still 0x00 or unlocked
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+ Status = gtRT->GetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ &Attributes, // Attributes
+ &DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_UNLOCKED)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ // Check that MORLOCK remains unlocked after previous operation
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid008,
+ L"MemoryOverwriteRequestControlLock - Lock value remains unlocked",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // MORLOCK SetVariable() to locked-without-key with valid GUID, variable name, Data, and Attributes
+ // except for invalid DataSize == 0
+ // verify SetVariable() returns EFI_WRITE_PROTECTED and GetVariable() returns a Data Value == 0
+ DataSize = 0;
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+ MemoryOverwriteRequestControlLockData = MOR_LOCK_DATA_LOCKED_WITHOUT_KEY;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (Status == EFI_WRITE_PROTECTED) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid009,
+ L"MemoryOverwriteRequestControlLock - SetVariable() with DataSize == 0 returns EFI_WRITE_PROTECTED",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // change DataSize to a valid value before GetVariable()
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+ // Check that MORLOCK remains unlocked after previous operation
+ Status = gtRT->GetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ &Attributes, // Attributes
+ &DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_UNLOCKED)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid010,
+ L"MemoryOverwriteRequestControlLock - Lock value remains unlocked",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // MORLOCK SetVariable() to locked-without-key with valid GUID,
+ // variable name, DataSize, and Attributes, except for Data == NULL
+ // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() returns a Data Value == 0
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ NULL // Data
+ );
+ if (Status == EFI_WRITE_PROTECTED || EFI_INVALID_PARAMETER) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid011,
+ L"MemoryOverwriteRequestControlLock - SetVariable() with Data parameter as NULL returns either EFI_WRITE_PROTECTED or EFI_INVALID_PARAMETER",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Check that MORLOCK remains unlocked after previous operation
+ Status = gtRT->GetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ &Attributes, // Attributes
+ &DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_UNLOCKED)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid012,
+ L"MemoryOverwriteRequestControlLock - Lock value remains unlocked",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // MORLOCK SetVariable() to lock-without-key with valid GUID, variable name, Data, and DataSize
+ // except for invalid Attributes != NV+BS+RT, this test will use invalid Attributes == NV + BS
+ // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() returns a Data Value == 0
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS;
+ MemoryOverwriteRequestControlLockData = MOR_LOCK_DATA_LOCKED_WITHOUT_KEY;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (Status == EFI_INVALID_PARAMETER) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid013,
+ L"MemoryOverwriteRequestControlLock - SetVariable() with Attributes == NV returns EFI_INVALID_PARAMETER",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // change attributes value to valid NV+BS+RT for GetVariable()
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+ // Check that MORLOCK remains unlocked after previous operation
+ Status = gtRT->GetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ &Attributes, // Attributes
+ &DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_UNLOCKED)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid014,
+ L"MemoryOverwriteRequestControlLock - Lock value remains unlocked",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // MORLOCK SetVariable() to locked-without-key with valid GUID, variable name, Data, and Attributes
+ // except for invalid DataSize != 1 && != 8, this test will use invalid DataSize == 5
+ // verify SetVariable() returns EFI_INVALID_PARAMETER and GetVariable() returns a Data Value == 0
+ DataSize = 5;
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+ MemoryOverwriteRequestControlLockData = MOR_LOCK_DATA_LOCKED_WITHOUT_KEY;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (Status == EFI_INVALID_PARAMETER) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid015,
+ L"MemoryOverwriteRequestControlLock - SetVariable() with DataSize == 5 returns EFI_INVALID_PARAMETER",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // change datasize to valid value for GetVariable
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+ // Check that MORLOCK remains unlocked after previous operation
+ Status = gtRT->GetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ &Attributes, // Attributes
+ &DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_UNLOCKED)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid016,
+ L"MemoryOverwriteRequestControlLock - Lock value remains unlocked",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
\ No newline at end of file
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116409): https://edk2.groups.io/g/devel/message/116409
Mute This Topic: https://groups.io/mt/104756654/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-03-05 23:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 23:36 [edk2-devel] [PATCH v4 0/6] EDK2-TEST TCG MOR Tests Abhimanyu Singh
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 1/6] uefi-sct/SctPkg: TCG Platform Reset Check Test Abhimanyu Singh
2024-03-21 11:30 ` G Edhaya Chandran
2024-03-21 11:33 ` G Edhaya Chandran
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 2/6] uefi-sct/SctPkg: TCG MOR SetVariable Test Abhimanyu Singh
2024-03-21 11:30 ` G Edhaya Chandran
2024-03-05 23:36 ` Abhimanyu Singh [this message]
2024-03-21 11:31 ` [edk2-devel] [PATCH v4 3/6] uefi-sct/SctPkg: TCG MORLOCK " G Edhaya Chandran
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 4/6] uefi-sct/SctPkg: TCG MORLOCK Unlocked State Test Abhimanyu Singh
2024-03-21 11:31 ` G Edhaya Chandran
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 5/6] uefi-sct/SctPkg: TCG MORLOCK Locked No Key " Abhimanyu Singh
2024-03-21 11:32 ` G Edhaya Chandran
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 6/6] uefi-sct/SctPkg: TCG MORLOCK Locked with " Abhimanyu Singh
2024-03-21 11:32 ` G Edhaya Chandran
2024-04-04 16:49 ` [edk2-devel] [PATCH v4 0/6] EDK2-TEST TCG MOR Tests Sunny Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240305233622.747522-4-Abhi.Singh@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox