public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config
@ 2023-08-11 11:04 Qingyu Shang
  2023-08-16  7:08 ` Li, Yong
  0 siblings, 1 reply; 6+ messages in thread
From: Qingyu Shang @ 2023-08-11 11:04 UTC (permalink / raw)
  To: devel; +Cc: Qingyu Shang

The block size configuration of Blockmap does not match that in Qemu
VirtNorFlash, which causes variable data to be written into FtwWorkBlock
by mistake, resulting in data loss during reboot. Fix it and update
new checksum value.

Signed-off-by: Qingyu Shang <2931013282@sjtu.edu.cn>
---
 OvmfPkg/RiscVVirt/VarStore.fdf.inc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/RiscVVirt/VarStore.fdf.inc b/OvmfPkg/RiscVVirt/VarStore.fdf.inc
index 6bc619e50c..aba32315cc 100644
--- a/OvmfPkg/RiscVVirt/VarStore.fdf.inc
+++ b/OvmfPkg/RiscVVirt/VarStore.fdf.inc
@@ -30,9 +30,9 @@ DATA = {
   # Signature "_FVH"       # Attributes
   0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00,
   # HeaderLength # CheckSum # ExtHeaderOffset #Reserved #Revision
-  0x48, 0x00, 0x2F, 0xF1, 0x00, 0x00, 0x00, 0x02,
-  # Blockmap[0]: 0x20 Blocks * 0x1000 Bytes / Block
-  0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+  0x48, 0x00, 0x28, 0x09, 0x00, 0x00, 0x00, 0x02,
+  # Blockmap[0]: 0x3 Blocks * 0x40000 Bytes / Block
+  0x3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
   # Blockmap[1]: End
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   ## This is the VARIABLE_STORE_HEADER
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107708): https://edk2.groups.io/g/devel/message/107708
Mute This Topic: https://groups.io/mt/100684601/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config
  2023-08-11 11:04 [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config Qingyu Shang
@ 2023-08-16  7:08 ` Li, Yong
  2023-08-16  9:03   ` Sunil V L
       [not found]   ` <177BD1A40E32609C.8497@groups.io>
  0 siblings, 2 replies; 6+ messages in thread
From: Li, Yong @ 2023-08-16  7:08 UTC (permalink / raw)
  To: devel@edk2.groups.io, 2931013282@sjtu.edu.cn; +Cc: Sunil V L, Warkentin, Andrei

Hi Sunil,

Qingyu is from Penglai team, when we were working together in enabling StandaloneMm variable service, 
we found an issue in OvmfPkg/RiscVVirt/VarStore.fdf.inc,  in which the blockmap config is not aligned with the value in
OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c, which is SIZE_256KB

That mis-alignment won't cause any issue if the variable size is small and less than 0x1000, but if store more data in the flash device then it will cause data loss issue during reboot.
Once reboot if any FV header data is corrupted it will result the whole variable system be re-initialized.

Please help review the patch and give the comments, thanks 

Thanks,
Yong Li

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Qingyu Shang
Sent: Friday, August 11, 2023 7:05 PM
To: devel@edk2.groups.io
Cc: Qingyu Shang <2931013282@sjtu.edu.cn>
Subject: [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config

The block size configuration of Blockmap does not match that in Qemu VirtNorFlash, which causes variable data to be written into FtwWorkBlock by mistake, resulting in data loss during reboot. Fix it and update new checksum value.

Signed-off-by: Qingyu Shang <2931013282@sjtu.edu.cn>
---
 OvmfPkg/RiscVVirt/VarStore.fdf.inc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/RiscVVirt/VarStore.fdf.inc b/OvmfPkg/RiscVVirt/VarStore.fdf.inc
index 6bc619e50c..aba32315cc 100644
--- a/OvmfPkg/RiscVVirt/VarStore.fdf.inc
+++ b/OvmfPkg/RiscVVirt/VarStore.fdf.inc
@@ -30,9 +30,9 @@ DATA = {
   # Signature "_FVH"       # Attributes   0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00,   # HeaderLength # CheckSum # ExtHeaderOffset #Reserved #Revision-  0x48, 0x00, 0x2F, 0xF1, 0x00, 0x00, 0x00, 0x02,-  # Blockmap[0]: 0x20 Blocks * 0x1000 Bytes / Block-  0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,+  0x48, 0x00, 0x28, 0x09, 0x00, 0x00, 0x00, 0x02,+  # Blockmap[0]: 0x3 Blocks * 0x40000 Bytes / Block+  0x3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,   # Blockmap[1]: End   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   ## This is the VARIABLE_STORE_HEADER-- 
2.25.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107708): https://edk2.groups.io/g/devel/message/107708
Mute This Topic: https://groups.io/mt/100684601/6998987
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [yong.li@intel.com] -=-=-=-=-=-=




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107791): https://edk2.groups.io/g/devel/message/107791
Mute This Topic: https://groups.io/mt/100684601/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config
  2023-08-16  7:08 ` Li, Yong
@ 2023-08-16  9:03   ` Sunil V L
  2023-08-16 10:25     ` 回复: " Qingyu Shang
       [not found]   ` <177BD1A40E32609C.8497@groups.io>
  1 sibling, 1 reply; 6+ messages in thread
