public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg: Fix device path when the boot manager menu is from different FV
@ 2021-06-09  9:37 Zhiguang Liu
  2021-06-09  9:50 ` Ni, Ray
  2021-06-15  3:21 ` Wu, Hao A
  0 siblings, 2 replies; 3+ messages in thread
From: Zhiguang Liu @ 2021-06-09  9:37 UTC (permalink / raw)
  To: devel; +Cc: Jian J Wang, Hao A Wu, Zhichao Gao, Ray Ni

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3441

When the boot manager menu is from different FV, the current logic still use the
device path of the FV as the module links to this library

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 28 +++-------------------------
 1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index bef41ae102..95d185b639 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -2405,13 +2405,9 @@ BmRegisterBootManagerMenu (
   CHAR16                             *Description;
   UINTN                              DescriptionLength;
   EFI_DEVICE_PATH_PROTOCOL           *DevicePath;
-  EFI_LOADED_IMAGE_PROTOCOL          *LoadedImage;
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;
   UINTN                              HandleCount;
   EFI_HANDLE                         *Handles;
   UINTN                              Index;
-  VOID                               *Data;
-  UINTN                              DataSize;
 
   DevicePath = NULL;
   Description = NULL;
@@ -2437,22 +2433,17 @@ BmRegisterBootManagerMenu (
   }
 
   if (DevicePath == NULL) {
-    Data = NULL;
-    Status = GetSectionFromAnyFv (
+    Status = GetFileDevicePathFromAnyFv (
                PcdGetPtr (PcdBootManagerMenuFile),
                EFI_SECTION_PE32,
                0,
-               (VOID **) &Data,
-               &DataSize
+               &DevicePath
                );
-    if (Data != NULL) {
-      FreePool (Data);
-    }
     if (EFI_ERROR (Status)) {
       DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));
       return EFI_NOT_FOUND;
     }
-
+    ASSERT (DevicePath != NULL);
     //
     // Get BootManagerMenu application's description from EFI User Interface Section.
     //
@@ -2466,19 +2457,6 @@ BmRegisterBootManagerMenu (
     if (EFI_ERROR (Status)) {
       Description = NULL;
     }
-
-    EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr (PcdBootManagerMenuFile));
-    Status = gBS->HandleProtocol (
-                    gImageHandle,
-                    &gEfiLoadedImageProtocolGuid,
-                    (VOID **) &LoadedImage
-                    );
-    ASSERT_EFI_ERROR (Status);
-    DevicePath = AppendDevicePathNode (
-                   DevicePathFromHandle (LoadedImage->DeviceHandle),
-                   (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
-                   );
-    ASSERT (DevicePath != NULL);
   }
 
   Status = EfiBootManagerInitializeLoadOption (
-- 
2.30.0.windows.2


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

* Re: [PATCH] MdeModulePkg: Fix device path when the boot manager menu is from different FV
  2021-06-09  9:37 [PATCH] MdeModulePkg: Fix device path when the boot manager menu is from different FV Zhiguang Liu
@ 2021-06-09  9:50 ` Ni, Ray
  2021-06-15  3:21 ` Wu, Hao A
  1 sibling, 0 replies; 3+ messages in thread
From: Ni, Ray @ 2021-06-09  9:50 UTC (permalink / raw)
  To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Wang, Jian J, Wu, Hao A, Gao, Zhichao

Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Wednesday, June 9, 2021 5:37 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Gao, Zhichao <zhichao.gao@intel.com>; Ni, Ray <ray.ni@intel.com>
> Subject: [PATCH] MdeModulePkg: Fix device path when the boot manager
> menu is from different FV
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3441
> 
> When the boot manager menu is from different FV, the current logic still use
> the
> device path of the FV as the module links to this library
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
>  MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 28 +++-------------
> ------------
>  1 file changed, 3 insertions(+), 25 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> index bef41ae102..95d185b639 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> @@ -2405,13 +2405,9 @@ BmRegisterBootManagerMenu (
>    CHAR16                             *Description;
> 
>    UINTN                              DescriptionLength;
> 
>    EFI_DEVICE_PATH_PROTOCOL           *DevicePath;
> 
> -  EFI_LOADED_IMAGE_PROTOCOL          *LoadedImage;
> 
> -  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;
> 
>    UINTN                              HandleCount;
> 
>    EFI_HANDLE                         *Handles;
> 
>    UINTN                              Index;
> 
> -  VOID                               *Data;
> 
> -  UINTN                              DataSize;
> 
> 
> 
>    DevicePath = NULL;
> 
>    Description = NULL;
> 
> @@ -2437,22 +2433,17 @@ BmRegisterBootManagerMenu (
>    }
> 
> 
> 
>    if (DevicePath == NULL) {
> 
> -    Data = NULL;
> 
> -    Status = GetSectionFromAnyFv (
> 
> +    Status = GetFileDevicePathFromAnyFv (
> 
>                 PcdGetPtr (PcdBootManagerMenuFile),
> 
>                 EFI_SECTION_PE32,
> 
>                 0,
> 
> -               (VOID **) &Data,
> 
> -               &DataSize
> 
> +               &DevicePath
> 
>                 );
> 
> -    if (Data != NULL) {
> 
> -      FreePool (Data);
> 
> -    }
> 
>      if (EFI_ERROR (Status)) {
> 
>        DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be
> found, skip its boot option registration\n"));
> 
>        return EFI_NOT_FOUND;
> 
>      }
> 
> -
> 
> +    ASSERT (DevicePath != NULL);
> 
>      //
> 
>      // Get BootManagerMenu application's description from EFI User
> Interface Section.
> 
>      //
> 
> @@ -2466,19 +2457,6 @@ BmRegisterBootManagerMenu (
>      if (EFI_ERROR (Status)) {
> 
>        Description = NULL;
> 
>      }
> 
> -
> 
> -    EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr
> (PcdBootManagerMenuFile));
> 
> -    Status = gBS->HandleProtocol (
> 
> -                    gImageHandle,
> 
> -                    &gEfiLoadedImageProtocolGuid,
> 
> -                    (VOID **) &LoadedImage
> 
> -                    );
> 
> -    ASSERT_EFI_ERROR (Status);
> 
> -    DevicePath = AppendDevicePathNode (
> 
> -                   DevicePathFromHandle (LoadedImage->DeviceHandle),
> 
> -                   (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> 
> -                   );
> 
> -    ASSERT (DevicePath != NULL);
> 
>    }
> 
> 
> 
>    Status = EfiBootManagerInitializeLoadOption (
> 
> --
> 2.30.0.windows.2


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

* Re: [PATCH] MdeModulePkg: Fix device path when the boot manager menu is from different FV
  2021-06-09  9:37 [PATCH] MdeModulePkg: Fix device path when the boot manager menu is from different FV Zhiguang Liu
  2021-06-09  9:50 ` Ni, Ray
@ 2021-06-15  3:21 ` Wu, Hao A
  1 sibling, 0 replies; 3+ messages in thread
From: Wu, Hao A @ 2021-06-15  3:21 UTC (permalink / raw)
  To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Wang, Jian J, Gao, Zhichao, Ni, Ray

> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Wednesday, June 9, 2021 5:37 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Gao, Zhichao <zhichao.gao@intel.com>; Ni, Ray <ray.ni@intel.com>
> Subject: [PATCH] MdeModulePkg: Fix device path when the boot manager
> menu is from different FV
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3441
> 
> When the boot manager menu is from different FV, the current logic still use
> the
> device path of the FV as the module links to this library
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
>  MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 28 +++-------------
> ------------
>  1 file changed, 3 insertions(+), 25 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> index bef41ae102..95d185b639 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> @@ -2405,13 +2405,9 @@ BmRegisterBootManagerMenu (
>    CHAR16                             *Description;
> 
>    UINTN                              DescriptionLength;
> 
>    EFI_DEVICE_PATH_PROTOCOL           *DevicePath;
> 
> -  EFI_LOADED_IMAGE_PROTOCOL          *LoadedImage;
> 
> -  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;
> 
>    UINTN                              HandleCount;
> 
>    EFI_HANDLE                         *Handles;
> 
>    UINTN                              Index;
> 
> -  VOID                               *Data;
> 
> -  UINTN                              DataSize;
> 
> 
> 
>    DevicePath = NULL;
> 
>    Description = NULL;
> 
> @@ -2437,22 +2433,17 @@ BmRegisterBootManagerMenu (
>    }
> 
> 
> 
>    if (DevicePath == NULL) {
> 
> -    Data = NULL;
> 
> -    Status = GetSectionFromAnyFv (
> 
> +    Status = GetFileDevicePathFromAnyFv (
> 
>                 PcdGetPtr (PcdBootManagerMenuFile),
> 
>                 EFI_SECTION_PE32,
> 
>                 0,
> 
> -               (VOID **) &Data,
> 
> -               &DataSize
> 
> +               &DevicePath
> 
>                 );
> 
> -    if (Data != NULL) {
> 
> -      FreePool (Data);
> 
> -    }
> 
>      if (EFI_ERROR (Status)) {
> 
>        DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be
> found, skip its boot option registration\n"));
> 
>        return EFI_NOT_FOUND;
> 
>      }
> 
> -
> 
> +    ASSERT (DevicePath != NULL);
> 
>      //
> 
>      // Get BootManagerMenu application's description from EFI User
> Interface Section.
> 
>      //
> 
> @@ -2466,19 +2457,6 @@ BmRegisterBootManagerMenu (
>      if (EFI_ERROR (Status)) {
> 
>        Description = NULL;
> 
>      }
> 
> -
> 
> -    EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr
> (PcdBootManagerMenuFile));
> 
> -    Status = gBS->HandleProtocol (
> 
> -                    gImageHandle,
> 
> -                    &gEfiLoadedImageProtocolGuid,
> 
> -                    (VOID **) &LoadedImage
> 
> -                    );
> 
> -    ASSERT_EFI_ERROR (Status);
> 
> -    DevicePath = AppendDevicePathNode (
> 
> -                   DevicePathFromHandle (LoadedImage->DeviceHandle),
> 
> -                   (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> 
> -                   );
> 
> -    ASSERT (DevicePath != NULL);
> 
>    }


Acked-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


> 
> 
> 
>    Status = EfiBootManagerInitializeLoadOption (
> 
> --
> 2.30.0.windows.2


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

end of thread, other threads:[~2021-06-15  3:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-09  9:37 [PATCH] MdeModulePkg: Fix device path when the boot manager menu is from different FV Zhiguang Liu
2021-06-09  9:50 ` Ni, Ray
2021-06-15  3:21 ` Wu, Hao A

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