From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smarthost01b.ixn.mail.zen.net.uk (smarthost01b.ixn.mail.zen.net.uk [212.23.1.21]) by mx.groups.io with SMTP id smtpd.web10.25648.1652684935040125422 for ; Mon, 16 May 2022 00:08:55 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=permerror, err=parse error for token &{10 18 sdn.klaviyomail.com}: permanent DNS error (domain: starlabs.systems, ip: 212.23.1.21, mailfrom: sean@starlabs.systems) Received: from [51.148.147.4] (helo=sean-StarBook.lan) by smarthost01b.ixn.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nqUqa-0003sB-Nt; Mon, 16 May 2022 07:08:52 +0000 From: "Sean Rhodes" To: devel@edk2.groups.io Cc: Sean Rhodes Subject: [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment Date: Mon, 16 May 2022 08:08:49 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-smarthost01b-IP: [51.148.147.4] Feedback-ID: 51.148.147.4 Content-Transfer-Encoding: quoted-printable WorkSpaceAddress and SpareAreaAddress point into MMIO, which isn't always aligned. Remove the check for block alignment to avoid false assertions. Signed-off-by: Sean Rhodes Change-Id: Ia1c1f44b6a0e7f32cac0d7806e74d729e5d83a6d --- MdeModulePkg/MdeModulePkg.dec | 2 -- MdeModulePkg/MdeModulePkg.uni | 4 ++-- .../Universal/FaultTolerantWriteDxe/FtwMisc.c | 20 ++++++++----------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index cf79292ec8..b7e2f48028 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1649,7 +1649,6 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x0|UINT32|= 0x30000014=0D =0D ## Base address of the FTW working block range in flash device.=0D - # If PcdFlashNvStorageFtwWorkingSize is larger than one block size, this= value should be block size aligned.=0D # @Prompt Base address of flash FTW working block range.=0D gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x0|UINT3= 2|0x30000010=0D =0D @@ -1668,7 +1667,6 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0x0|UINT6= 4|0x80000013=0D =0D ## 64-bit Base address of the FTW working block range in flash device.=0D - # If PcdFlashNvStorageFtwWorkingSize is larger than one block size, this= value should be block size aligned.=0D # @Prompt 64-bit Base address of flash FTW working block range.=0D gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0x0|UIN= T64|0x80000010=0D =0D diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index b070f15ff2..9f916506f7 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -374,7 +374,7 @@ =0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= _PROMPT #language en-US "Base address of flash FTW working block range"=0D =0D -#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= _HELP #language en-US "Base address of the FTW working block range in flas= h device. If PcdFlashNvStorageFtwWorkingSize is larger than one block size,= this value should be block size aligned."=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= _HELP #language en-US "Base address of the FTW working block range in flas= h device."=0D =0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingSize= _PROMPT #language en-US "Size of flash FTW working block range"=0D =0D @@ -390,7 +390,7 @@ =0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= 64_PROMPT #language en-US "64-bit Base address of flash FTW working block = range"=0D =0D -#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= 64_HELP #language en-US "64-bit Base address of the FTW working block rang= e in flash device. If PcdFlashNvStorageFtwWorkingSize is larger than one bl= ock size, this value should be block size aligned."=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= 64_HELP #language en-US "64-bit Base address of the FTW working block rang= e in flash device."=0D =0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvModeEnable_PROM= PT #language en-US "EMU variable NV mode enable"=0D =0D diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c b/MdeMo= dulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c index 661e148767..2fce694f22 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c @@ -1108,8 +1108,8 @@ FindFvbForFtw ( // To get the LBA of work space=0D //=0D for (LbaIndex =3D 1; LbaIndex <=3D NumberOfBlocks; LbaIndex +=3D 1) = {=0D - if ( (FtwDevice->WorkSpaceAddress >=3D (FvbBaseAddress + BlockSiz= e * (LbaIndex - 1)))=0D - && (FtwDevice->WorkSpaceAddress < (FvbBaseAddress + BlockSize *= LbaIndex)))=0D + if ((FtwDevice->WorkSpaceAddress - FvbBaseAddress >=3D BlockSize *= (LbaIndex - 1)) &&=0D + ((FtwDevice->WorkSpaceAddress - FvbBaseAddress) / BlockSize >= =3D LbaIndex - 1))=0D {=0D FtwDevice->FtwWorkSpaceLba =3D LbaIndex - 1;=0D //=0D @@ -1121,12 +1121,10 @@ FindFvbForFtw ( FtwDevice->NumberOfWorkSpaceBlock =3D FTW_BLOCKS (FtwDevice->Ftw= WorkSpaceBase + FtwDevice->FtwWorkSpaceSize, FtwDevice->WorkBlockSize);=0D if (FtwDevice->FtwWorkSpaceSize >=3D FtwDevice->WorkBlockSize) {= =0D //=0D - // 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.=0D + // Check the alignment of work space length, it should be bloc= k size aligned when work space size is larger than one block size.=0D //=0D - if (((FtwDevice->WorkSpaceAddress & (FtwDevice->WorkBlockSize = - 1)) !=3D 0) ||=0D - ((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize -= 1)) !=3D 0))=0D - {=0D - DEBUG ((DEBUG_ERROR, "Ftw: Work space address or length is n= ot block size aligned when work space size is larger than one block size\n"= ));=0D + if ((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize - = 1)) !=3D 0) {=0D + DEBUG ((EFI_D_ERROR, "Ftw: Work space length is not block si= ze aligned when work space size is larger than one block size\n"));=0D FreePool (HandleBuffer);=0D ASSERT (FALSE);=0D return EFI_ABORTED;=0D @@ -1171,12 +1169,10 @@ FindFvbForFtw ( }=0D =0D //=0D - // Check the alignment of spare area address and length, they sh= ould be block size aligned=0D + // Check the alignment of spare area length, it should be block = size aligned=0D //=0D - if (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize -= 1)) !=3D 0) ||=0D - ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - = 1)) !=3D 0))=0D - {=0D - DEBUG ((DEBUG_ERROR, "Ftw: Spare area address or length is not= block size aligned\n"));=0D + if ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1= )) !=3D 0) {=0D + DEBUG ((EFI_D_ERROR, "Ftw: Spare area address or length is not= block size aligned\n"));=0D FreePool (HandleBuffer);=0D //=0D // Report Status Code EFI_SW_EC_ABORTED.=0D --=20 2.34.1