From: Sunil V L @ 2023-08-16  9:03 UTC (permalink / raw)
  To: Li, Yong; +Cc: devel@edk2.groups.io, 2931013282@sjtu.edu.cn, Warkentin, Andrei

On Wed, Aug 16, 2023 at 07:08:58AM +0000, Li, Yong wrote:
> Hi Sunil,
> 
> Qingyu is from Penglai team, when we were working together in enabling StandaloneMm variable service, 
> we found an issue in OvmfPkg/RiscVVirt/VarStore.fdf.inc,  in which the blockmap config is not aligned with the value in
> OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c, which is SIZE_256KB
> 
> That mis-alignment won't cause any issue if the variable size is small and less than 0x1000, but if store more data in the flash device then it will cause data loss issue during reboot.
> Once reboot if any FV header data is corrupted it will result the whole variable system be re-initialized.
> 
> Please help review the patch and give the comments, thanks 
>
Hi Yong Li,

Thank you very much for providing the context. Sorry, I actually had
missed this.

Hi Quingyu Shang,

The patch LGTM. Thanks a lot for finding the issue and fixing it. In
future, could you please run BaseTools/Scripts/GetMaintainer.py on the
patches and CC all the people it lists using "Cc:" tag?

Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>

Thanks!
Sunil


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107794): https://edk2.groups.io/g/devel/message/107794
Mute This Topic: https://groups.io/mt/100684601/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* 回复: [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config
  2023-08-16  9:03   ` Sunil V L
@ 2023-08-16 10:25     ` Qingyu Shang
  0 siblings, 0 replies; 6+ messages in thread
From: Qingyu Shang @ 2023-08-16 10:25 UTC (permalink / raw)
  To: Sunil V L; +Cc: Li, Yong, devel, Warkentin, Andrei

Hi Sunil, 

Happy you like that! I will CC all the related maintainers by that python script next time. 

Thanks! 
Qingyu 

-----原始邮件----- 
发件人: "Sunil V L" <sunilvl@ventanamicro.com> 
收件人: "Li, Yong" <yong.li@intel.com> 
抄送: devel@edk2.groups.io, 2931013282@sjtu.edu.cn, "Warkentin, Andrei" <andrei.warkentin@intel.com> 
已发送邮件: 星期三, 8 月 16, 2023 05:03:00 PM 
主题: Re: [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config 

On Wed, Aug 16, 2023 at 07:08:58AM +0000, Li, Yong wrote: 
> Hi Sunil, 
> 
> Qingyu is from Penglai team, when we were working together in enabling StandaloneMm variable service, 
> we found an issue in OvmfPkg/RiscVVirt/VarStore.fdf.inc, in which the blockmap config is not aligned with the value in 
> OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c, which is SIZE_256KB 
> 
> That mis-alignment won't cause any issue if the variable size is small and less than 0x1000, but if store more data in the flash device then it will cause data loss issue during reboot. 
> Once reboot if any FV header data is corrupted it will result the whole variable system be re-initialized. 
> 
> Please help review the patch and give the comments, thanks 
> 
Hi Yong Li, 

Thank you very much for providing the context. Sorry, I actually had 
missed this. 

Hi Quingyu Shang, 

The patch LGTM. Thanks a lot for finding the issue and fixing it. In 
future, could you please run BaseTools/Scripts/GetMaintainer.py on the 
patches and CC all the people it lists using "Cc:" tag? 

Reviewed-by: Sunil V L <sunilvl@ventanamicro.com> 

Thanks! 
Sunil 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107795): https://edk2.groups.io/g/devel/message/107795
Mute This Topic: https://groups.io/mt/100776646/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config
       [not found]   ` <177BD1A40E32609C.8497@groups.io>
@ 2023-08-22  6:26     ` Sunil V L
  2023-08-24  1:44       ` edk2-stable202308: " gaoliming via groups.io
  0 siblings, 1 reply; 6+ messages in thread
From: Sunil V L @ 2023-08-22  6:26 UTC (permalink / raw)
  To: devel, Liming Gao; +Cc: Li, Yong, 2931013282@sjtu.edu.cn, Warkentin, Andrei

Hi Liming,

This is a bug fix and can cause data loss if the variable size > 4k.
Can it be included for the edk2-stable202308? Let me know if it requires
a BZ id.

I tried running the CI tests for this patch. But 2 of tests failed and I
don't think it has anything to do with this patch. If you are ok to take
this patch for the stable release, could you please let me know what
needs to be done?

PR : https://github.com/tianocore/edk2/pull/4754

Thanks!
Sunil

On Wed, Aug 16, 2023 at 02:33:00PM +0530, Sunil V L via groups.io wrote:
> On Wed, Aug 16, 2023 at 07:08:58AM +0000, Li, Yong wrote:
> > Hi Sunil,
> > 
> > Qingyu is from Penglai team, when we were working together in enabling StandaloneMm variable service, 
> > we found an issue in OvmfPkg/RiscVVirt/VarStore.fdf.inc,  in which the blockmap config is not aligned with the value in
> > OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c, which is SIZE_256KB
> > 
> > That mis-alignment won't cause any issue if the variable size is small and less than 0x1000, but if store more data in the flash device then it will cause data loss issue during reboot.
> > Once reboot if any FV header data is corrupted it will result the whole variable system be re-initialized.
> > 
> > Please help review the patch and give the comments, thanks 
> >
> Hi Yong Li,
> 
> Thank you very much for providing the context. Sorry, I actually had
> missed this.
> 
> Hi Quingyu Shang,
> 
> The patch LGTM. Thanks a lot for finding the issue and fixing it. In
> future, could you please run BaseTools/Scripts/GetMaintainer.py on the
> patches and CC all the people it lists using "Cc:" tag?
> 
> Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
> 
> Thanks!
> Sunil
> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107947): https://edk2.groups.io/g/devel/message/107947
Mute This Topic: https://groups.io/mt/100684601/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* edk2-stable202308: [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config
  2023-08-22  6:26     ` Sunil V L
