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 5/6] uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test
Date: Tue, 5 Mar 2024 17:36:21 -0600 [thread overview]
Message-ID: <20240305233622.747522-6-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 MemoryOverwriteRequestControlLock Locked No Key
State test cases
-Add Assertions 21 - 31 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 | 61 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h | 11 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c | 25 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 472 ++++++++++++++++++++
4 files changed, 569 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 1ca43a393f29..612e6ee436e0 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
@@ -85,6 +85,42 @@ Abstract:
#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_020_GUID \
{ 0x2eba284a, 0xf701, 0x4c19, {0xbe, 0x5c, 0x39, 0x27, 0xb0, 0x68, 0x4f, 0xd7 }}
+<<<<<<< HEAD
+=======
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_021_GUID \
+{ 0x9a1b44ae, 0x08ce, 0x474c, {0xa5, 0x8e, 0xa6, 0xe2, 0xcf, 0xaf, 0x91, 0x2c }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_022_GUID \
+{ 0x490d7b39, 0xcad4, 0x4e8c, {0xb1, 0x5d, 0x63, 0xd2, 0x0c, 0xb3, 0xe9, 0x45 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_023_GUID \
+{ 0x397394ae, 0xce01, 0x4350, {0xa2, 0x0c, 0xe1, 0xb3, 0xe8, 0x74, 0xdc, 0x01 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_024_GUID \
+{ 0x9cf27a60, 0x94b5, 0x4e2e, {0xb3, 0x2b, 0x51, 0x0f, 0x24, 0x7a, 0x80, 0xd7 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_025_GUID \
+{ 0x766dc008, 0x2a88, 0x4eed, {0x91, 0x95, 0x46, 0x92, 0xdc, 0xcc, 0x1d, 0xf6 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_026_GUID \
+{ 0x5f66c8e5, 0x1bf8, 0x4af4, {0x86, 0x45, 0xf4, 0x93, 0xa0, 0xee, 0x26, 0x88 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_027_GUID \
+{ 0x1064f6ce, 0xb307, 0x4981, {0xac, 0x8f, 0xe5, 0xca, 0x20, 0x6c, 0x1b, 0x8b }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_028_GUID \
+{ 0x40f2c4e9, 0xe937, 0x426e, {0x98, 0xc5, 0x62, 0xca, 0x23, 0x68, 0x52, 0xd0 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_029_GUID \
+{ 0x6d5dcb4d, 0xe008, 0x41cc, {0x98, 0x32, 0xdf, 0xa8, 0x38, 0xb1, 0xb6, 0x02 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_030_GUID \
+{ 0x29b81ee0, 0x368d, 0x447c, {0x9e, 0xd0, 0xa5, 0xfe, 0xd7, 0x02, 0x65, 0x7b }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_031_GUID \
+{ 0xe88b22ce, 0x3de6, 0x49b0, {0xb2, 0x46, 0x9e, 0x35, 0x98, 0x2b, 0x9b, 0x1c }}
+
+>>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test)
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;
@@ -124,3 +160,28 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid018;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid019;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid020;
+<<<<<<< HEAD
+=======
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid022;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid023;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid024;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid025;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid026;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid027;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid028;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid029;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031;
+>>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test)
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 15eedc60f19d..94ed476f86ad 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
@@ -51,6 +51,10 @@ typedef struct _RESET_DATA {
#define MOR_LOCK_DATA_UNLOCKED 0x0
#define MOR_LOCK_DATA_LOCKED_WITHOUT_KEY 0x1
+#define MOR_LOCK_WITH_KEY_SIZE 8
+
+#define MOR_LOCK_TEST_KEY 0x11111111
+
//
// TEST GUID for TCG Platform Reset Attack Mitigation MemoryOverwriteRequest (MOR) Test
@@ -107,6 +111,13 @@ TCGMemoryOverwriteRequestControlLockUnlockedState (
IN RESET_DATA *ResetData
);
+EFI_STATUS
+TCGMemoryOverwriteRequestControlLockLockedNoKeyState (
+ 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 fe8853452979..7e00224c325c 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
@@ -67,3 +67,28 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid018 = EFI_TEST_TCGMO
EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid019 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_019_GUID;
EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid020 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_020_GUID;
+<<<<<<< HEAD
+=======
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_021_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid022 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_022_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid023 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_023_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid024 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_024_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid025 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_025_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid026 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_026_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid027 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_027_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid028 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_028_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid029 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_029_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_030_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_031_GUID;
+>>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test)
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 fe5ca180c104..7780b390a5f2 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
@@ -43,6 +43,8 @@ Abstract:
#define LOCK_NO_KEY_STATE_TEST 5
+#define LOCK_WITH_KEY_STATE_TEST 6
+
/**
* Entry point for TCG Platform Reset Attack Mitigation MemoryOverwrite EFI Variables Function Test.
@@ -180,6 +182,16 @@ BBTestTCGMemoryOverwriteRequestFunctionTest (
}
CheckpointStepMatched = TRUE;
}
+ if (ResetData->CheckpointStep == LOCK_NO_KEY_STATE_TEST) {
+ //
+ // Test Checkpoint LOCK_NO_KEY_STATE_TEST
+ //
+ Status = TCGMemoryOverwriteRequestControlLockLockedNoKeyState (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
@@ -1247,3 +1259,463 @@ MORLOCK_UNLOCKED_STATE:
return EFI_SUCCESS;
}
+
+
+/**
+ * MemoryOverwriteRequestControlLock in locked-without-key state test
+ * When unlocked, a valid SetVariable() with Data value 0x01 must return EFI_SUCCESS
+ * and the lock value must be 0x01, value cannot change till the system is cold reset
+ *
+ * When locked-without-key, SetVariable() with Data = 0x01, 0x00, or 0x11111111 (key)
+ * must return EFI_ACCESS_DENIED and value must still equal 0x01
+ * @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
+TCGMemoryOverwriteRequestControlLockLockedNoKeyState (
+ 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;
+ UINTN MemoryOverwriteControlLockKeyValue;
+ UINT8 MemoryOverwriteRequestControlLockData;
+ UINT8 MemoryOverwriteRequestControlData;
+ UINT8 MemoryOverwriteRequestControlDataCached;
+ 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_LOCKED_STATE;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+
+INITIAL_RESET:
+ //
+ // Reset MORLOCK variable by performing a cold reset
+ //
+ ResetData->Step = 1;
+ ResetData->CheckpointStep = LOCK_NO_KEY_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;
+ }
+
+ 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_LOCKED_STATE:
+ //change checkpoint to next function
+ ResetData->Step = 0;
+ ResetData->CheckpointStep = LOCK_WITH_KEY_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;
+ }
+
+ //
+ // After Cold Reset, MORLOCK SetVariable() with value 0x01 must return EFI_SUCCESS
+ // and MORLOCK GetVariable() value must now be MOR_LOCK_DATA_LOCKED_WITHOUT_KEY
+ //
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ 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_SUCCESS) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021,
+ L"MemoryOverwriteRequestControlLock - Setting to locked-without-key when unlocked returns EFI_SUCCESS",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ 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_LOCKED_WITHOUT_KEY)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid022,
+ L"MemoryOverwriteRequestControlLock - Lock state is now locked-without-key",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Once locked-without-key, MORLOCK SetVariable() with value 0x00 must return EFI_ACCESS_DENIED
+ // and MORLOCK GetVariable() value must still be 0x01
+ //
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+ MemoryOverwriteRequestControlLockData = MOR_LOCK_DATA_UNLOCKED;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteRequestControlLockData // Data
+ );
+ if (Status == EFI_ACCESS_DENIED) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid023,
+ L"MemoryOverwriteRequestControlLock - Setting to unlocked when locked-without-key returns EFI_ACCESS_DENIED",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ 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_LOCKED_WITHOUT_KEY)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid024,
+ L"MemoryOverwriteRequestControlLock - Lock state is still locked-without-key",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Once locked-without-key, MORLOCK SetVariable() with value 0x01 must return EFI_ACCESS_DENIED
+ // and MORLOCK GetVariable() value must still be 0x01
+ //
+ DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+ 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_ACCESS_DENIED) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid025,
+ L"MemoryOverwriteRequestControlLock - Setting to locked-without-key when already locked-without-key returns EFI_ACCESS_DENIED",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ 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_LOCKED_WITHOUT_KEY)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid026,
+ L"MemoryOverwriteRequestControlLock - Lock state is still locked-without-key",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Once locked-without-key, MORLOCK SetVariable() with 8 byte key = 0x11111111 must return EFI_ACCESS_DENIED
+ // and MORLOCK GetVariable() value must still be 0x01
+ //
+ DataSize = MOR_LOCK_WITH_KEY_SIZE;
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+ MemoryOverwriteControlLockKeyValue = MOR_LOCK_TEST_KEY;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControlLock", // VariableName
+ &gEfiMemoryOverwriteRequestControlLockGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteControlLockKeyValue // Data
+ );
+ if (Status == EFI_ACCESS_DENIED) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid027,
+ L"MemoryOverwriteRequestControlLock - Setting to locked-with-key when locked-without-key returns EFI_ACCESS_DENIED",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ 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_LOCKED_WITHOUT_KEY)) {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid028,
+ L"MemoryOverwriteRequestControlLock - Lock state is still locked-without-key",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Once locked-without-key, MOR SetVariable() call to set MOR bit 0 must return EFI_ACCESS_DENIED
+ // and MOR value must not change
+ //
+ DataSize = sizeof(MemoryOverwriteRequestControlData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+ // getting current MOR bit 0 value that will be used to check that the variable is unchanged
+ Status = gtRT->GetVariable (
+ L"MemoryOverwriteRequestControl", // VariableName
+ &gEfiMemoryOverwriteControlDataGuid, // VendorGuid
+ &Attributes, // Attributes
+ &DataSize, // DataSize
+ &MemoryOverwriteRequestControlData // Data
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // caching MOR and then setting bit 0
+ MemoryOverwriteRequestControlDataCached = MemoryOverwriteRequestControlData;
+ MemoryOverwriteRequestControlData |= MOR_BIT_HIGH << MOR_CLEAR_MEMORY_BIT_OFFSET;
+
+ DataSize = sizeof(MemoryOverwriteRequestControlData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControl", // VariableName
+ &gEfiMemoryOverwriteControlDataGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteRequestControlData // Data
+ );
+ if (Status == EFI_ACCESS_DENIED) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid029,
+ L"MemoryOverwriteRequestControl - SetVariable() returns EFI_ACCESS_DENIED when MORLOCK is locked-without-key",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ DataSize = sizeof(MemoryOverwriteRequestControlData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+ Status = gtRT->GetVariable (
+ L"MemoryOverwriteRequestControl", // VariableName
+ &gEfiMemoryOverwriteControlDataGuid, // VendorGuid
+ &Attributes, // Attributes
+ &DataSize, // DataSize
+ &MemoryOverwriteRequestControlData // Data
+ );
+
+ // verifying that the variable has not been modified with SetVariable(), proving that MORLOCK acts as a lock
+ if (MemoryOverwriteRequestControlDataCached == MemoryOverwriteRequestControlData) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030,
+ L"MemoryOverwriteRequestControl - When locked-without-key, MOR bit 0 remains unchanged after an attempt to set it",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ //
+ // Once locked-without-key, MOR cannot be deleted
+ // SetVariable() call to set MOR with DataSize == 0 must return EFI_ACCESS_DENIED
+ // MemoryOverwriteControlData is a don't care in this case
+ DataSize = 0;
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControl", // VariableName
+ &gEfiMemoryOverwriteControlDataGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteRequestControlData // Data
+ );
+ if (Status == EFI_ACCESS_DENIED || EFI_INVALID_PARAMETER) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031,
+ 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",
+ L"%a:%d:Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
--
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]
-=-=-=-=-=-=-=-=-=-=-=-
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 ` [edk2-devel] [PATCH v4 3/6] uefi-sct/SctPkg: TCG MORLOCK " Abhimanyu Singh
2024-03-21 11:31 ` 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 ` Abhimanyu Singh [this message]
2024-03-21 11:32 ` [edk2-devel] [PATCH v4 5/6] uefi-sct/SctPkg: TCG MORLOCK Locked No Key " 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-6-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