public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug info
@ 2023-09-07 11:11 Zhenyu Zhang
  2023-09-07 12:26 ` Yao, Jiewen
  0 siblings, 1 reply; 4+ messages in thread
From: Zhenyu Zhang @ 2023-09-07 11:11 UTC (permalink / raw)
  To: devel
  Cc: zhenyzha, osteffen, kraxel, marcandre.lureau, stefanb,
	anthony.perard, julien

From: "Zhenyu Zhang" <zhenyzha@redhat.com>

When the variable store is full, edk2 will directly assert.
Add debug information to help users understand what caused
the assertion.

 Actual results:
 RecordVarErrorFlag (0xEF) 9A144FE2A47E:937FE521-95AE-4D1A-8929-
 48BCD90AD31A - 0x00000003 - 0x7E
 CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize =
 0x3FF98
 RecordVarErrorFlag (0xEF) 9A144FE2A47E:937FE521-95AE-4D1A-8929-
 48BCD90AD31A - 0x00000003 - 0x92
 CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF98

 Synchronous Exception at 0x000000023CA60374
 ......
 ASSERT_EFI_ERROR (Status = Out of Resources)
 ASSERT /builddir/build/BUILD/edk2-ba91d0292e59/OvmfPkg/Library/
 PlatformBootManagerLib/BdsPlatform.c(142): !(((INTN)(RETURN_
 STATUS)(Status)) < 0)

Cc: Oliver Steffen <osteffen@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>                      
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Stefan Berger <stefanb@linux.ibm.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Zhenyu Zhang <zhenyzha@redhat.com>
---
 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 8dc2bbf97371..c95c7931a3f5 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -139,6 +139,7 @@ PlatformRegisterFvBootOption (
 
   if (OptionIndex == -1) {
     Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
+    DEBUG ((DEBUG_ERROR, "ERROR: Variable store is full.\n"));
     ASSERT_EFI_ERROR (Status);
   }
 
-- 
2.39.3



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108374): https://edk2.groups.io/g/devel/message/108374
Mute This Topic: https://groups.io/mt/101211889/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] 4+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug info
  2023-09-07 11:11 [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug info Zhenyu Zhang
@ 2023-09-07 12:26 ` Yao, Jiewen
  2023-09-07 13:24   ` Oliver Steffen
  0 siblings, 1 reply; 4+ messages in thread
From: Yao, Jiewen @ 2023-09-07 12:26 UTC (permalink / raw)
  To: devel@edk2.groups.io, zhenyzha@redhat.com
  Cc: osteffen@redhat.com, kraxel@redhat.com,
	marcandre.lureau@redhat.com, stefanb@linux.ibm.com,
	anthony.perard@citrix.com, julien@xen.org, Yao, Jiewen

I don't think using ASSERT is a good idea here.

Why not return ERROR?



> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Zhenyu
> Zhang
> Sent: Thursday, September 7, 2023 7:11 PM
> To: devel@edk2.groups.io
> Cc: zhenyzha@redhat.com; osteffen@redhat.com; kraxel@redhat.com;
> marcandre.lureau@redhat.com; stefanb@linux.ibm.com;
> anthony.perard@citrix.com; julien@xen.org
> Subject: [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug
> info
> 
> From: "Zhenyu Zhang" <zhenyzha@redhat.com>
> 
> When the variable store is full, edk2 will directly assert.
> Add debug information to help users understand what caused
> the assertion.
> 
>  Actual results:
>  RecordVarErrorFlag (0xEF) 9A144FE2A47E:937FE521-95AE-4D1A-8929-
>  48BCD90AD31A - 0x00000003 - 0x7E
>  CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize =
>  0x3FF98
>  RecordVarErrorFlag (0xEF) 9A144FE2A47E:937FE521-95AE-4D1A-8929-
>  48BCD90AD31A - 0x00000003 - 0x92
>  CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF98
> 
>  Synchronous Exception at 0x000000023CA60374
>  ......
>  ASSERT_EFI_ERROR (Status = Out of Resources)
>  ASSERT /builddir/build/BUILD/edk2-ba91d0292e59/OvmfPkg/Library/
>  PlatformBootManagerLib/BdsPlatform.c(142): !(((INTN)(RETURN_
>  STATUS)(Status)) < 0)
> 
> Cc: Oliver Steffen <osteffen@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Cc: Stefan Berger <stefanb@linux.ibm.com>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Julien Grall <julien@xen.org>
> Signed-off-by: Zhenyu Zhang <zhenyzha@redhat.com>
> ---
>  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 8dc2bbf97371..c95c7931a3f5 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -139,6 +139,7 @@ PlatformRegisterFvBootOption (
> 
>    if (OptionIndex == -1) {
>      Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
> +    DEBUG ((DEBUG_ERROR, "ERROR: Variable store is full.\n"));
>      ASSERT_EFI_ERROR (Status);
>    }
> 
> --
> 2.39.3
> 
> 
> 
> 
> 



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



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

* Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug info
  2023-09-07 12:26 ` Yao, Jiewen
