]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/BDS: Do not pass unnecessary option to boot option
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 30 Nov 2015 03:08:49 +0000 (03:08 +0000)
committerniruiyu <niruiyu@Edk2>
Mon, 30 Nov 2015 03:08:49 +0000 (03:08 +0000)
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.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19007 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c

index e9634580f4846e4aa94aa8106556fa06e5607f6e..7297a1ddda2f7e7159b9a3ce29ddffaafdd05caf 100644 (file)
@@ -52,6 +52,28 @@ EfiBootManagerRegisterLegacyBootSupport (
   mBmLegacyBoot              = LegacyBoot;\r
 }\r
 \r
+/**\r
+  Return TRUE when the boot option is auto-created instead of manually added.\r
+\r
+  @param BootOption Pointer to the boot option to check.\r
+\r
+  @retval TRUE  The boot option is auto-created.\r
+  @retval FALSE The boot option is manually added.\r
+**/\r
+BOOLEAN\r
+BmIsAutoCreateBootOption (\r
+  EFI_BOOT_MANAGER_LOAD_OPTION    *BootOption\r
+  )\r
+{\r
+  if ((BootOption->OptionalDataSize == sizeof (EFI_GUID)) &&\r
+      CompareGuid ((EFI_GUID *) BootOption->OptionalData, &mBmAutoCreateBootOptionGuid)\r
+      ) {\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
 /**\r
   For a bootable Device path, return its boot type.\r
 \r
@@ -1814,8 +1836,10 @@ EfiBootManagerBoot (
   Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ImageInfo);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  ImageInfo->LoadOptionsSize  = BootOption->OptionalDataSize;\r
-  ImageInfo->LoadOptions      = BootOption->OptionalData;\r
+  if (!BmIsAutoCreateBootOption (BootOption)) {\r
+    ImageInfo->LoadOptionsSize = BootOption->OptionalDataSize;\r
+    ImageInfo->LoadOptions     = BootOption->OptionalData;\r
+  }\r
 \r
   //\r
   // Clean to NULL because the image is loaded directly from the firmwares boot manager.\r
@@ -2231,9 +2255,7 @@ EfiBootManagerRefreshAllBootOption (
   for (Index = 0; Index < NvBootOptionCount; Index++) {\r
     if (((DevicePathType (NvBootOptions[Index].FilePath) != BBS_DEVICE_PATH) || \r
          (DevicePathSubType (NvBootOptions[Index].FilePath) != BBS_BBS_DP)\r
-        ) &&\r
-        (NvBootOptions[Index].OptionalDataSize == sizeof (EFI_GUID)) &&\r
-        CompareGuid ((EFI_GUID *) NvBootOptions[Index].OptionalData, &mBmAutoCreateBootOptionGuid)\r
+        ) && BmIsAutoCreateBootOption (&NvBootOptions[Index])\r
        ) {\r
       //\r
       // Only check those added by BDS\r