@ 2023-08-24  1:44       ` gaoliming via groups.io
  0 siblings, 0 replies; 6+ messages in thread
From: gaoliming via groups.io @ 2023-08-24  1:44 UTC (permalink / raw)
  To: devel, sunilvl, 'Kinney, Michael D',
	'Leif Lindholm', 'Andrew Fish'
  Cc: 'Li, Yong', 2931013282, 'Warkentin, Andrei',
	gaoliming

Sunil:
  I agree this is a critical bug fix. The fix is correct. CI failure is not
related to this change. If no other comment, I will help merge this change
tomorrow. 

Thanks
Liming
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Sunil V L
> 发送时间: 2023年8月22日 14:26
> 收件人: devel@edk2.groups.io; Liming Gao <gaoliming@byosoft.com.cn>
> 抄送: Li, Yong <yong.li@intel.com>; 2931013282@sjtu.edu.cn; Warkentin,
> Andrei <andrei.warkentin@intel.com>
> 主题: Re: [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore
> Blockmap config
> 
> Hi Liming,
> 
> This is a bug fix and can cause data loss if the variable size > 4k.
> Can it be included for the edk2-stable202308? Let me know if it requires
> a BZ id.
> 
> I tried running the CI tests for this patch. But 2 of tests failed and I
> don't think it has anything to do with this patch. If you are ok to take
> this patch for the stable release, could you please let me know what
> needs to be done?
> 
> PR : https://github.com/tianocore/edk2/pull/4754
> 
> Thanks!
> Sunil
> 
> On Wed, Aug 16, 2023 at 02:33:00PM +0530, Sunil V L via groups.io wrote:
> > On Wed, Aug 16, 2023 at 07:08:58AM +0000, Li, Yong wrote:
> > > Hi Sunil,
> > >
> > > Qingyu is from Penglai team, when we were working together in enabling
> StandaloneMm variable service,
> > > we found an issue in OvmfPkg/RiscVVirt/VarStore.fdf.inc,  in which the
> blockmap config is not aligned with the value in
> > >
> OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c,
> which is SIZE_256KB
> > >
> > > That mis-alignment won't cause any issue if the variable size is small
and
> less than 0x1000, but if store more data in the flash device then it will
cause
> data loss issue during reboot.
> > > Once reboot if any FV header data is corrupted it will result the
whole
> variable system be re-initialized.
> > >
> > > Please help review the patch and give the comments, thanks
> > >
> > Hi Yong Li,
> >
> > Thank you very much for providing the context. Sorry, I actually had
> > missed this.
> >
> > Hi Quingyu Shang,
> >
> > The patch LGTM. Thanks a lot for finding the issue and fixing it. In
> > future, could you please run BaseTools/Scripts/GetMaintainer.py on the
> > patches and CC all the people it lists using "Cc:" tag?
> >
> > Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
> >
> > Thanks!
> > Sunil
> >
> >
> >
> >
> >
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107992): https://edk2.groups.io/g/devel/message/107992
Mute This Topic: https://groups.io/mt/100928325/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-24  1:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 11:04 [edk2-devel] [PATCH] OvmfPkg/RiscVVirt: Fix issues in VarStore Blockmap config Qingyu Shang
2023-08-16  7:08 ` Li, Yong
2023-08-16  9:03   ` Sunil V L
2023-08-16 10:25     ` 回复: " Qingyu Shang
     [not found]   ` <177BD1A40E32609C.8497@groups.io>
2023-08-22  6:26     ` Sunil V L
2023-08-24  1:44       ` edk2-stable202308: " gaoliming via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox