From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by mx.groups.io with SMTP id smtpd.web10.25106.1652679684872734533 for ; Sun, 15 May 2022 22:41:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@starlabs-systems.20210112.gappssmtp.com header.s=20210112 header.b=RqJ7XtMd; spf=pass (domain: starlabs.systems, ip: 209.85.219.176, mailfrom: sean@starlabs.systems) Received: by mail-yb1-f176.google.com with SMTP id j84so14305010ybc.3 for ; Sun, 15 May 2022 22:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=starlabs-systems.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aHJdFpu7iO8imxuW8ZrZfPxul3dF6Tpgjf0twUUlnfQ=; b=RqJ7XtMdUH4747ZZ4HkWfP5oFK+K7psDTdGrT2yL7hwHe/sPqANH48I62X2kNnDf2U PZoNBubIYNHQhUS9q1EHN5hHWYIWnq1J4HnImeizAeCJ6RpTHJH9TxuhPpm1XtqSAZfi iZ3UTqG0MzKNdCtWy4aqyIhxbPFdV0k5QdsatDmcP9lzSF9bMO4nVy+aQuHO5rm5WTDa Skp+Cu/Hz3HF9HWBH2lMqghUX6gh3gBrivwcATfRthETo/Bz3nJbvczu4yFPHuw5I300 k0VzN37iSXPXDv31yQIdGWmVj9g4tULNxdwUpia2n/l+KsPHfqFEh8ncGTIUsONxcC9X CvNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aHJdFpu7iO8imxuW8ZrZfPxul3dF6Tpgjf0twUUlnfQ=; b=i7mdHOuvWA3N24LYCWtPRBuPDrz80eIT04vEZ+d01+sWJtBGgDrUV4LVt5955p6K1c RyFFa3Mf+M4wAuGsTccV0QQ7cz7Mf+QrmG03UsY/oc4A11pza40hURV7wBUbXHYJXar2 kRE4gDfYPebj4kb5j0KVsKHFdcnFDeGR//FLuBmPMk2AJ0RQWhpFT2Wsw+id58FRoTCG 3XlGXPBsH11HV58Ei1eAgKKngz72mkdFxeBzQ8+L48TG04vLp5yPGYgUGoVjZx3FpEhg N0igcMjOOK2+8+z5qRN0ADHGQSdZD7tqV3LDd9qrjM32tXd+pRXlCtMIfD0SyOdLiJ6l 9K5g== X-Gm-Message-State: AOAM531NlFxKATl8Yc/+H+8h17sa2F57berHVD9Icq368cFTeCUTD7/3 gUNfpg4aWc+xcdchqphPcctmi6v9OLu1ZR6NnsIVI6QxHw== X-Google-Smtp-Source: ABdhPJwZMfJd3TNH3rXRsxnSiizxpq+IRBbRVAOnH2XF03hxS2gx15f6fyHaCYEihfWW2ZWVR4oxXU/5NLQ63Ds7ZOw= X-Received: by 2002:a25:258:0:b0:64d:6b57:bf25 with SMTP id 85-20020a250258000000b0064d6b57bf25mr8108622ybc.193.1652679682875; Sun, 15 May 2022 22:41:22 -0700 (PDT) MIME-Version: 1.0 References: <16E1B70DABEEDF46.30116@groups.io> In-Reply-To: <16E1B70DABEEDF46.30116@groups.io> From: "Sean Rhodes" Date: Mon, 16 May 2022 06:41:11 +0100 Message-ID: Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment To: devel@edk2.groups.io, Sean Rhodes Cc: Jian J Wang , Hao A Wu , Liming Gao Content-Type: multipart/alternative; boundary="0000000000006d001405df1a79ee" --0000000000006d001405df1a79ee Content-Type: text/plain; charset="UTF-8" Hi Would any one be able to review please? Thank you On Fri, 1 Apr 2022, 09:03 Sean Rhodes via 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 > Cc: Hao A Wu > Cc: Liming Gao > Signed-off-by: Sean Rhodes > 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 > Unsubscribe: https://edk2.groups.io/g/devel/unsub [sean@starlabs.systems] > ------------ > > > --0000000000006d001405df1a79ee Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

Would any= one be able to review please?

Thank you

On Fri, 1 Apr 2022, 09:03 Sean Rhodes via groups.io, <sean=3Dstarlabs.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>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: Ia1c1f44b6a0e7f32cac0d7806e74d729e5d83a6d
---
=C2=A0.../Universal/FaultTolerantWriteDxe/FtwMisc.c=C2=A0 =C2=A0 | 16 +++++= +----------
=C2=A01 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 (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FtwDevice->NumberOfWorkSpaceBlo= ck =3D FTW_BLOCKS (FtwDevice->FtwWorkSpaceBase + FtwDevice->FtwWorkSp= aceSize, FtwDevice->WorkBlockSize);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (FtwDevice->FtwWorkSpaceSize= >=3D FtwDevice->WorkBlockSize) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Check the alignment of work s= pace address and length, they should be block size aligned when work space = size is larger than one block size.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Check the alignment of work s= pace length, it should be block size aligned when work space size is larger= than one block size.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (((FtwDevice->WorkSpaceAdd= ress & (FtwDevice->WorkBlockSize - 1)) !=3D 0) ||
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((FtwDevice->Wo= rkSpaceLength & (FtwDevice->WorkBlockSize - 1)) !=3D 0))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DEBUG ((DEBUG_ERROR, &quo= t;Ftw: Work space address or length is not block size aligned when work spa= ce size is larger than one block size\n"));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((FtwDevice->WorkSpaceLeng= th & (FtwDevice->WorkBlockSize - 1)) !=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DEBUG ((EFI_D_ERROR, &quo= t;Ftw: Work space length is not block size aligned when work space size is = larger than one block size\n"));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FreePool (HandleBuff= er);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ASSERT (FALSE);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return EFI_ABORTED;<= br> @@ -1171,12 +1169,10 @@ FindFvbForFtw (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Check the alignment of spare area ad= dress and length, they should be block size aligned
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Check the alignment of spare area le= ngth, it should be block size aligned
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (((FtwDevice->SpareAreaAddress &a= mp; (FtwDevice->SpareBlockSize - 1)) !=3D 0) ||
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((FtwDevice->SpareArea= Length & (FtwDevice->SpareBlockSize - 1)) !=3D 0))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DEBUG ((DEBUG_ERROR, "Ftw: = Spare area address or length is not block size aligned\n"));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((FtwDevice->SpareAreaLength &= ; (FtwDevice->SpareBlockSize - 1)) !=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DEBUG ((EFI_D_ERROR, "Ftw: = Spare area address or length is not block size aligned\n"));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FreePool (HandleBuffer); =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0// Report Status Code EFI_S= W_EC_ABORTED.
--
2.32.0



------------
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88320): https://edk2.grou= ps.io/g/devel/message/88320
Mute This Topic: https://groups.io/mt/90173290/67188= 66
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub= [sean@starlabs.systems]
------------


--0000000000006d001405df1a79ee--