public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted
@ 2023-11-23  4:48 Nhi Pham via groups.io
  2023-11-23  8:36 ` Ard Biesheuvel
  0 siblings, 1 reply; 5+ messages in thread
From: Nhi Pham via groups.io @ 2023-11-23  4:48 UTC (permalink / raw)
  To: devel; +Cc: gaoliming, ardb+tianocore, Nhi Pham

If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted
is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when
executing gBS->LocateProtocol () in the else case.

To serve the omitted SetVirtualAddressMap() call, we could just check
mEsrtTable presence instead of relying on mIsVirtualAddrConverted.

Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c     | 17 +++++++----------
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c |  2 --
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 197af267aff3..2433c76a8c6f 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -41,8 +41,7 @@
 #include <Protocol/FirmwareManagementProgress.h>

 #include <Protocol/DevicePath.h>

 

-EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable             = NULL;

-BOOLEAN                    mIsVirtualAddrConverted = FALSE;

+EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;

 

 BOOLEAN    mDxeCapsuleLibEndOfDxe      = FALSE;

 EFI_EVENT  mDxeCapsuleLibEndOfDxeEvent = NULL;

@@ -1394,14 +1393,12 @@ IsNestedFmpCapsule (
   EFI_SYSTEM_RESOURCE_ENTRY  Entry;

 

   EsrtGuidFound = FALSE;

-  if (mIsVirtualAddrConverted) {

-    if (mEsrtTable != NULL) {

-      EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);

-      for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {

-        if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {

-          EsrtGuidFound = TRUE;

-          break;

-        }

+  if (mEsrtTable != NULL) {

+    EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);

+    for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {

+      if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {

+        EsrtGuidFound = TRUE;

+        break;

       }

     }

   } else {

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
index 9ceb44fe4d79..44f30c16c284 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
@@ -21,7 +21,6 @@
 #include <Library/MemoryAllocationLib.h>

 

 extern EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable;

-extern BOOLEAN                    mIsVirtualAddrConverted;

 EFI_EVENT                         mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;

 EFI_EVENT                         mDxeRuntimeCapsuleLibReadyToBootEvent          = NULL;

 

@@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent (
   )

 {

   gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable);

-  mIsVirtualAddrConverted = TRUE;

 }

 

 /**

-- 
2.25.1



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

* Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted
  2023-11-23  4:48 [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted Nhi Pham via groups.io
@ 2023-11-23  8:36 ` Ard Biesheuvel
  2023-11-23 12:10   ` Nhi Pham via groups.io
  2023-11-28 15:14   ` 回复: " gaoliming via groups.io
  0 siblings, 2 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2023-11-23  8:36 UTC (permalink / raw)
  To: Nhi Pham; +Cc: devel, gaoliming, ardb+tianocore

On Thu, 23 Nov 2023 at 05:49, Nhi Pham <nhi@os.amperecomputing.com> wrote:
>
> If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted
> is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when
> executing gBS->LocateProtocol () in the else case.
>
> To serve the omitted SetVirtualAddressMap() call, we could just check
> mEsrtTable presence instead of relying on mIsVirtualAddrConverted.
>
> Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>

Agreed: SetVirtualAddressMap() is optional, so whether it has been
called or not should not be used as a proxy to decide whether or not
we are still running in the boot services context.

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>


