[PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment


Sean Rhodes
 

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@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Liming Gao <gaoliming@...>
Signed-off-by: Sean Rhodes <sean@...>
Change-Id: Ia1c1f44b6a0e7f32cac0d7806e74d729e5d83a6d
---
.../Universal/FaultTolerantWriteDxe/FtwMisc.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c b/MdeMo=
dulePkg/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 =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.32.0

Join devel@edk2.groups.io to automatically receive all group messages.