Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-10-03 Thread Sheng Lean Tan
Hi Wu Hao/ Zeng Star,
Any update on this? :)


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94663): https://edk2.groups.io/g/devel/message/94663
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-17 Thread Sean Rhodes
Hi Star

I think the point is shown in a comment from coreboot:

"As mentioned above, only the offsets need to be
aligned, not the absolute bases. Please, have a look for instance at
`MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c:`:

  (FtwDevice->WorkSpaceAddress >= (FvbBaseAddress + BlockSize * (LbaIndex -
1)))
Things become more obvious if we remove the unnecessary parentheses:

  FtwDevice->WorkSpaceAddress >= FvbBaseAddress + BlockSize * (LbaIndex - 1)
It's the same as:

  FtwDevice->WorkSpaceAddress - FvbBaseAddress >= BlockSize * (LbaIndex - 1)
And _if_ aligned, the same as:

  (FtwDevice->WorkSpaceAddress - FvbBaseAddress) / BlockSize >= LbaIndex - 1
Now it's easy to see: neither `FtwDevice->WorkSpaceAddress` nor
`FvbBaseAddress`
have to be aligned, but their relative distance has to be."

So if this solution isn't acceptable, could you suggest one that would be?

Many thanks

On Tue, 17 May 2022 at 16:05, Zeng, Star  wrote:

> When length is larger than block size and block size aligned, if the
> address is not block size aligned, that means the range will mix with other
> range, but erase operation will be done per block, that will be risky and
> may break the fault tolerant mechanism.
>
> I could not remember all the details. Personally, I do not think it is
> right way to remove the check.
>
>
>
>
>
> Thanks,
>
> Star
>
> *From:* Lean Sheng Tan 
> *Sent:* Tuesday, May 17, 2022 7:58 PM
> *To:* devel@edk2.groups.io; Wu, Hao A 
> *Cc:* Zeng, Star ; Gao, Liming <
> gaolim...@byosoft.com.cn>; Rhodes, Sean 
> *Subject:* Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe:
> Don't check for address alignment
>
>
>
> Hi Star & Liming,
>
> Any update on this?
>
> Much appreciated.
>
>
> Best Regards,
>
> *Lean Sheng Tan*
>
>
> 9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
>
> Email: sheng@9elements.com
>
> Phone: *+49 234 68 94 188 <+492346894188>*
>
> Mobile: *+49 176 76 113842 <+4917676113842>*
>
>
>
> Registered office: Bochum
>
> Commercial register: Amtsgericht Bochum, HRB 17519
>
> Management: Sebastian German, Eray Bazaar
>
>
> Data protection information according to Art. 13 GDPR
> <https://9elements.com/privacy>
>
>
>
>
>
> On Mon, 16 May 2022 at 11:03, Wu, Hao A  wrote:
>
> Sorry Star and Liming,
>
>
>
> For the below patch (removing the alignment check for WorkSpace &
> SpareArea):
>
> https://edk2.groups.io/g/devel/message/89742
>
>
>
> Do you think it will impact the FTW service on flash device? Thanks in
> advance.
>
>
>
> Best Regards,
>
> Hao Wu
>
>
>
> *From:* devel@edk2.groups.io  *On Behalf Of *Sean
> Rhodes
> *Sent:* Monday, May 16, 2022 3:54 PM
> *To:* Wu, Hao A 
> *Cc:* devel@edk2.groups.io
> *Subject:* Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe:
> Don't check for address alignment
>
>
>
> The bug discovered was with coreboot, and the PCD values are derived from
> the block size of its SMMStore (NvStorage) region. The discussion on the
> patch can be found here: https://review.coreboot.org/c/coreboot/+/62990
>
>
>
> Hacking the PCDs could work,, but why would we want to keep an incorrect
> check?
>
>
>
> Thanks!
>
>
>
>
>
> On Mon, 16 May 2022 at 08:36, Wu, Hao A  wrote:
>
> Sorry for not being clear on what I mean.
>
> Is it possible to change the platform PCD values and keep these block size
> alignment requirements.
>
>
>
> Best Regards,
>
> Hao Wu
>
>
>
> *From:* devel@edk2.groups.io  *On Behalf Of *Sean
> Rhodes
> *Sent:* Monday, May 16, 2022 3:00 PM
> *To:* Wu; Wu, Hao A ; devel@edk2.groups.io
> *Subject:* Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe:
> Don't check for address alignment
>
>
>
> Hi Hao
>
> Yes, it does conflict - I will update the patch to fix these comments :)
>
> Thank you
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89828): https://edk2.groups.io/g/devel/message/89828
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-17 Thread Zeng, Star
When length is larger than block size and block size aligned, if the address is 
not block size aligned, that means the range will mix with other range, but 
erase operation will be done per block, that will be risky and may break the 
fault tolerant mechanism.
I could not remember all the details. Personally, I do not think it is right 
way to remove the check.


