[edk2-devel] [PATCH 2/2] uefi-sct/SctPkg: Correct BBTestEraseBlocks behavior (EFI_BLOCK_IO_PROTOCOL)

Samer El-Haj-Mahmoud samer.el-haj-mahmoud at arm.com
Wed Nov 11 20:56:25 UTC 2020


Hi Chen,

The UEFI Specification 2.8ErrataB (page 575) states that " It is the intention of the EraseBlocks() operation to be at least as performant as writing zeroes to each of the specified LBA locations while ensuring the equivalent security."

So while not explicitly saying that Erase should "erase to 0", it implies that at least is the intention. Do we know that erasing to "1" is a valid behavior?



> -----Original Message-----
> From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Chen,
> ArvinX via groups.io
> Sent: Monday, November 2, 2020 5:00 AM
> To: devel at edk2.groups.io
> Cc: G Edhaya Chandran <Edhaya.Chandran at arm.com>; Eric Jin
> <eric.jin at intel.com>
> Subject: [edk2-devel] [PATCH 2/2] uefi-sct/SctPkg: Correct
> BBTestEraseBlocks behavior (EFI_BLOCK_IO_PROTOCOL)
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3022
>
>
>
> The storage device erase behavior may have two possibilities:
>
>  1.Write all data into "0"
>
>  2.Write all data into "1"
>
> but now tool behavior can only check case 1 (Write all data into "0"),
>
> so we need add the other case into SCT tool to correct the test behavior.
>
>
>
> Cc: G Edhaya Chandran <Edhaya.Chandran at arm.com>
>
> Cc: Eric Jin <eric.jin at intel.com>
>
> Signed-off-by: ArvinX Chen <arvinx.chen at intel.com>
>
> ---
>
>  .../BlackBoxTest/EraseBlockBBTestFunction.c   | 55 +++++++++++++++----
>
>  1 file changed, 43 insertions(+), 12 deletions(-)
>
>
>
> diff --git a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlock
> BBTestFunction.c b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlock
> BBTestFunction.c
>
> index cbf43e1d..dbbb70c6 100644
>
> --- a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlock
> BBTestFunction.c
>
> +++ b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlock
> BBTestFunction.c
>
> @@ -71,6 +71,7 @@ BBTestEraseBlocksFunctionTest (
>
>    UINT64                                Index;
>
>    UINTN                                 Index1;
>
>    UINTN                                 Remainder;
>
> +  UINT64                                EraseCounter;
>
>
>
>    EFI_ERASE_BLOCK_TOKEN                 Token;
>
>    EFI_BLOCK_IO2_TOKEN                   BlockIo2Token;
>
> @@ -223,26 +224,41 @@ BBTestEraseBlocksFunctionTest (
>
>          // Read the data with 0, the first/last block should not be erased
>
>          ReadStatus = BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferSize,
> (VOID*)Buffer2);
>
>          if (ReadStatus == EFI_SUCCESS) {
>
> -          for (Index1 = 0; Index1 < BlockSize; Index1++) {
>
> -            if (Buffer2[Index1] != 0) {
>
> +          for (Index1 = 0, EraseCounter = 0; Index1 < BlockSize; Index1++) {
>
> +            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
>
>                IsZero1 = FALSE;
>
>                break;
>
> +            } else if (Buffer2[Index1] == 0x00) {
>
> +              EraseCounter++;
>
>              }
>
>            }
>
> +          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
>
> +            IsZero1 = FALSE;
>
> +          }
>
>
>
> -          for (Index1 = BlockSize; Index1 < BufferSize - BlockSize; Index1++) {
>
> -            if (Buffer2[Index1] != 0) {
>
> +          for (Index1 = BlockSize, EraseCounter = 0; Index1 < BufferSize -
> BlockSize; Index1++) {
>
> +            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
>
>                IsZero2 = FALSE;
>
>                break;
>
> +            } else if (Buffer2[Index1] == 0x00) {
>
> +              EraseCounter++;
>
>              }
>
>            }
>
> +          if (EraseCounter!=0 && EraseCounter!=(BufferSize - (BlockSize*2))) {
>
> +            IsZero2 = FALSE;
>
> +          }
>
>
>
> -          for (Index1 = BufferSize - BlockSize; Index1 < BufferSize; Index1++) {
>
> -            if (Buffer2[Index1] != 0) {
>
> +          for (Index1 = BufferSize - BlockSize, EraseCounter = 0; Index1 <
> BufferSize; Index1++) {
>
> +            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
>
>                IsZero3 = FALSE;
>
>                break;
>
> +            } else if (Buffer2[Index1] == 0x00) {
>
> +              EraseCounter++;
>
>              }
>
>            }
>
> +          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
>
> +            IsZero3 = FALSE;
>
> +          }
>
>
>
>            if ((EraseStatus == EFI_SUCCESS) && (IsZero1 == FALSE) && (IsZero2 ==
> TRUE) && ((IsZero3 == FALSE)))
>
>              AssertionType = EFI_TEST_ASSERTION_PASSED;
>
> @@ -492,26 +508,41 @@ BlockIo2:
>
>          // Read the data with 0, the first/last block should not be erased
>
>          ReadStatus = BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba,
> &BlockIo2Token, BufferSize, (VOID*)Buffer2);
>
>          if (ReadStatus == EFI_SUCCESS) {
>
> -          for (Index1 = 0; Index1 < BlockSize; Index1++) {
>
> -            if (Buffer2[Index1] != 0) {
>
> +          for (Index1 = 0, EraseCounter = 0; Index1 < BlockSize; Index1++) {
>
> +            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
>
>                IsZero1 = FALSE;
>
>                break;
>
> +            } else if (Buffer2[Index1] == 0x00) {
>
> +              EraseCounter++;
>
>              }
>
>            }
>
> +          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
>
> +            IsZero1 = FALSE;
>
> +          }
>
>
>
> -          for (Index1 = BlockSize; Index1 < BufferSize - BlockSize; Index1++) {
>
> -            if (Buffer2[Index1] != 0) {
>
> +          for (Index1 = BlockSize, EraseCounter = 0; Index1 < BufferSize -
> BlockSize; Index1++) {
>
> +            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
>
>                IsZero2 = FALSE;
>
>                break;
>
> +            } else if (Buffer2[Index1] == 0x00) {
>
> +              EraseCounter++;
>
>              }
>
>            }
>
> +          if (EraseCounter!=0 && EraseCounter!=(BufferSize - (BlockSize*2))) {
>
> +            IsZero2 = FALSE;
>
> +          }
>
>
>
> -          for (Index1 = BufferSize - BlockSize; Index1 < BufferSize; Index1++) {
>
> -            if (Buffer2[Index1] != 0) {
>
> +          for (Index1 = BufferSize - BlockSize, EraseCounter = 0; Index1 <
> BufferSize; Index1++) {
>
> +            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
>
>                IsZero3 = FALSE;
>
>                break;
>
> +            } else if (Buffer2[Index1] == 0x00) {
>
> +              EraseCounter++;
>
>              }
>
>            }
>
> +          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
>
> +            IsZero3 = FALSE;
>
> +          }
>
>
>
>            if ((EraseStatus == EFI_SUCCESS) && (IsZero1 == FALSE) && (IsZero2 ==
> TRUE) && ((IsZero3 == FALSE)))
>
>              AssertionType = EFI_TEST_ASSERTION_PASSED;
>
> --
>
> 2.26.2.windows.1
>
>
>
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#66857): https://edk2.groups.io/g/devel/message/66857
> Mute This Topic: https://groups.io/mt/77977762/1945644
> Group Owner: devel+owner at edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [samer.el-haj-
> mahmoud at arm.com]
> -=-=-=-=-=-=
>

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#67305): https://edk2.groups.io/g/devel/message/67305
Mute This Topic: https://groups.io/mt/77977762/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list