@ 2023-09-07 13:24   ` Oliver Steffen
  2023-09-08  2:44     ` Zhenyu Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Steffen @ 2023-09-07 13:24 UTC (permalink / raw)
  To: Yao, Jiewen, devel@edk2.groups.io, zhenyzha@redhat.com
  Cc: kraxel@redhat.com, marcandre.lureau@redhat.com,
	stefanb@linux.ibm.com, anthony.perard@citrix.com, julien@xen.org

Quoting Yao, Jiewen (2023-09-07 14:26:31)
> I don't think using ASSERT is a good idea here.
>

Some context:

We observed that EDK2 hits an ASSERT (Out of Resources) when booting
with a full variable store. The message provided in this case is not
helpful for non-experts.
I think the goal here is to emit a more user friendly message.

My suggestion is to wrap the newly added DEBUG statement with an if:

   if (OptionIndex == -1) {
     Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
+    if (Status == EFI_OUT_OF_RESOURCES) {
+      DEBUG ((DEBUG_ERROR, "ERROR: Variable store is full.\n"));
+    }
     ASSERT_EFI_ERROR (Status);
   }

The ASSERT_EFI_ERROR was already there. It will halt the execution in
case Status contains an error. Aparently the firmware is not able to
continue with a full variable store.

> Why not return ERROR?
>

This is in VOID PlatformRegisterFvBootOption (), returning ERROR is not
possible.

Thanks,
 Oliver