> ---
>  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c     | 17 +++++++----------
>  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c |  2 --
>  2 files changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> index 197af267aff3..2433c76a8c6f 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> @@ -41,8 +41,7 @@
>  #include <Protocol/FirmwareManagementProgress.h>
>  #include <Protocol/DevicePath.h>
>
> -EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable             = NULL;
> -BOOLEAN                    mIsVirtualAddrConverted = FALSE;
> +EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;
>
>  BOOLEAN    mDxeCapsuleLibEndOfDxe      = FALSE;
>  EFI_EVENT  mDxeCapsuleLibEndOfDxeEvent = NULL;
> @@ -1394,14 +1393,12 @@ IsNestedFmpCapsule (
>    EFI_SYSTEM_RESOURCE_ENTRY  Entry;
>
>    EsrtGuidFound = FALSE;
> -  if (mIsVirtualAddrConverted) {
> -    if (mEsrtTable != NULL) {
> -      EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> -      for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {
> -        if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
> -          EsrtGuidFound = TRUE;
> -          break;
> -        }
> +  if (mEsrtTable != NULL) {
> +    EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> +    for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {
> +      if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
> +        EsrtGuidFound = TRUE;
> +        break;
>        }
>      }
>    } else {
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> index 9ceb44fe4d79..44f30c16c284 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> @@ -21,7 +21,6 @@
>  #include <Library/MemoryAllocationLib.h>
>
>  extern EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable;
> -extern BOOLEAN                    mIsVirtualAddrConverted;
>  EFI_EVENT                         mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
>  EFI_EVENT                         mDxeRuntimeCapsuleLibReadyToBootEvent          = NULL;
>
> @@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent (
>    )
>  {
>    gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable);
> -  mIsVirtualAddrConverted = TRUE;
>  }
>
>  /**
> --
> 2.25.1
>


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



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

* Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted
  2023-11-23  8:36 ` Ard Biesheuvel
@ 2023-11-23 12:10   ` Nhi Pham via groups.io
  2023-11-28 15:14   ` 回复: " gaoliming via groups.io
  1 sibling, 0 replies; 5+ messages in thread
From: Nhi Pham via groups.io @ 2023-11-23 12:10 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: devel, gaoliming, ardb+tianocore

On 11/23/2023 3:36 PM, Ard Biesheuvel wrote:
> On Thu, 23 Nov 2023 at 05:49, Nhi Pham <nhi@os.amperecomputing.com> wrote:
>>
>> If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted
>> is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when
>> executing gBS->LocateProtocol () in the else case.
>>
>> To serve the omitted SetVirtualAddressMap() call, we could just check
>> mEsrtTable presence instead of relying on mIsVirtualAddrConverted.
>>
>> Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
> 
> Agreed: SetVirtualAddressMap() is optional, so whether it has been
> called or not should not be used as a proxy to decide whether or not
> we are still running in the boot services context.
> 
> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

Thanks Ard for quick review. I created the PR with your Rb-tag at
https://github.com/tianocore/edk2/pull/5071

Regards,
Nhi
> 
> 
>> ---
>>   MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c     | 17 +++++++----------
>>   MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c |  2 --
>>   2 files changed, 7 insertions(+), 12 deletions(-)
>>
>> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
>> index 197af267aff3..2433c76a8c6f 100644
>> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
>> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
>> @@ -41,8 +41,7 @@
>>   #include <Protocol/FirmwareManagementProgress.h>
>>   #include <Protocol/DevicePath.h>
>>
>> -EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable             = NULL;
>> -BOOLEAN                    mIsVirtualAddrConverted = FALSE;
>> +EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;
>>
>>   BOOLEAN    mDxeCapsuleLibEndOfDxe      = FALSE;
>>   EFI_EVENT  mDxeCapsuleLibEndOfDxeEvent = NULL;
>> @@ -1394,14 +1393,12 @@ IsNestedFmpCapsule (
>>     EFI_SYSTEM_RESOURCE_ENTRY  Entry;
>>
>>     EsrtGuidFound = FALSE;
>> -  if (mIsVirtualAddrConverted) {
>> -    if (mEsrtTable != NULL) {
>> -      EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
>> -      for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {
>> -        if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
>> -          EsrtGuidFound = TRUE;
>> -          break;
>> -        }
>> +  if (mEsrtTable != NULL) {
>> +    EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
>> +    for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {
>> +      if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
>> +        EsrtGuidFound = TRUE;
>> +        break;
>>         }
>>       }
>>     } else {
>> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
>> index 9ceb44fe4d79..44f30c16c284 100644
>> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
>> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
>> @@ -21,7 +21,6 @@
>>   #include <Library/MemoryAllocationLib.h>
>>
>>   extern EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable;
>> -extern BOOLEAN                    mIsVirtualAddrConverted;
>>   EFI_EVENT                         mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
>>   EFI_EVENT                         mDxeRuntimeCapsuleLibReadyToBootEvent          = NULL;
>>
>> @@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent (
>>     )
>>   {
>>     gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable);
>> -  mIsVirtualAddrConverted = TRUE;
>>   }
>>
>>   /**
>> --
>> 2.25.1
>>


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



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

* 回复: [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted
  2023-11-23  8:36 ` Ard Biesheuvel
  2023-11-23 12:10   ` Nhi Pham via groups.io
@ 2023-11-28 15:14   ` gaoliming via groups.io
  2023-11-28 18:10     ` Ard Biesheuvel
  1 sibling, 1 reply; 5+ messages in thread
From: gaoliming via groups.io @ 2023-11-28 15:14 UTC (permalink / raw)
  To: devel, ardb, 'Nhi Pham'; +Cc: ardb+tianocore

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Ard
> Biesheuvel
> 发送时间: 2023年11月23日 16:36
> 收件人: Nhi Pham <nhi@os.amperecomputing.com>
> 抄送: devel@edk2.groups.io; gaoliming@byosoft.com.cn;
> ardb+tianocore@kernel.org
> 主题: Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1]
> MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap
> omitted
> 
> On Thu, 23 Nov 2023 at 05:49, Nhi Pham <nhi@os.amperecomputing.com>
> wrote:
> >
> > If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted
> > is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when
> > executing gBS->LocateProtocol () in the else case.
> >
> > To serve the omitted SetVirtualAddressMap() call, we could just check
> > mEsrtTable presence instead of relying on mIsVirtualAddrConverted.
> >
> > Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
> 
> Agreed: SetVirtualAddressMap() is optional, so whether it has been
> called or not should not be used as a proxy to decide whether or not
> we are still running in the boot services context.
> 
> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
> 
> 
> > ---
> >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c     | 17
> +++++++----------
> >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c |  2 --
> >  2 files changed, 7 insertions(+), 12 deletions(-)
> >
> > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > index 197af267aff3..2433c76a8c6f 100644
> > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > @@ -41,8 +41,7 @@
> >  #include <Protocol/FirmwareManagementProgress.h>
> >  #include <Protocol/DevicePath.h>
> >
> > -EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable             = NULL;
> > -BOOLEAN                    mIsVirtualAddrConverted = FALSE;
> > +EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;
> >
> >  BOOLEAN    mDxeCapsuleLibEndOfDxe      = FALSE;
> >  EFI_EVENT  mDxeCapsuleLibEndOfDxeEvent = NULL;
> > @@ -1394,14 +1393,12 @@ IsNestedFmpCapsule (
> >    EFI_SYSTEM_RESOURCE_ENTRY  Entry;
> >
> >    EsrtGuidFound = FALSE;
> > -  if (mIsVirtualAddrConverted) {
> > -    if (mEsrtTable != NULL) {
> > -      EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> > -      for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++,
> EsrtEntry++) {
> > -        if (CompareGuid (&EsrtEntry->FwClass,
> &CapsuleHeader->CapsuleGuid)) {
> > -          EsrtGuidFound = TRUE;
> > -          break;
> > -        }
> > +  if (mEsrtTable != NULL) {
> > +    EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> > +    for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++,
> EsrtEntry++) {
> > +      if (CompareGuid (&EsrtEntry->FwClass,
> &CapsuleHeader->CapsuleGuid)) {
> > +        EsrtGuidFound = TRUE;
> > +        break;
> >        }
> >      }
> >    } else {
> > diff --git
> a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > index 9ceb44fe4d79..44f30c16c284 100644
> > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > @@ -21,7 +21,6 @@
> >  #include <Library/MemoryAllocationLib.h>
> >
> >  extern EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable;
> > -extern BOOLEAN                    mIsVirtualAddrConverted;
> >  EFI_EVENT
> mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
> >  EFI_EVENT
> mDxeRuntimeCapsuleLibReadyToBootEvent          = NULL;
> >
> > @@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent (
> >    )
> >  {
> >    gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable);
> > -  mIsVirtualAddrConverted = TRUE;
> >  }
> >
> >  /**
> > --
> > 2.25.1
> >
> 
> 
> 
> 





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



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

* Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted
  2023-11-28 15:14   ` 回复: " gaoliming via groups.io
@ 2023-11-28 18:10     ` Ard Biesheuvel
  0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2023-11-28 18:10 UTC (permalink / raw)
  To: devel, gaoliming; +Cc: Nhi Pham, ardb+tianocore

On Tue, 28 Nov 2023 at 16:15, gaoliming via groups.io
<gaoliming=byosoft.com.cn@groups.io> wrote:
>
> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
>

Thanks I'll queue this up.



> > -----邮件原件-----
> > 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Ard
> > Biesheuvel
> > 发送时间: 2023年11月23日 16:36
> > 收件人: Nhi Pham <nhi@os.amperecomputing.com>
> > 抄送: devel@edk2.groups.io; gaoliming@byosoft.com.cn;
> > ardb+tianocore@kernel.org
> > 主题: Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1]
> > MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap
> > omitted
> >
> > On Thu, 23 Nov 2023 at 05:49, Nhi Pham <nhi@os.amperecomputing.com>
> > wrote:
> > >
> > > If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted
> > > is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when
> > > executing gBS->LocateProtocol () in the else case.
> > >
> > > To serve the omitted SetVirtualAddressMap() call, we could just check
> > > mEsrtTable presence instead of relying on mIsVirtualAddrConverted.
> > >
> > > Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
> >
> > Agreed: SetVirtualAddressMap() is optional, so whether it has been
> > called or not should not be used as a proxy to decide whether or not
> > we are still running in the boot services context.
> >
> > Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
> >
> >
> > > ---
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c     | 17
> > +++++++----------
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c |  2 --
> > >  2 files changed, 7 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > index 197af267aff3..2433c76a8c6f 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > @@ -41,8 +41,7 @@
> > >  #include <Protocol/FirmwareManagementProgress.h>
> > >  #include <Protocol/DevicePath.h>
> > >
> > > -EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable             = NULL;
> > > -BOOLEAN                    mIsVirtualAddrConverted = FALSE;
> > > +EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;
> > >
> > >  BOOLEAN    mDxeCapsuleLibEndOfDxe      = FALSE;
> > >  EFI_EVENT  mDxeCapsuleLibEndOfDxeEvent = NULL;
> > > @@ -1394,14 +1393,12 @@ IsNestedFmpCapsule (
> > >    EFI_SYSTEM_RESOURCE_ENTRY  Entry;
> > >
> > >    EsrtGuidFound = FALSE;
> > > -  if (mIsVirtualAddrConverted) {
> > > -    if (mEsrtTable != NULL) {
> > > -      EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> > > -      for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++,
> > EsrtEntry++) {
> > > -        if (CompareGuid (&EsrtEntry->FwClass,
> > &CapsuleHeader->CapsuleGuid)) {
> > > -          EsrtGuidFound = TRUE;
> > > -          break;
> > > -        }
> > > +  if (mEsrtTable != NULL) {
> > > +    EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> > > +    for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++,
> > EsrtEntry++) {
> > > +      if (CompareGuid (&EsrtEntry->FwClass,
> > &CapsuleHeader->CapsuleGuid)) {
> > > +        EsrtGuidFound = TRUE;
> > > +        break;
> > >        }
> > >      }
> > >    } else {
> > > diff --git
> > a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > index 9ceb44fe4d79..44f30c16c284 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > @@ -21,7 +21,6 @@
> > >  #include <Library/MemoryAllocationLib.h>
> > >
> > >  extern EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable;
> > > -extern BOOLEAN                    mIsVirtualAddrConverted;
> > >  EFI_EVENT
> > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
> > >  EFI_EVENT
> > mDxeRuntimeCapsuleLibReadyToBootEvent          = NULL;
> > >
> > > @@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent (
> > >    )
> > >  {
> > >    gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable);
> > > -  mIsVirtualAddrConverted = TRUE;
> > >  }
> > >
> > >  /**
> > > --
> > > 2.25.1
> > >
> >
> >
> >
> >
>
>
>
>
>
> 
>
>


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



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

end of thread, other threads:[~2023-11-28 18:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-23  4:48 [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted Nhi Pham via groups.io
2023-11-23  8:36 ` Ard Biesheuvel
2023-11-23 12:10   ` Nhi Pham via groups.io
2023-11-28 15:14   ` 回复: " gaoliming via groups.io
2023-11-28 18:10     ` Ard Biesheuvel

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