From nobody Sun Nov 24 08:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+89742+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+89742+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1652684937; cv=none; d=zohomail.com; s=zohoarc; b=QcwtoqIR7UnaGAeEhq4R8kAo72PL+Rbvu1hze1nUtkK1ffIxFP9eDJpwgdJ8x5cEhOtaSOsEqLEyoadgThF31BuJ+xzBVMZEHNAWkYlc15qW7k15um2hceGx0/STxLhvGFkWsidROk5ZK8+SS+AotntojQLaDcqYV5HFHNW6UkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652684937; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=Nf4WqB1388FPnNjWRgpaeh11TvudazzexLluJuPnQdY=; b=aVO+YvzBkd2IqHrzNWU+baYcVzsxiDdvZnUWPrjIRYWfx/OG7D5HQ926SlNmCYteUBeDkytZ4ghDBJ2EwEKIvuuwmmIhMXofOlVkzkY+WtFojUa4TNCzJCWdadVUFd6WHEaprWFcMyOiDBH5w8pMs+pOMiFhB7xVMUMwmb+oR08= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+89742+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1652684937881953.1015373861007; Mon, 16 May 2022 00:08:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id YNf0YY1788612xYPgv31RL73; Mon, 16 May 2022 00:08:57 -0700 X-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 X-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: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment Date: Mon, 16 May 2022 08:08:49 +0100 Message-Id: MIME-Version: 1.0 X-Originating-smarthost01b-IP: [51.148.147.4] Feedback-ID: 51.148.147.4 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sean@starlabs.systems X-Gm-Message-State: nUuXbtzG1WNZp7heg2uukbilx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652684937; bh=FPYhU7GUlzrQV4q9lwKxFLtRU95gGuqxd2JR9SQuocE=; h=Cc:Date:From:Reply-To:Subject:To; b=qFTYVgEZMHWudBM1qdzKJOp8zWe3AlaXBV+8jrHHaR999eNgQTLW3031lZETF8/Yst7 KBJcA+nYVtiTb7QhIcUzxp2cX3ZEN+Nvi+QJ/ymVsI7fiFSy+AkthoysJ95rN7i9MdVnu evQa0TxAT+TxKK0mLUq/8BWYkr1NRJzng94= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652684939379100002 Content-Type: text/plain; charset="utf-8" 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 =20 ## 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|UINT3= 2|0x30000010 =20 @@ -1668,7 +1667,6 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0x0|UINT6= 4|0x80000013 =20 ## 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|UIN= T64|0x80000010 =20 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 @@ =20 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= _PROMPT #language en-US "Base address of flash FTW working block range" =20 -#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." +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= _HELP #language en-US "Base address of the FTW working block range in flas= h device." =20 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingSize= _PROMPT #language en-US "Size of flash FTW working block range" =20 @@ -390,7 +390,7 @@ =20 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= 64_PROMPT #language en-US "64-bit Base address of flash FTW working block = range" =20 -#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." +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase= 64_HELP #language en-US "64-bit Base address of the FTW working block rang= e in flash device." =20 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvModeEnable_PROM= PT #language en-US "EMU variable NV mode enable" =20 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 // for (LbaIndex =3D 1; LbaIndex <=3D NumberOfBlocks; LbaIndex +=3D 1) { - if ( (FtwDevice->WorkSpaceAddress >=3D (FvbBaseAddress + BlockSiz= e * (LbaIndex - 1))) - && (FtwDevice->WorkSpaceAddress < (FvbBaseAddress + BlockSize *= LbaIndex))) + if ((FtwDevice->WorkSpaceAddress - FvbBaseAddress >=3D BlockSize *= (LbaIndex - 1)) && + ((FtwDevice->WorkSpaceAddress - FvbBaseAddress) / BlockSize >= =3D LbaIndex - 1)) { FtwDevice->FtwWorkSpaceLba =3D LbaIndex - 1; // @@ -1121,12 +1121,10 @@ FindFvbForFtw ( FtwDevice->NumberOfWorkSpaceBlock =3D FTW_BLOCKS (FtwDevice->Ftw= WorkSpaceBase + FtwDevice->FtwWorkSpaceSize, FtwDevice->WorkBlockSize); if (FtwDevice->FtwWorkSpaceSize >=3D 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 bloc= k size aligned when work space size is larger than one block size. // - if (((FtwDevice->WorkSpaceAddress & (FtwDevice->WorkBlockSize = - 1)) !=3D 0) || - ((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize -= 1)) !=3D 0)) - { - 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"= )); + if ((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize - = 1)) !=3D 0) { + 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")); FreePool (HandleBuffer); ASSERT (FALSE); return EFI_ABORTED; @@ -1171,12 +1169,10 @@ FindFvbForFtw ( } =20 // - // Check the alignment of spare area address and length, they sh= ould be block size aligned + // Check the alignment of spare area length, it should be block = size aligned // - if (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize -= 1)) !=3D 0) || - ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - = 1)) !=3D 0)) - { - DEBUG ((DEBUG_ERROR, "Ftw: Spare area address or length is not= block size aligned\n")); + if ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1= )) !=3D 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. --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#89742): https://edk2.groups.io/g/devel/message/89742 Mute This Topic: https://groups.io/mt/91134149/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-