public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Stuart Yoder" <stuart.yoder@arm.com>
To: devel@edk2.groups.io, Abhi.Singh@arm.com
Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>,
	Barton Gao <gaojie@byosoft.com.cn>,
	Carolyn Gjertsen <Carolyn.Gjertsen@amd.com>
Subject: Re: [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG MORLOCK SetVariable Test
Date: Thu, 21 Sep 2023 14:03:24 -0500	[thread overview]
Message-ID: <ab4fd7d8-9f15-c390-563d-d941862ac588@arm.com> (raw)
In-Reply-To: <20230921163748.275971-4-Abhi.Singh@arm.com>

See inline comments...

On 9/21/23 11:37 AM, Abhimanyu Singh via groups.io wrote:
> 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 9 through 18 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>
> Change-Id: I23ba7256441354f497ecdc96a394df5ba5cae8df
> ---

[cut]

> +
> +  // MORLOCK SetVariable 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,
> +                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid011,
> +                  L"MemoryOverwriteRequestControlLock - SetVariable() with DataSize == 0 returns EFI_WRITE_PROTECTED",
> +                  L"%a:%d:Status - %r",
> +                  __FILE__,
> +                  (UINTN)__LINE__,
> +                  Status
> +                  );
> +
> +  // change datasize to valid value before GetVariable
> +  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
> +  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
> +
> +  // now check that MORLOCK value is still 0x00 or Unlocked
> +  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 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_INVALID_PARAMETER) {
> +    Result = EFI_TEST_ASSERTION_PASSED;
> +  } else {
> +    Result = EFI_TEST_ASSERTION_FAILED;
> +  }

This code checks for EFI_INVALID_PARAMETER, which seems correct.  But,
it does not match the SCT specification for these tests on the
bugzilla ticket, which says that EFI_WRITE_PROTECTED is expected.
I think you need to fix the spec.

Thanks,
Stuart



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108964): https://edk2.groups.io/g/devel/message/108964
Mute This Topic: https://groups.io/mt/101504339/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-09-21 19:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 16:37 [edk2-devel] [PATCH v2 0/6] RESEND: TCG MemoryOverwriteRequest Tests Abhimanyu Singh
2023-09-21 16:37 ` [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG Platform Reset Check Test Abhimanyu Singh
2023-09-21 16:37 ` [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG MOR SetVariable Test Abhimanyu Singh
2023-09-21 19:03   ` Stuart Yoder
2023-09-21 16:37 ` [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG MORLOCK " Abhimanyu Singh
2023-09-21 19:03   ` Stuart Yoder [this message]
2023-09-21 16:37 ` [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG MORLOCK Unlocked State Test Abhimanyu Singh
2023-09-21 19:03   ` Stuart Yoder
2023-09-21 16:37 ` [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG MORLOCK Locked No Key " Abhimanyu Singh
2023-09-21 19:03   ` Stuart Yoder
2023-09-21 16:37 ` [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG MORLOCK Locked with " Abhimanyu Singh
2023-09-21 19:03   ` Stuart Yoder
2023-09-21 19:03 ` [edk2-devel] [PATCH v2 0/6] RESEND: TCG MemoryOverwriteRequest Tests Stuart Yoder
  -- strict thread matches above, loose matches on Subject: below --
2023-08-23  2:09 [edk2-devel] [PATCH v2 0/6] " Abhimanyu Singh
2023-08-23  2:09 ` [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG MORLOCK SetVariable Test Abhimanyu Singh

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=ab4fd7d8-9f15-c390-563d-d941862ac588@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