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>
Subject: [edk2-devel] [PATCH v3 2/7] uefi-sct/SctPkg: TCG MOR SetVariable Test
Date: Wed, 14 Feb 2024 21:30:51 -0600 [thread overview]
Message-ID: <20240215033056.331060-3-Abhi.Singh@arm.com> (raw)
In-Reply-To: <20240215033056.331060-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 MemoryOverwriteRequestControlSetVariable test cases
-Add Assertions 5, 6, 7, and 8 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>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h | 20 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h | 7 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c | 8 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 140 ++++++++++++++++++++
4 files changed, 175 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 a3d87a3eb764..84175504579c 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
@@ -37,6 +37,18 @@ Abstract:
#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_004_GUID \
{ 0x002519c6, 0x859f, 0x4d25, {0xb1, 0x36, 0xb2, 0xef, 0x61, 0xe5, 0xd9, 0x6f }}
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_005_GUID \
+{ 0x13e97668, 0xe905, 0x452d, {0xa0, 0x72, 0x03, 0xde, 0xbf, 0x53, 0xdf, 0xa2 }}
+
+#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 }}
+
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;
@@ -44,3 +56,11 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid003;
extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid004;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid005;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid006;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid007;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid008;
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 45bd921ecca4..46c2c2faa388 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
@@ -85,6 +85,13 @@ TCGMemoryOverwriteRequestPlatformResetCheck (
IN RESET_DATA *ResetData
);
+EFI_STATUS
+TCGMemoryOverwriteRequestControlSetVariable (
+ 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 59c798a710f1..07bc98b8d764 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
@@ -35,3 +35,11 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002 = EFI_TEST_TCGMO
EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid003 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_003_GUID;
EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid004 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_004_GUID;
+
+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;
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 2f11926f123f..4a4133aac4ea 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
@@ -37,6 +37,8 @@ Abstract:
#define CONTROL_SET_VARIABLE_TEST 2
+#define LOCK_SET_VARIABLE_TEST 3
+
/**
* Entry point for TCG Platform Reset Attack Mitigation MemoryOverwrite EFI Variables Function Test.
@@ -126,6 +128,15 @@ BBTestTCGMemoryOverwriteRequestFunctionTest (
return Status;
}
}
+ if (ResetData->CheckpointStep == CONTROL_SET_VARIABLE_TEST) {
+ //
+ // Test Checkpoint CONTROL_SET_VARIABLE_TEST
+ //
+ Status = TCGMemoryOverwriteRequestControlSetVariable (StandardLib, RecoveryLib, ResetData);
+ if(EFI_ERROR(Status)) {
+ return Status;
+ }
+ }
//
// After all Checkpoints have run
//
@@ -408,3 +419,132 @@ MOR_BIT_CLEAR_ON_RESET:
return EFI_SUCCESS;
}
+
+
+/**
+ * MemoryOverwriteRequestControl EFI variable SetVariable() requests with a single invalid parameter
+ * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL
+ * instance.
+ * @param RecoveryLib A pointer to EFI_TEST_RECOVERY_LIBRARY_PROTOCOL
+ * instance.
+ * @return EFI_SUCCESS Successfully.
+ * @return Other value Something failed.
+ */
+EFI_STATUS
+TCGMemoryOverwriteRequestControlSetVariable (
+ 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 MemoryOverwriteRequestControlData;
+ UINT8 MemoryOverwriteRequestControlDataCached;
+ UINT32 Attributes;
+
+ //
+ // Write reset record to initiate checkpoint LOCK_SET_VARIABLE_TEST after these assertions are complete
+ //
+ ResetData->Step = 0;
+ 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;
+ }
+
+ //
+ // MOR SetVariable() with invalid Attributes == NV + BS returns EFI_INVALID_PARAMETER and value is unchanged
+ // SetVariable() with MOR bit 0 set and invalid Attributes = NV + BS
+ //
+ DataSize = sizeof(MemoryOverwriteRequestControlData);
+ Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+ Status = gtRT->GetVariable (
+ L"MemoryOverwriteRequestControl", // VariableName
+ &gEfiMemoryOverwriteControlDataGuid, // VendorGuid
+ &Attributes, // Attributes
+ &DataSize, // DataSize
+ &MemoryOverwriteRequestControlData // Data
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // caching variable for later comparison with the second GetVariable() value
+ MemoryOverwriteRequestControlDataCached = MemoryOverwriteRequestControlData;
+
+ DataSize = sizeof(MemoryOverwriteRequestControlData);
+ Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS;
+ MemoryOverwriteRequestControlData |= MOR_BIT_HIGH << MOR_CLEAR_MEMORY_BIT_OFFSET;
+
+ Status = gtRT->SetVariable (
+ L"MemoryOverwriteRequestControl", // VariableName
+ &gEfiMemoryOverwriteControlDataGuid, // VendorGuid
+ Attributes, // Attributes
+ DataSize, // DataSize
+ &MemoryOverwriteRequestControlData // Data
+ );
+ if (Status == EFI_INVALID_PARAMETER) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid005,
+ L"MemoryOverwriteRequestControl - SetVariable() with Attributes == NV returns EFI_INVALID_PARAMETER",
+ 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 MOR variable has not been modified with SetVariable()
+ if (MemoryOverwriteRequestControlDataCached == MemoryOverwriteRequestControlData) {
+ Result = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ Result = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ Result,
+ gTCGMemoryOverwriteRequestTestFunctionAssertionGuid006,
+ L"MemoryOverwriteRequestControl - SetVariable() with Attributes == NV variable value remains unchanged",
+ 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 (#115480): https://edk2.groups.io/g/devel/message/115480
Mute This Topic: https://groups.io/mt/104367130/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-02-15 3:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 3:30 [edk2-devel] [PATCH v3 0/7] EDK2-TEST TCG MOR Tests Abhimanyu Singh
2024-02-15 3:30 ` [edk2-devel] [PATCH v3 1/7] uefi-sct/SctPkg: TCG Platform Reset Check Test Abhimanyu Singh
2024-02-15 3:30 ` Abhimanyu Singh [this message]
2024-02-15 3:30 ` [edk2-devel] [PATCH v3 3/7] uefi-sct/SctPkg: TCG MORLOCK SetVariable Test Abhimanyu Singh
2024-02-15 3:30 ` [edk2-devel] [PATCH v3 4/7] uefi-sct/SctPkg: TCG MORLOCK Unlocked State Test Abhimanyu Singh
2024-02-15 3:30 ` [edk2-devel] [PATCH v3 5/7] uefi-sct/SctPkg: TCG MORLOCK Locked No Key " Abhimanyu Singh
2024-02-15 3:30 ` [edk2-devel] [PATCH v3 6/7] uefi-sct/SctPkg: TCG MORLOCK Locked with " Abhimanyu Singh
2024-02-15 3:30 ` [edk2-devel] [PATCH v3 7/7] uefi-sct/SctPkg: TCG MOR & MORLOCK tests Abhimanyu Singh
2024-02-15 16:46 ` [edk2-devel] [PATCH v3 0/7] EDK2-TEST TCG MOR Tests Stuart Yoder
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=20240215033056.331060-3-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