Revision: 19072
          http://sourceforge.net/p/edk2/code/19072
Author:   vanjeff
Date:     2015-12-01 01:56:57 +0000 (Tue, 01 Dec 2015)
Log Message:
-----------
MdeModulePkg/BDS: Do not pass unnecessary option to boot option

BDS puts a special GUID in boot option optional data for
auto-discovered boot option. But when launching that boot
option, the BDS core unconditionally pass the special GUID
to the executable.

A good written application/OS loader can ignore the unexpected
parameters, but BDS core should still avoid passing the
unnecessary GUID.

(Sync patch r19007 from main trunk.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <[email protected]>
Reviewed-by: Eric Dong <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/19007

Modified Paths:
--------------
    branches/UDK2015/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c

Modified: branches/UDK2015/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
===================================================================
--- branches/UDK2015/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   
2015-12-01 00:40:37 UTC (rev 19071)
+++ branches/UDK2015/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   
2015-12-01 01:56:57 UTC (rev 19072)
@@ -53,6 +53,28 @@
 }
 
 /**
+  Return TRUE when the boot option is auto-created instead of manually added.
+
+  @param BootOption Pointer to the boot option to check.
+
+  @retval TRUE  The boot option is auto-created.
+  @retval FALSE The boot option is manually added.
+**/
+BOOLEAN
+BmIsAutoCreateBootOption (
+  EFI_BOOT_MANAGER_LOAD_OPTION    *BootOption
+  )
+{
+  if ((BootOption->OptionalDataSize == sizeof (EFI_GUID)) &&
+      CompareGuid ((EFI_GUID *) BootOption->OptionalData, 
&mBmAutoCreateBootOptionGuid)
+      ) {
+    return TRUE;
+  } else {
+    return FALSE;
+  }
+}
+
+/**
   For a bootable Device path, return its boot type.
 
   @param  DevicePath                   The bootable device Path to check
@@ -1738,8 +1760,10 @@
   Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, 
(VOID **) &ImageInfo);
   ASSERT_EFI_ERROR (Status);
 
-  ImageInfo->LoadOptionsSize  = BootOption->OptionalDataSize;
-  ImageInfo->LoadOptions      = BootOption->OptionalData;
+  if (!BmIsAutoCreateBootOption (BootOption)) {
+    ImageInfo->LoadOptionsSize = BootOption->OptionalDataSize;
+    ImageInfo->LoadOptions     = BootOption->OptionalData;
+  }
 
   //
   // Clean to NULL because the image is loaded directly from the firmwares 
boot manager.
@@ -2155,9 +2179,7 @@
   for (Index = 0; Index < NvBootOptionCount; Index++) {
     if (((DevicePathType (NvBootOptions[Index].FilePath) != BBS_DEVICE_PATH) 
|| 
          (DevicePathSubType (NvBootOptions[Index].FilePath) != BBS_BBS_DP)
-        ) &&
-        (NvBootOptions[Index].OptionalDataSize == sizeof (EFI_GUID)) &&
-        CompareGuid ((EFI_GUID *) NvBootOptions[Index].OptionalData, 
&mBmAutoCreateBootOptionGuid)
+        ) && BmIsAutoCreateBootOption (&NvBootOptions[Index])
        ) {
       //
       // Only check those added by BDS


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to