public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "Rhodes, Sean" <sean@starlabs.systems>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Rhodes, Sean" <sean@starlabs.systems>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>,
	"Gao, Liming" <gaoliming@byosoft.com.cn>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment
Date: Mon, 16 May 2022 06:54:07 +0000	[thread overview]
Message-ID: <DM6PR11MB4025F07843A1C116B9632769CACF9@DM6PR11MB4025.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CABtds-1Y9MN64amc8pA2LDDEPT3fNx+J=TdukdedWqpCuRcQtg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5302 bytes --]

Sorry for a question.

I referred the code in InitFtwDevice():
  FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwWorkingBase64);
  if (FtwDevice->WorkSpaceAddress == 0) {
    FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwWorkingBase);
  }

and the PCD definition in MdeModulePkg.dec:
  ## Base address of the FTW working block range in flash device.
  # If PcdFlashNvStorageFtwWorkingSize is larger than one block size, this value should be block size aligned.
  # @Prompt Base address of flash FTW working block range.
  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x0|UINT32|0x30000010

  ## 64-bit Base address of the FTW working block range in flash device.
  # If PcdFlashNvStorageFtwWorkingSize is larger than one block size, this value should be block size aligned.
  # @Prompt 64-bit Base address of flash FTW working block range.
  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0x0|UINT64|0x80000010

The description of both PCDs mentioned a block size alignment requirement.
Does the change in this patch conflict with the above PCD description?

(SpareAreaAddress is having a similar case.)

Best Regards,
Hao Wu

From: Sean Rhodes <sean@starlabs.systems>
Sent: Monday, May 16, 2022 1:41 PM
To: devel@edk2.groups.io; Rhodes, Sean <sean@starlabs.systems>
Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

Hi

Would any one be able to review please?

Thank you

On Fri, 1 Apr 2022, 09:03 Sean Rhodes via groups.io<http://groups.io>, <sean=starlabs.systems@groups.io<mailto:starlabs.systems@groups.io>> wrote:
WorkSpaceAddress and SpareAreaAddress point into MMIO, which isn't
always aligned. Remove the check for block alignment to avoid
false assertions.

Cc: Jian J Wang <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>
Cc: Hao A Wu <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>
Cc: Liming Gao <gaoliming@byosoft.com.cn<mailto:gaoliming@byosoft.com.cn>>
Signed-off-by: Sean Rhodes <sean@starlabs.systems<mailto:sean@starlabs.systems>>
Change-Id: Ia1c1f44b6a0e7f32cac0d7806e74d729e5d83a6d
---
 .../Universal/FaultTolerantWriteDxe/FtwMisc.c    | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
index 661e148767..3b9ff1c828 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
@@ -1121,12 +1121,10 @@ FindFvbForFtw (
           FtwDevice->NumberOfWorkSpaceBlock = FTW_BLOCKS (FtwDevice->FtwWorkSpaceBase + FtwDevice->FtwWorkSpaceSize, FtwDevice->WorkBlockSize);
           if (FtwDevice->FtwWorkSpaceSize >= FtwDevice->WorkBlockSize) {
             //
-            // Check the alignment of work space address and length, they should be block size aligned when work space size is larger than one block size.
+            // Check the alignment of work space length, it should be block size aligned when work space size is larger than one block size.
             //
-            if (((FtwDevice->WorkSpaceAddress & (FtwDevice->WorkBlockSize - 1)) != 0) ||
-                ((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize - 1)) != 0))
-            {
-              DEBUG ((DEBUG_ERROR, "Ftw: Work space address or length is not block size aligned when work space size is larger than one block size\n"));
+            if ((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize - 1)) != 0) {
+              DEBUG ((EFI_D_ERROR, "Ftw: Work space length is not block size aligned when work space size is larger than one block size\n"));
               FreePool (HandleBuffer);
               ASSERT (FALSE);
               return EFI_ABORTED;
@@ -1171,12 +1169,10 @@ FindFvbForFtw (
           }

           //
-          // Check the alignment of spare area address and length, they should be block size aligned
+          // Check the alignment of spare area length, it should be block size aligned
           //
-          if (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize - 1)) != 0) ||
-              ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1)) != 0))
-          {
-            DEBUG ((DEBUG_ERROR, "Ftw: Spare area address or length is not block size aligned\n"));
+          if ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1)) != 0) {
+            DEBUG ((EFI_D_ERROR, "Ftw: Spare area address or length is not block size aligned\n"));
             FreePool (HandleBuffer);
             //
             // Report Status Code EFI_SW_EC_ABORTED.
--
2.32.0



------------
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88320): https://edk2.groups.io/g/devel/message/88320
Mute This Topic: https://groups.io/mt/90173290/6718866
Group Owner: devel+owner@edk2.groups.io<mailto:devel%2Bowner@edk2.groups.io>
Unsubscribe: https://edk2.groups.io/g/devel/unsub [sean@starlabs.systems]
------------


[-- Attachment #2: Type: text/html, Size: 10696 bytes --]

  reply	other threads:[~2022-05-16  6:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <16E1B70DABEEDF46.30116@groups.io>
2022-05-16  5:41 ` [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment Sean Rhodes
2022-05-16  6:54   ` Wu, Hao A [this message]
2022-05-16  6:59     ` Sean Rhodes
2022-05-16  7:36       ` Wu, Hao A
2022-05-16  7:53         ` Sean Rhodes
2022-05-16  9:03           ` Wu, Hao A
2022-05-17 11:58             ` Sheng Lean Tan
2022-05-17 15:05               ` Zeng, Star
2022-05-17 15:16                 ` Sean Rhodes
2022-10-03  9:53                   ` Sheng Lean Tan

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=DM6PR11MB4025F07843A1C116B9632769CACF9@DM6PR11MB4025.namprd11.prod.outlook.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