>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Zhenyu
> > Zhang
> > Sent: Thursday, September 7, 2023 7:11 PM
> > To: devel@edk2.groups.io
> > Cc: zhenyzha@redhat.com; osteffen@redhat.com; kraxel@redhat.com;
> > marcandre.lureau@redhat.com; stefanb@linux.ibm.com;
> > anthony.perard@citrix.com; julien@xen.org
> > Subject: [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug
> > info
> >
> > From: "Zhenyu Zhang" <zhenyzha@redhat.com>
> >
> > When the variable store is full, edk2 will directly assert.
> > Add debug information to help users understand what caused
> > the assertion.
> >
> >  Actual results:
> >  RecordVarErrorFlag (0xEF) 9A144FE2A47E:937FE521-95AE-4D1A-8929-
> >  48BCD90AD31A - 0x00000003 - 0x7E
> >  CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize =
> >  0x3FF98
> >  RecordVarErrorFlag (0xEF) 9A144FE2A47E:937FE521-95AE-4D1A-8929-
> >  48BCD90AD31A - 0x00000003 - 0x92
> >  CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF98
> >
> >  Synchronous Exception at 0x000000023CA60374
> >  ......
> >  ASSERT_EFI_ERROR (Status = Out of Resources)
> >  ASSERT /builddir/build/BUILD/edk2-ba91d0292e59/OvmfPkg/Library/
> >  PlatformBootManagerLib/BdsPlatform.c(142): !(((INTN)(RETURN_
> >  STATUS)(Status)) < 0)
> >
> > Cc: Oliver Steffen <osteffen@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> > Cc: Stefan Berger <stefanb@linux.ibm.com>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > Cc: Julien Grall <julien@xen.org>
> > Signed-off-by: Zhenyu Zhang <zhenyzha@redhat.com>
> > ---
> >  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> > b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> > index 8dc2bbf97371..c95c7931a3f5 100644
> > --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> > +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> > @@ -139,6 +139,7 @@ PlatformRegisterFvBootOption (
> >
> >    if (OptionIndex == -1) {
> >      Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
> > +    DEBUG ((DEBUG_ERROR, "ERROR: Variable store is full.\n"));
> >      ASSERT_EFI_ERROR (Status);
> >    }
> >
> > --
> > 2.39.3
> >



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



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

* Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug info
  2023-09-07 13:24   ` Oliver Steffen
@ 2023-09-08  2:44     ` Zhenyu Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Zhenyu Zhang @ 2023-09-08  2:44 UTC (permalink / raw)
  To: Oliver Steffen
  Cc: Yao, Jiewen, devel@edk2.groups.io, kraxel@redhat.com,
	marcandre.lureau@redhat.com, stefanb@linux.ibm.com,
	anthony.perard@citrix.com, julien@xen.org

> My suggestion is to wrap the newly added DEBUG statement with an if:
>
>   if (OptionIndex == -1) {
>     Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
> +    if (Status == EFI_OUT_OF_RESOURCES) {
> +      DEBUG ((DEBUG_ERROR, "ERROR: Variable store is full.\n"));
> +    }
>     ASSERT_EFI_ERROR (Status);
>   }
>
> The ASSERT_EFI_ERROR was already there. It will halt the execution in
> case Status contains an error. Aparently the firmware is not able to
> continue with a full variable store.

Agreed, I'll add it in the next patch.

> > Why not return ERROR?
> >

> This is in VOID PlatformRegisterFvBootOption (), returning ERROR is not
> possible.

Indeed so.

Best wishes,
 Zhenyu

On Thu, Sep 7, 2023 at 9:25 PM Oliver Steffen <osteffen@redhat.com> wrote:
>
> Quoting Yao, Jiewen (2023-09-07 14:26:31)
> > I don't think using ASSERT is a good idea here.
> >
>
> Some context:
>
> We observed that EDK2 hits an ASSERT (Out of Resources) when booting
> with a full variable store. The message provided in this case is not
> helpful for non-experts.
> I think the goal here is to emit a more user friendly message.
>
> My suggestion is to wrap the newly added DEBUG statement with an if:
>
>    if (OptionIndex == -1) {
>      Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
> +    if (Status == EFI_OUT_OF_RESOURCES) {
> +      DEBUG ((DEBUG_ERROR, "ERROR: Variable store is full.\n"));
> +    }
>      ASSERT_EFI_ERROR (Status);
>    }
>
> The ASSERT_EFI_ERROR was already there. It will halt the execution in
> case Status contains an error. Aparently the firmware is not able to
> continue with a full variable store.
>
> > Why not return ERROR?
> >
>
> This is in VOID PlatformRegisterFvBootOption (), returning ERROR is not
> possible.
>
> Thanks,
>  Oliver
>
> >
> > > -----Original Message-----
> > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Zhenyu
> > > Zhang
> > > Sent: Thursday, September 7, 2023 7:11 PM
> > > To: devel@edk2.groups.io
> > > Cc: zhenyzha@redhat.com; osteffen@redhat.com; kraxel@redhat.com;
> > > marcandre.lureau@redhat.com; stefanb@linux.ibm.com;
> > > anthony.perard@citrix.com; julien@xen.org
> > > Subject: [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug
> > > info
> > >
> > > From: "Zhenyu Zhang" <zhenyzha@redhat.com>
> > >
> > > When the variable store is full, edk2 will directly assert.
> > > Add debug information to help users understand what caused
> > > the assertion.
> > >
> > >  Actual results:
> > >  RecordVarErrorFlag (0xEF) 9A144FE2A47E:937FE521-95AE-4D1A-8929-
> > >  48BCD90AD31A - 0x00000003 - 0x7E
> > >  CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize =
> > >  0x3FF98
> > >  RecordVarErrorFlag (0xEF) 9A144FE2A47E:937FE521-95AE-4D1A-8929-
> > >  48BCD90AD31A - 0x00000003 - 0x92
> > >  CommonVariableSpace = 0x3FF9C - CommonVariableTotalSize = 0x3FF98
> > >
> > >  Synchronous Exception at 0x000000023CA60374
> > >  ......
> > >  ASSERT_EFI_ERROR (Status = Out of Resources)
> > >  ASSERT /builddir/build/BUILD/edk2-ba91d0292e59/OvmfPkg/Library/
> > >  PlatformBootManagerLib/BdsPlatform.c(142): !(((INTN)(RETURN_
> > >  STATUS)(Status)) < 0)
> > >
> > > Cc: Oliver Steffen <osteffen@redhat.com>
> > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > Cc: Stefan Berger <stefanb@linux.ibm.com>
> > > Cc: Anthony Perard <anthony.perard@citrix.com>
> > > Cc: Julien Grall <julien@xen.org>
> > > Signed-off-by: Zhenyu Zhang <zhenyzha@redhat.com>
> > > ---
> > >  OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> > > b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> > > index 8dc2bbf97371..c95c7931a3f5 100644
> > > --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> > > +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> > > @@ -139,6 +139,7 @@ PlatformRegisterFvBootOption (
> > >
> > >    if (OptionIndex == -1) {
> > >      Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
> > > +    DEBUG ((DEBUG_ERROR, "ERROR: Variable store is full.\n"));
> > >      ASSERT_EFI_ERROR (Status);
> > >    }
> > >
> > > --
> > > 2.39.3
> > >
>



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



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

end of thread, other threads:[~2023-09-08  2:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-07 11:11 [edk2-devel] [PATCH v2 1/1] OvmfPkg:Add variable store is full debug info Zhenyu Zhang
2023-09-07 12:26 ` Yao, Jiewen
2023-09-07 13:24   ` Oliver Steffen
2023-09-08  2:44     ` Zhenyu Zhang

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