Thanks,
Star
From: Lean Sheng Tan 
Sent: Tuesday, May 17, 2022 7:58 PM
To: devel@edk2.groups.io; Wu, Hao A 
Cc: Zeng, Star ; Gao, Liming ; 
Rhodes, Sean 
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't 
check for address alignment

Hi Star & Liming,
Any update on this?
Much appreciated.

Best Regards,
Lean Sheng Tan

[http://static.9elements.com/logo-signature.png]
9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
Email: sheng@9elements.com<mailto:sheng@9elements.com>
Phone: +49 234 68 94 188
Mobile: +49 176 76 113842

Registered office: Bochum
Commercial register: Amtsgericht Bochum, HRB 17519
Management: Sebastian German, Eray Bazaar

Data protection information according to Art. 13 
GDPR<https://9elements.com/privacy>


On Mon, 16 May 2022 at 11:03, Wu, Hao A 
mailto:hao.a...@intel.com>> wrote:
Sorry Star and Liming,

For the below patch (removing the alignment check for WorkSpace & SpareArea):
https://edk2.groups.io/g/devel/message/89742

Do you think it will impact the FTW service on flash device? Thanks in advance.

Best Regards,
Hao Wu

From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> 
mailto:devel@edk2.groups.io>> On Behalf Of Sean Rhodes
Sent: Monday, May 16, 2022 3:54 PM
To: Wu, Hao A mailto:hao.a...@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't 
check for address alignment

The bug discovered was with coreboot, and the PCD values are derived from the 
block size of its SMMStore (NvStorage) region. The discussion on the patch can 
be found here: https://review.coreboot.org/c/coreboot/+/62990

Hacking the PCDs could work,, but why would we want to keep an incorrect check?

Thanks!


On Mon, 16 May 2022 at 08:36, Wu, Hao A 
mailto:hao.a...@intel.com>> wrote:
Sorry for not being clear on what I mean.
Is it possible to change the platform PCD values and keep these block size 
alignment requirements.

Best Regards,
Hao Wu

From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> 
mailto:devel@edk2.groups.io>> On Behalf Of Sean Rhodes
Sent: Monday, May 16, 2022 3:00 PM
To: Wu; Wu, Hao A mailto:hao.a...@intel.com>>; 
devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't 
check for address alignment

Hi Hao

Yes, it does conflict - I will update the patch to fix these comments :)

Thank you



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89827): https://edk2.groups.io/g/devel/message/89827
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-17 Thread Sheng Lean Tan
Hi Star & Liming,
Any update on this?
Much appreciated.

Best Regards,
*Lean Sheng Tan*



9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
Email: sheng@9elements.com
Phone: *+49 234 68 94 188 <+492346894188>*
Mobile: *+49 176 76 113842 <+4917676113842>*

Registered office: Bochum
Commercial register: Amtsgericht Bochum, HRB 17519
Management: Sebastian German, Eray Bazaar

Data protection information according to Art. 13 GDPR
<https://9elements.com/privacy>


On Mon, 16 May 2022 at 11:03, Wu, Hao A  wrote:

> Sorry Star and Liming,
>
>
>
> For the below patch (removing the alignment check for WorkSpace &
> SpareArea):
>
> https://edk2.groups.io/g/devel/message/89742
>
>
>
> Do you think it will impact the FTW service on flash device? Thanks in
> advance.
>
>
>
> Best Regards,
>
> Hao Wu
>
>
>
> *From:* devel@edk2.groups.io  * On Behalf Of *Sean
> Rhodes
> *Sent:* Monday, May 16, 2022 3:54 PM
> *To:* Wu, Hao A 
> *Cc:* devel@edk2.groups.io
> *Subject:* Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe:
> Don't check for address alignment
>
>
>
> The bug discovered was with coreboot, and the PCD values are derived from
> the block size of its SMMStore (NvStorage) region. The discussion on the
> patch can be found here: https://review.coreboot.org/c/coreboot/+/62990
>
>
>
> Hacking the PCDs could work,, but why would we want to keep an incorrect
> check?
>
>
>
> Thanks!
>
>
>
>
>
> On Mon, 16 May 2022 at 08:36, Wu, Hao A  wrote:
>
> Sorry for not being clear on what I mean.
>
> Is it possible to change the platform PCD values and keep these block size
> alignment requirements.
>
>
>
> Best Regards,
>
> Hao Wu
>
>
>
> *From:* devel@edk2.groups.io  *On Behalf Of *Sean
> Rhodes
> *Sent:* Monday, May 16, 2022 3:00 PM
> *To:* Wu; Wu, Hao A ; devel@edk2.groups.io
> *Subject:* Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe:
> Don't check for address alignment
>
>
>
> Hi Hao
>
> Yes, it does conflict - I will update the patch to fix these comments :)
>
> Thank you
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89810): https://edk2.groups.io/g/devel/message/89810
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-16 Thread Wu, Hao A
Sorry Star and Liming,

For the below patch (removing the alignment check for WorkSpace & SpareArea):
https://edk2.groups.io/g/devel/message/89742

Do you think it will impact the FTW service on flash device? Thanks in advance.

Best Regards,
Hao Wu

From: devel@edk2.groups.io  On Behalf Of Sean Rhodes
Sent: Monday, May 16, 2022 3:54 PM
To: Wu, Hao A 
Cc: devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't 
check for address alignment

The bug discovered was with coreboot, and the PCD values are derived from the 
block size of its SMMStore (NvStorage) region. The discussion on the patch can 
be found here: https://review.coreboot.org/c/coreboot/+/62990

Hacking the PCDs could work,, but why would we want to keep an incorrect check?

Thanks!


On Mon, 16 May 2022 at 08:36, Wu, Hao A 
mailto:hao.a...@intel.com>> wrote:
Sorry for not being clear on what I mean.
Is it possible to change the platform PCD values and keep these block size 
alignment requirements.

Best Regards,
Hao Wu

From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> 
mailto:devel@edk2.groups.io>> On Behalf Of Sean Rhodes
Sent: Monday, May 16, 2022 3:00 PM
To: Wu; Wu, Hao A mailto:hao.a...@intel.com>>; 
devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't 
check for address alignment

Hi Hao

Yes, it does conflict - I will update the patch to fix these comments :)

Thank you



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89761): https://edk2.groups.io/g/devel/message/89761
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-16 Thread Sean Rhodes
The bug discovered was with coreboot, and the PCD values are derived from
the block size of its SMMStore (NvStorage) region. The discussion on the
patch can be found here: https://review.coreboot.org/c/coreboot/+/62990

Hacking the PCDs could work,, but why would we want to keep an incorrect
check?

Thanks!


On Mon, 16 May 2022 at 08:36, Wu, Hao A  wrote:

> Sorry for not being clear on what I mean.
>
> Is it possible to change the platform PCD values and keep these block size
> alignment requirements.
>
>
>
> Best Regards,
>
> Hao Wu
>
>
>
> *From:* devel@edk2.groups.io  * On Behalf Of *Sean
> Rhodes
> *Sent:* Monday, May 16, 2022 3:00 PM
> *To:* Wu; Wu, Hao A ; devel@edk2.groups.io
> *Subject:* Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe:
> Don't check for address alignment
>
>
>
> Hi Hao
>
> Yes, it does conflict - I will update the patch to fix these comments :)
>
> Thank you
>
> 
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89760): https://edk2.groups.io/g/devel/message/89760
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-16 Thread Wu, Hao A
Sorry for not being clear on what I mean.
Is it possible to change the platform PCD values and keep these block size 
alignment requirements.

Best Regards,
Hao Wu

From: devel@edk2.groups.io  On Behalf Of Sean Rhodes
Sent: Monday, May 16, 2022 3:00 PM
To: Wu; Wu, Hao A ; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't 
check for address alignment

Hi Hao

Yes, it does conflict - I will update the patch to fix these comments :)

Thank you



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89749): https://edk2.groups.io/g/devel/message/89749
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

2022-05-16 Thread Sean Rhodes
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|0x3014
 
   ## 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|0x3010
 
@@ -1668,7 +1667,6 @@
   
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0x0|UINT64|0x8013
 
   ## 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|0x8010
 
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 @@
 
 #string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase_PROMPT  
#language en-US "Base address of flash FTW working block range"
 
-#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase_HELP  
#language en-US "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."
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase_HELP  
#language en-US "Base address of the FTW working block range in flash device."
 
 #string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingSize_PROMPT  
#language en-US "Size of flash FTW working block range"
 
@@ -390,7 +390,7 @@
 
 #string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase64_PROMPT  
#language en-US "64-bit Base address of flash FTW working block range"
 
-#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase64_HELP  
#language en-US "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."
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFlashNvStorageFtwWorkingBase64_HELP  
#language en-US "64-bit Base address of the FTW working block range in flash 
device."
 
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEmuVariableNvModeEnable_PROMPT  
#language en-US "EMU variable NV mode enable"
 
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c 
b/MdeModulePkg/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 = 1; LbaIndex <= NumberOfBlocks; LbaIndex += 1) {
-if (  (FtwDevice->WorkSpaceAddress >= (FvbBaseAddress + BlockSize * 
(LbaIndex - 1)))
-   && (FtwDevice->WorkSpaceAddress < (FvbBaseAddress + BlockSize * 
LbaIndex)))
+if ((FtwDevice->WorkSpaceAddress - FvbBaseAddress >= BlockSize * 
(LbaIndex - 1)) &&
+((FtwDevice->WorkSpaceAddress - FvbBaseAddress) / BlockSize >= 
LbaIndex - 1))
 {
   FtwDevice->FtwWorkSpaceLba = LbaIndex - 1;
   //
@@ -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 

Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-16 Thread Sean Rhodes
Hi Hao

Yes, it does conflict - I will update the patch to fix these comments :)

Thank you


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89741): https://edk2.groups.io/g/devel/message/89741
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-16 Thread Wu, Hao A
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|0x3010

  ## 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|0x8010

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 
Sent: Monday, May 16, 2022 1:41 PM
To: devel@edk2.groups.io; Rhodes, Sean 
Cc: Wang, Jian J ; Wu, Hao A ; Gao, 
Liming 
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>, 
mailto:starlabs.syst...@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 mailto:jian.j.w...@intel.com>>
Cc: Hao A Wu mailto:hao.a...@intel.com>>
Cc: Liming Gao mailto:gaolim...@byosoft.com.cn>>
Signed-off-by: Sean Rhodes 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/

Re: [edk2-devel] [PATCH] MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment

2022-05-15 Thread Sean Rhodes
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+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [sean@starlabs.systems]
> 
>
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89739): https://edk2.groups.io/g/devel/message/89739
Mute This Topic: https://groups.io/mt/91134149/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

2022-04-01 Thread 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 
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/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-