public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] Support skipping automatic BM enumeration
@ 2019-10-30  3:47 Ashish Singhal
  2019-10-30  3:47 ` [PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping " Ashish Singhal
  2019-10-31 10:14 ` [edk2-devel] [PATCH] Support skipping automatic " Laszlo Ersek
  0 siblings, 2 replies; 49+ messages in thread
From: Ashish Singhal @ 2019-10-30  3:47 UTC (permalink / raw)
  To: devel, jian.j.wang, hao.a.wu; +Cc: Ashish Singhal

Right now, any and every handle with a BlockIO or SimpleFileSystem or
LoadFile protocol installed on the system is used to enumerate BM
automatically. There may be cases where on a platform, some of these
are not desirable to be enumerated automatically. This patch adds
support for skipping this automatic enumeration if on the same handle,
a new protocol defined as EdkiiSkipBmAutoEnumerate is found to be installed.

Ashish Singhal (1):
  MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration

 .../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40 +++++++++++++++++++++-
 .../Library/UefiBootManagerLib/InternalBm.h        |  1 +
 .../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
 MdeModulePkg/MdeModulePkg.dec                      |  3 ++
 5 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h

-- 
2.7.4


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

* [PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration
  2019-10-30  3:47 [PATCH] Support skipping automatic BM enumeration Ashish Singhal
@ 2019-10-30  3:47 ` Ashish Singhal
  2019-10-31 10:14 ` [edk2-devel] [PATCH] Support skipping automatic " Laszlo Ersek
  1 sibling, 0 replies; 49+ messages in thread
From: Ashish Singhal @ 2019-10-30  3:47 UTC (permalink / raw)
  To: devel, jian.j.wang, hao.a.wu; +Cc: Ashish Singhal

Allow support for skipping auto enumeration of a BlockIO or
SimpleFileSystem or LoadFile protocol based on a new protocol
installed on the same handle. EdkiiSkipBmAutoEnumerate protocol
has been added for that purpose.

Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
---
 .../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40 +++++++++++++++++++++-
 .../Library/UefiBootManagerLib/InternalBm.h        |  1 +
 .../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
 MdeModulePkg/MdeModulePkg.dec                      |  3 ++
 5 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h

diff --git a/MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h b/MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h
new file mode 100644
index 0000000..7efca7a
--- /dev/null
+++ b/MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h
@@ -0,0 +1,25 @@
+/** @file
+  Skip Boot Manager Auto Enumerate protocol header file.
+
+  This is used to skip auto boot manager enumeration. This protocol can
+  be installed on any handle having BlockIo or SimpleFileSystem or LoadFile
+  protocol and UEFI boot manager would skip its enumeration.
+
+Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _SKIP_BM_AUTO_ENUMERATE_PROTOCOL_H_
+#define _SKIP_BM_AUTO_ENUMERATE_PROTOCOL_H_
+
+///
+/// Global ID for the EDKII SKIP BM AUTO ENUMERATE Protocol.
+///
+#define EDKII_SKIP_BM_AUTO_ENUMERATE_PROTOCOL_GUID \
+  { 0x2733f321, 0x5a7e, 0x4178, { 0x86, 0xcc, 0x21, 0x65, 0xd2, 0x0c, 0xec, 0x1e }}
+
+extern EFI_GUID gEdkiiSkipBmAutoEnumerateProtocolGuid;
+
+#endif
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 760d764..7b5f176 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -2080,6 +2080,7 @@ BmEnumerateBootOptions (
   UINTN                                 HandleCount;
   EFI_HANDLE                            *Handles;
   EFI_BLOCK_IO_PROTOCOL                 *BlkIo;
+  VOID                                  *SkipBmAutoEnumerate;
   UINTN                                 Removable;
   UINTN                                 Index;
   CHAR16                                *Description;
@@ -2111,6 +2112,18 @@ BmEnumerateBootOptions (
         continue;
       }
 
+      Status = gBS->HandleProtocol (
+                      Handles[Index],
+                      &gEdkiiSkipBmAutoEnumerateProtocolGuid,
+                      (VOID **) &SkipBmAutoEnumerate
+                      );
+      if (!EFI_ERROR (Status)) {
+        //
+        //  Skip if the file system handle supports a SkipBmAutoEnumerate protocol
+        //
+        continue;
+      }
+
       //
       // Skip the logical partitions
       //
@@ -2169,12 +2182,25 @@ BmEnumerateBootOptions (
                     &gEfiBlockIoProtocolGuid,
                     (VOID **) &BlkIo
                     );
-     if (!EFI_ERROR (Status)) {
+    if (!EFI_ERROR (Status)) {
       //
       //  Skip if the file system handle supports a BlkIo protocol, which we've handled in above
       //
       continue;
     }
+
+    Status = gBS->HandleProtocol (
+                    Handles[Index],
+                    &gEdkiiSkipBmAutoEnumerateProtocolGuid,
+                    (VOID **) &SkipBmAutoEnumerate
+                    );
+    if (!EFI_ERROR (Status)) {
+      //
+      //  Skip if the file system handle supports a SkipBmAutoEnumerate protocol
+      //
+      continue;
+    }
+
     Description = BmGetBootDescription (Handles[Index]);
     BootOptions = ReallocatePool (
                     sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount),
@@ -2212,6 +2238,18 @@ BmEnumerateBootOptions (
          &Handles
          );
   for (Index = 0; Index < HandleCount; Index++) {
+    Status = gBS->HandleProtocol (
+                    Handles[Index],
+                    &gEdkiiSkipBmAutoEnumerateProtocolGuid,
+                    (VOID **) &SkipBmAutoEnumerate
+                    );
+    if (!EFI_ERROR (Status)) {
+      //
+      //  Skip if the file system handle supports a SkipBmAutoEnumerate protocol
+      //
+      continue;
+    }
+
     //
     // Ignore BootManagerMenu. its boot option will be created by EfiBootManagerGetBootManagerMenu().
     //
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
index 027eb25..f95e58f 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
+++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
@@ -41,6 +41,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Protocol/VariableLock.h>
 #include <Protocol/RamDisk.h>
 #include <Protocol/DeferredImageLoad.h>
+#include <Protocol/SkipBmAutoEnumerate.h>
 
 #include <Guid/MemoryTypeInformation.h>
 #include <Guid/FileInfo.h>
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
index ed6b467..40c668c 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@@ -107,6 +107,7 @@
   gEfiFormBrowser2ProtocolGuid                  ## SOMETIMES_CONSUMES
   gEfiRamDiskProtocolGuid                       ## SOMETIMES_CONSUMES
   gEfiDeferredImageLoadProtocolGuid             ## SOMETIMES_CONSUMES
+  gEdkiiSkipBmAutoEnumerateProtocolGuid         ## SOMETIMES_CONSUMES
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange      ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index d6bac97..64ef22a 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -604,6 +604,9 @@
   ## Include/Protocol/PeCoffImageEmulator.h
   gEdkiiPeCoffImageEmulatorProtocolGuid = { 0x96f46153, 0x97a7, 0x4793, { 0xac, 0xc1, 0xfa, 0x19, 0xbf, 0x78, 0xea, 0x97 } }
 
+  ## Include/Protocol/SkipBmAutoEnumerate.h
+  gEdkiiSkipBmAutoEnumerateProtocolGuid = { 0x2733f321, 0x5a7e, 0x4178, { 0x86, 0xcc, 0x21, 0x65, 0xd2, 0x0c, 0xec, 0x1e } }
+
 #
 # [Error.gEfiMdeModulePkgTokenSpaceGuid]
 #   0x80000001 | Invalid value provided.
-- 
2.7.4


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-10-30  3:47 [PATCH] Support skipping automatic BM enumeration Ashish Singhal
  2019-10-30  3:47 ` [PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping " Ashish Singhal
@ 2019-10-31 10:14 ` Laszlo Ersek
       [not found]   ` <DM6PR12MB33249A87560B32B0155D4FE0BA630@DM6PR12MB3324.namprd12.prod.outlook.com>
  2019-11-05  2:42   ` Ni, Ray
  1 sibling, 2 replies; 49+ messages in thread
From: Laszlo Ersek @ 2019-10-31 10:14 UTC (permalink / raw)
  To: devel, ashishsingha, jian.j.wang, hao.a.wu, Ray Ni, Zhichao Gao

+Ray, +Zhichao

(although, the actual patch seems to be missing from the posting)

Thanks
Laszlo

On 10/30/19 04:47, Ashish Singhal wrote:
> Right now, any and every handle with a BlockIO or SimpleFileSystem or
> LoadFile protocol installed on the system is used to enumerate BM
> automatically. There may be cases where on a platform, some of these
> are not desirable to be enumerated automatically. This patch adds
> support for skipping this automatic enumeration if on the same handle,
> a new protocol defined as EdkiiSkipBmAutoEnumerate is found to be installed.
> 
> Ashish Singhal (1):
>   MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration
> 
>  .../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
>  MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40 +++++++++++++++++++++-
>  .../Library/UefiBootManagerLib/InternalBm.h        |  1 +
>  .../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
>  MdeModulePkg/MdeModulePkg.dec                      |  3 ++
>  5 files changed, 69 insertions(+), 1 deletion(-)
>  create mode 100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h
> 


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
       [not found]   ` <DM6PR12MB33249A87560B32B0155D4FE0BA630@DM6PR12MB3324.namprd12.prod.outlook.com>
@ 2019-11-01 21:42     ` Laszlo Ersek
  2019-11-01 22:05       ` Ashish Singhal
  0 siblings, 1 reply; 49+ messages in thread
From: Laszlo Ersek @ 2019-11-01 21:42 UTC (permalink / raw)
  To: Ashish Singhal, devel@edk2.groups.io, jian.j.wang@intel.com,
	hao.a.wu@intel.com, Ray Ni, Zhichao Gao

On 10/31/19 13:42, Ashish Singhal wrote:
> Hello Laszlo,
> 
> This is the cover letter. The patch was also submitted.

Can you please state the groups.io permalink for the posted patch,
and/or the Message-Id header for the posted patch?

> Please let me know if you are unable to find it and I'll resubmit it.

I can't see the patch email in my list folder.

Thanks
Laszlo


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-01 21:42     ` Laszlo Ersek
@ 2019-11-01 22:05       ` Ashish Singhal
  2019-11-01 22:57         ` Laszlo Ersek
  0 siblings, 1 reply; 49+ messages in thread
From: Ashish Singhal @ 2019-11-01 22:05 UTC (permalink / raw)
  To: Laszlo Ersek, devel@edk2.groups.io, jian.j.wang@intel.com,
	hao.a.wu@intel.com, Ray Ni, Zhichao Gao

Please refer to https://edk2.groups.io/g/devel/message/49627 for the patch.

Thanks
Ashish

-----Original Message-----
From: Laszlo Ersek <lersek@redhat.com> 
Sent: Friday, November 1, 2019 3:42 PM
To: Ashish Singhal <ashishsingha@nvidia.com>; devel@edk2.groups.io; jian.j.wang@intel.com; hao.a.wu@intel.com; Ray Ni <ray.ni@intel.com>; Zhichao Gao <zhichao.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

On 10/31/19 13:42, Ashish Singhal wrote:
> Hello Laszlo,
> 
> This is the cover letter. The patch was also submitted.

Can you please state the groups.io permalink for the posted patch, and/or the Message-Id header for the posted patch?

> Please let me know if you are unable to find it and I'll resubmit it.

I can't see the patch email in my list folder.

Thanks
Laszlo

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-01 22:05       ` Ashish Singhal
@ 2019-11-01 22:57         ` Laszlo Ersek
  2019-11-04 17:51           ` Ashish Singhal
  0 siblings, 1 reply; 49+ messages in thread
From: Laszlo Ersek @ 2019-11-01 22:57 UTC (permalink / raw)
  To: Ashish Singhal, devel@edk2.groups.io, jian.j.wang@intel.com,
	hao.a.wu@intel.com, Ray Ni, Zhichao Gao

On 11/01/19 23:05, Ashish Singhal wrote:
> Please refer to https://edk2.groups.io/g/devel/message/49627 for the patch.

Thanks! The subject line is:

[PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration

This looks like a <groups.io> glitch to me -- a failure to reflect your
message to *some* subscribers. It's not just me that hasn't received the
patch, but at least a mailing list daemon too (which is subscribed to
the list in order to create a "secondary archive"):

https://www.redhat.com/archives/edk2-devel-archive/2019-October/author.html

The patch is not listed under your name.


On the other hand, the patch is there in the (also subscribed)
<mail-archive.com> collection, with apparently correct threading even:

http://mid.mail-archive.com/8a8ecae581eeffd193157096f09da53a3ab3a7ab.1572406843.git.ashishsingha@nvidia.com

So... I'm not sure.

Ray, Zhichao, did you get a copy of the patch? If not, then I think we
should ask Ashish to please repost.

Thanks
Laszlo

> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com> 
> Sent: Friday, November 1, 2019 3:42 PM
> To: Ashish Singhal <ashishsingha@nvidia.com>; devel@edk2.groups.io; jian.j.wang@intel.com; hao.a.wu@intel.com; Ray Ni <ray.ni@intel.com>; Zhichao Gao <zhichao.gao@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> On 10/31/19 13:42, Ashish Singhal wrote:
>> Hello Laszlo,
>>
>> This is the cover letter. The patch was also submitted.
> 
> Can you please state the groups.io permalink for the posted patch, and/or the Message-Id header for the posted patch?
> 
>> Please let me know if you are unable to find it and I'll resubmit it.
> 
> I can't see the patch email in my list folder.
> 
> Thanks
> Laszlo
> 
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information.  Any unauthorized review, use, disclosure or distribution
> is prohibited.  If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> 


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-01 22:57         ` Laszlo Ersek
@ 2019-11-04 17:51           ` Ashish Singhal
  0 siblings, 0 replies; 49+ messages in thread
From: Ashish Singhal @ 2019-11-04 17:51 UTC (permalink / raw)
  To: Laszlo Ersek, devel@edk2.groups.io, jian.j.wang@intel.com,
	hao.a.wu@intel.com, Ray Ni, Zhichao Gao

I sent 2 patches that day for 2 separate changes. I have resent those just now.

-----Original Message-----
From: Laszlo Ersek <lersek@redhat.com> 
Sent: Friday, November 1, 2019 4:58 PM
To: Ashish Singhal <ashishsingha@nvidia.com>; devel@edk2.groups.io; jian.j.wang@intel.com; hao.a.wu@intel.com; Ray Ni <ray.ni@intel.com>; Zhichao Gao <zhichao.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

On 11/01/19 23:05, Ashish Singhal wrote:
> Please refer to https://edk2.groups.io/g/devel/message/49627 for the patch.

Thanks! The subject line is:

[PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration

This looks like a <groups.io> glitch to me -- a failure to reflect your message to *some* subscribers. It's not just me that hasn't received the patch, but at least a mailing list daemon too (which is subscribed to the list in order to create a "secondary archive"):

https://www.redhat.com/archives/edk2-devel-archive/2019-October/author.html

The patch is not listed under your name.


On the other hand, the patch is there in the (also subscribed) <mail-archive.com> collection, with apparently correct threading even:

http://mid.mail-archive.com/8a8ecae581eeffd193157096f09da53a3ab3a7ab.1572406843.git.ashishsingha@nvidia.com

So... I'm not sure.

Ray, Zhichao, did you get a copy of the patch? If not, then I think we should ask Ashish to please repost.

Thanks
Laszlo

> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com>
> Sent: Friday, November 1, 2019 3:42 PM
> To: Ashish Singhal <ashishsingha@nvidia.com>; devel@edk2.groups.io; 
> jian.j.wang@intel.com; hao.a.wu@intel.com; Ray Ni <ray.ni@intel.com>; 
> Zhichao Gao <zhichao.gao@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
> 
> On 10/31/19 13:42, Ashish Singhal wrote:
>> Hello Laszlo,
>>
>> This is the cover letter. The patch was also submitted.
> 
> Can you please state the groups.io permalink for the posted patch, and/or the Message-Id header for the posted patch?
> 
>> Please let me know if you are unable to find it and I'll resubmit it.
> 
> I can't see the patch email in my list folder.
> 
> Thanks
> Laszlo
> 
> ----------------------------------------------------------------------
> ------------- This email message is for the sole use of the intended 
> recipient(s) and may contain confidential information.  Any 
> unauthorized review, use, disclosure or distribution is prohibited.  
> If you are not the intended recipient, please contact the sender by 
> reply email and destroy all copies of the original message.
> ----------------------------------------------------------------------
> -------------
> 


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-10-31 10:14 ` [edk2-devel] [PATCH] Support skipping automatic " Laszlo Ersek
       [not found]   ` <DM6PR12MB33249A87560B32B0155D4FE0BA630@DM6PR12MB3324.namprd12.prod.outlook.com>
@ 2019-11-05  2:42   ` Ni, Ray
  2019-11-05  3:24     ` Ashish Singhal
  1 sibling, 1 reply; 49+ messages in thread
From: Ni, Ray @ 2019-11-05  2:42 UTC (permalink / raw)
  To: Laszlo Ersek, devel@edk2.groups.io, ashishsingha@nvidia.com,
	Wang, Jian J, Wu, Hao A, Gao, Zhichao
  Cc: Kinney, Michael D

+ Mike

With the UEFI driver model, if a device is not needed by booting, it can skip the connecting.
Then I do not see a need of the new protocol.

Thanks,
Ray

> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com>
> Sent: Thursday, October 31, 2019 6:15 PM
> To: devel@edk2.groups.io; ashishsingha@nvidia.com; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Ni, Ray
> <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM
> enumeration
> 
> +Ray, +Zhichao
> 
> (although, the actual patch seems to be missing from the posting)
> 
> Thanks
> Laszlo
> 
> On 10/30/19 04:47, Ashish Singhal wrote:
> > Right now, any and every handle with a BlockIO or SimpleFileSystem or
> > LoadFile protocol installed on the system is used to enumerate BM
> > automatically. There may be cases where on a platform, some of these
> > are not desirable to be enumerated automatically. This patch adds
> > support for skipping this automatic enumeration if on the same handle,
> > a new protocol defined as EdkiiSkipBmAutoEnumerate is found to be
> installed.
> >
> > Ashish Singhal (1):
> >   MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration
> >
> >  .../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
> >  MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40
> +++++++++++++++++++++-
> >  .../Library/UefiBootManagerLib/InternalBm.h        |  1 +
> >  .../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
> >  MdeModulePkg/MdeModulePkg.dec                      |  3 ++
> >  5 files changed, 69 insertions(+), 1 deletion(-)  create mode 100644
> > MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h
> >


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  2:42   ` Ni, Ray
@ 2019-11-05  3:24     ` Ashish Singhal
  2019-11-05  5:00       ` Andrew Fish
  2019-11-05  9:33       ` Laszlo Ersek
  0 siblings, 2 replies; 49+ messages in thread
From: Ashish Singhal @ 2019-11-05  3:24 UTC (permalink / raw)
  To: Ni, Ray, Laszlo Ersek, devel@edk2.groups.io, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao
  Cc: Kinney, Michael D

Hi Ray,

I did not see any example with which one can tell BDS not to enumerate a boot option. Can you please point me to an example where a protocol (Block IO, Simple FS or Load File) does not get enumerated as a boot option?

Thanks
Ashish

-----Original Message-----
From: Ni, Ray <ray.ni@intel.com> 
Sent: Monday, November 4, 2019 7:42 PM
To: Laszlo Ersek <lersek@redhat.com>; devel@edk2.groups.io; Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

+ Mike

With the UEFI driver model, if a device is not needed by booting, it can skip the connecting.
Then I do not see a need of the new protocol.

Thanks,
Ray

> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com>
> Sent: Thursday, October 31, 2019 6:15 PM
> To: devel@edk2.groups.io; ashishsingha@nvidia.com; Wang, Jian J 
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Ni, Ray 
> <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
> 
> +Ray, +Zhichao
> 
> (although, the actual patch seems to be missing from the posting)
> 
> Thanks
> Laszlo
> 
> On 10/30/19 04:47, Ashish Singhal wrote:
> > Right now, any and every handle with a BlockIO or SimpleFileSystem 
> > or LoadFile protocol installed on the system is used to enumerate BM 
> > automatically. There may be cases where on a platform, some of these 
> > are not desirable to be enumerated automatically. This patch adds 
> > support for skipping this automatic enumeration if on the same 
> > handle, a new protocol defined as EdkiiSkipBmAutoEnumerate is found 
> > to be
> installed.
> >
> > Ashish Singhal (1):
> >   MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration
> >
> >  .../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
> >  MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40
> +++++++++++++++++++++-
> >  .../Library/UefiBootManagerLib/InternalBm.h        |  1 +
> >  .../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
> >  MdeModulePkg/MdeModulePkg.dec                      |  3 ++
> >  5 files changed, 69 insertions(+), 1 deletion(-)  create mode 
> > 100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h
> >


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  3:24     ` Ashish Singhal
@ 2019-11-05  5:00       ` Andrew Fish
  2019-11-05  5:06         ` Ashish Singhal
  2019-11-05  9:33       ` Laszlo Ersek
  1 sibling, 1 reply; 49+ messages in thread
From: Andrew Fish @ 2019-11-05  5:00 UTC (permalink / raw)
  To: devel, ashishsingha
  Cc: Ni, Ray, Laszlo Ersek, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 3847 bytes --]

> On Nov 4, 2019, at 9:24 PM, Ashish Singhal <ashishsingha@nvidia.com> wrote:
> 
> Hi Ray,
> 
> I did not see any example with which one can tell BDS not to enumerate a boot option. Can you please point me to an example where a protocol (Block IO, Simple FS or Load File) does not get enumerated as a boot option?
> 

Ashish,

Are you asking for example code, or reasons that you would not want to enumerate something as bootable? 

Most likely if you want to have a platform policy to add gEdkiiSkipBmAutoEnumerateProtocolGuid you are going to need an EFI Driver Model driver to add it to the handle based on some platform policy. This is the only way you can filter based on things getting connected at different times during boot. 

Thanks,

Andrew Fish


> Thanks
> Ashish
> 
> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com <mailto:ray.ni@intel.com>> 
> Sent: Monday, November 4, 2019 7:42 PM
> To: Laszlo Ersek <lersek@redhat.com <mailto:lersek@redhat.com>>; devel@edk2.groups.io <mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com <mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com <mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com <mailto:zhichao.gao@intel.com>>
> Cc: Kinney, Michael D <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> + Mike
> 
> With the UEFI driver model, if a device is not needed by booting, it can skip the connecting.
> Then I do not see a need of the new protocol.
> 
> Thanks,
> Ray
> 
>> -----Original Message-----
>> From: Laszlo Ersek <lersek@redhat.com>
>> Sent: Thursday, October 31, 2019 6:15 PM
>> To: devel@edk2.groups.io; ashishsingha@nvidia.com; Wang, Jian J 
>> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Ni, Ray 
>> <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>
>> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
>> enumeration
>> 
>> +Ray, +Zhichao
>> 
>> (although, the actual patch seems to be missing from the posting)
>> 
>> Thanks
>> Laszlo
>> 
>> On 10/30/19 04:47, Ashish Singhal wrote:
>>> Right now, any and every handle with a BlockIO or SimpleFileSystem 
>>> or LoadFile protocol installed on the system is used to enumerate BM 
>>> automatically. There may be cases where on a platform, some of these 
>>> are not desirable to be enumerated automatically. This patch adds 
>>> support for skipping this automatic enumeration if on the same 
>>> handle, a new protocol defined as EdkiiSkipBmAutoEnumerate is found 
>>> to be
>> installed.
>>> 
>>> Ashish Singhal (1):
>>>  MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration
>>> 
>>> .../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
>>> MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40
>> +++++++++++++++++++++-
>>> .../Library/UefiBootManagerLib/InternalBm.h        |  1 +
>>> .../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
>>> MdeModulePkg/MdeModulePkg.dec                      |  3 ++
>>> 5 files changed, 69 insertions(+), 1 deletion(-)  create mode 
>>> 100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h
>>> 
> 
> 
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information.  Any unauthorized review, use, disclosure or distribution
> is prohibited.  If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> 
> 


[-- Attachment #2: Type: text/html, Size: 31376 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  5:00       ` Andrew Fish
@ 2019-11-05  5:06         ` Ashish Singhal
  2019-11-05  5:21           ` Andrew Fish
  0 siblings, 1 reply; 49+ messages in thread
From: Ashish Singhal @ 2019-11-05  5:06 UTC (permalink / raw)
  To: afish@apple.com, devel@edk2.groups.io
  Cc: Ni, Ray, Laszlo Ersek, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 4759 bytes --]

Hello Andrew,

On my platform, I am installing Load File protocol on a handle which I do not want to be auto enumerated by boot manager. In order to achieve this, I submitted this match on edk2 side and have installed gEdkiiSkipBmAutoEnumerateProtocolGuid on the same handle to achieve this on platform side. If there is a different way to achieve what I am trying to do, please let me know and I would be happy to adopt that.

Thanks
Ashish

From: afish@apple.com <afish@apple.com>
Sent: Monday, November 4, 2019 10:01 PM
To: devel@edk2.groups.io; Ashish Singhal <ashishsingha@nvidia.com>
Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Mike Kinney <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

On Nov 4, 2019, at 9:24 PM, Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>> wrote:

Hi Ray,

I did not see any example with which one can tell BDS not to enumerate a boot option. Can you please point me to an example where a protocol (Block IO, Simple FS or Load File) does not get enumerated as a boot option?


Ashish,

Are you asking for example code, or reasons that you would not want to enumerate something as bootable?

Most likely if you want to have a platform policy to add gEdkiiSkipBmAutoEnumerateProtocolGuid you are going to need an EFI Driver Model driver to add it to the handle based on some platform policy. This is the only way you can filter based on things getting connected at different times during boot.

Thanks,

Andrew Fish



Thanks
Ashish

-----Original Message-----
From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 4, 2019 7:42 PM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>
Cc: Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

+ Mike

With the UEFI driver model, if a device is not needed by booting, it can skip the connecting.
Then I do not see a need of the new protocol.

Thanks,
Ray


-----Original Message-----
From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Thursday, October 31, 2019 6:15 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>; Wang, Jian J
<jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Ni, Ray
<ray.ni@intel.com<mailto:ray.ni@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM
enumeration

+Ray, +Zhichao

(although, the actual patch seems to be missing from the posting)

Thanks
Laszlo

On 10/30/19 04:47, Ashish Singhal wrote:

Right now, any and every handle with a BlockIO or SimpleFileSystem
or LoadFile protocol installed on the system is used to enumerate BM
automatically. There may be cases where on a platform, some of these
are not desirable to be enumerated automatically. This patch adds
support for skipping this automatic enumeration if on the same
handle, a new protocol defined as EdkiiSkipBmAutoEnumerate is found
to be
installed.


Ashish Singhal (1):
 MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration

.../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40
+++++++++++++++++++++-

.../Library/UefiBootManagerLib/InternalBm.h        |  1 +
.../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
MdeModulePkg/MdeModulePkg.dec                      |  3 ++
5 files changed, 69 insertions(+), 1 deletion(-)  create mode
100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------




[-- Attachment #2: Type: text/html, Size: 12829 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  5:06         ` Ashish Singhal
@ 2019-11-05  5:21           ` Andrew Fish
  2019-11-05  5:42             ` Ashish Singhal
  0 siblings, 1 reply; 49+ messages in thread
From: Andrew Fish @ 2019-11-05  5:21 UTC (permalink / raw)
  To: Ashish Singhal
  Cc: devel@edk2.groups.io, Ni, Ray, Laszlo Ersek, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao, Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 5784 bytes --]

Ashish,

Just to be clear on your definition of enumerate. In this case it means the Boot Manager lib that is just one of may implementations a platform could use to manage its boot options. 3rd party code, or an OS boot loader could try to boot your handle since by definition of the UEFI spec it is a bootable device. 

The simple answer is if you don't want your device to boot in normal cases, then don't add a Load File Protocol to your handle? What problem are you trying to solve?

gBS->LoadImage () supports an optional Source Buffer so you can just add a custom protocol and call your protocol to get a memory buffer and then just pass that buffer into gBS->LoadImage ()?

Thanks,

Andrew Fish

> On Nov 4, 2019, at 11:06 PM, Ashish Singhal <ashishsingha@nvidia.com> wrote:
> 
> Hello Andrew,
>
> On my platform, I am installing Load File protocol on a handle which I do not want to be auto enumerated by boot manager. In order to achieve this, I submitted this match on edk2 side and have installed gEdkiiSkipBmAutoEnumerateProtocolGuid on the same handle to achieve this on platform side. If there is a different way to achieve what I am trying to do, please let me know and I would be happy to adopt that.
>
> Thanks
> Ashish
>
> From: afish@apple.com <afish@apple.com> 
> Sent: Monday, November 4, 2019 10:01 PM
> To: devel@edk2.groups.io; Ashish Singhal <ashishsingha@nvidia.com>
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Mike Kinney <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> On Nov 4, 2019, at 9:24 PM, Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>> wrote:
>
> Hi Ray,
> 
> I did not see any example with which one can tell BDS not to enumerate a boot option. Can you please point me to an example where a protocol (Block IO, Simple FS or Load File) does not get enumerated as a boot option?
> 
>
> Ashish,
>
> Are you asking for example code, or reasons that you would not want to enumerate something as bootable? 
>
> Most likely if you want to have a platform policy to add gEdkiiSkipBmAutoEnumerateProtocolGuid you are going to need an EFI Driver Model driver to add it to the handle based on some platform policy. This is the only way you can filter based on things getting connected at different times during boot. 
>
> Thanks,
>
> Andrew Fish
>
> 
> 
> Thanks
> Ashish
> 
> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com <mailto:ray.ni@intel.com>> 
> Sent: Monday, November 4, 2019 7:42 PM
> To: Laszlo Ersek <lersek@redhat.com <mailto:lersek@redhat.com>>; devel@edk2.groups.io <mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com <mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com <mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com <mailto:zhichao.gao@intel.com>>
> Cc: Kinney, Michael D <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> + Mike
> 
> With the UEFI driver model, if a device is not needed by booting, it can skip the connecting.
> Then I do not see a need of the new protocol.
> 
> Thanks,
> Ray
> 
> 
> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com <mailto:lersek@redhat.com>>
> Sent: Thursday, October 31, 2019 6:15 PM
> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>; Wang, Jian J 
> <jian.j.wang@intel.com <mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com <mailto:hao.a.wu@intel.com>>; Ni, Ray 
> <ray.ni@intel.com <mailto:ray.ni@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com <mailto:zhichao.gao@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
> 
> +Ray, +Zhichao
> 
> (although, the actual patch seems to be missing from the posting)
> 
> Thanks
> Laszlo
> 
> On 10/30/19 04:47, Ashish Singhal wrote:
> 
> Right now, any and every handle with a BlockIO or SimpleFileSystem 
> or LoadFile protocol installed on the system is used to enumerate BM 
> automatically. There may be cases where on a platform, some of these 
> are not desirable to be enumerated automatically. This patch adds 
> support for skipping this automatic enumeration if on the same 
> handle, a new protocol defined as EdkiiSkipBmAutoEnumerate is found 
> to be
> installed.
> 
> 
> Ashish Singhal (1):
>  MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration
> 
> .../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
> MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40
> +++++++++++++++++++++-
> 
> .../Library/UefiBootManagerLib/InternalBm.h        |  1 +
> .../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
> MdeModulePkg/MdeModulePkg.dec                      |  3 ++
> 5 files changed, 69 insertions(+), 1 deletion(-)  create mode 
> 100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h
> 
> 
> 
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information.  Any unauthorized review, use, disclosure or distribution
> is prohibited.  If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> 
> 


[-- Attachment #2: Type: text/html, Size: 17847 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  5:21           ` Andrew Fish
@ 2019-11-05  5:42             ` Ashish Singhal
  2019-11-05  6:15               ` Andrew Fish
  0 siblings, 1 reply; 49+ messages in thread
From: Ashish Singhal @ 2019-11-05  5:42 UTC (permalink / raw)
  To: afish@apple.com
  Cc: devel@edk2.groups.io, Ni, Ray, Laszlo Ersek, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao, Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 7080 bytes --]

Hi Andrew,

I have a use case where I install Load File protocol on a handle and want to expose that as a boot option through platform boot manager driver as I need it to have a custom description and custom option data along with it. This is the reason I submitted this patch so that someone can keep using edk2 uefi boot manager library and not expose a boot option if desired using this new protocol. In my use case, I use the load file protocol to be able to load kernel packaged in a proprietary manner for my platform and want to use custom optional data to provide kernel command line and custom description to identify the boot option.

Please suggest the best way for this and I would make necessary changes at my end.

Thanks
Ashish

From: afish@apple.com <afish@apple.com>
Sent: Monday, November 4, 2019 10:22 PM
To: Ashish Singhal <ashishsingha@nvidia.com>
Cc: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Mike Kinney <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Ashish,

Just to be clear on your definition of enumerate. In this case it means the Boot Manager lib that is just one of may implementations a platform could use to manage its boot options. 3rd party code, or an OS boot loader could try to boot your handle since by definition of the UEFI spec it is a bootable device.

The simple answer is if you don't want your device to boot in normal cases, then don't add a Load File Protocol to your handle? What problem are you trying to solve?

gBS->LoadImage () supports an optional Source Buffer so you can just add a custom protocol and call your protocol to get a memory buffer and then just pass that buffer into gBS->LoadImage ()?

Thanks,

Andrew Fish


On Nov 4, 2019, at 11:06 PM, Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>> wrote:

Hello Andrew,

On my platform, I am installing Load File protocol on a handle which I do not want to be auto enumerated by boot manager. In order to achieve this, I submitted this match on edk2 side and have installed gEdkiiSkipBmAutoEnumerateProtocolGuid on the same handle to achieve this on platform side. If there is a different way to achieve what I am trying to do, please let me know and I would be happy to adopt that.

Thanks
Ashish

From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Monday, November 4, 2019 10:01 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>
Cc: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

On Nov 4, 2019, at 9:24 PM, Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>> wrote:

Hi Ray,

I did not see any example with which one can tell BDS not to enumerate a boot option. Can you please point me to an example where a protocol (Block IO, Simple FS or Load File) does not get enumerated as a boot option?



Ashish,

Are you asking for example code, or reasons that you would not want to enumerate something as bootable?

Most likely if you want to have a platform policy to add gEdkiiSkipBmAutoEnumerateProtocolGuid you are going to need an EFI Driver Model driver to add it to the handle based on some platform policy. This is the only way you can filter based on things getting connected at different times during boot.

Thanks,

Andrew Fish




Thanks
Ashish

-----Original Message-----
From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 4, 2019 7:42 PM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>
Cc: Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

+ Mike

With the UEFI driver model, if a device is not needed by booting, it can skip the connecting.
Then I do not see a need of the new protocol.

Thanks,
Ray



-----Original Message-----
From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Thursday, October 31, 2019 6:15 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>; Wang, Jian J
<jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Ni, Ray
<ray.ni@intel.com<mailto:ray.ni@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM
enumeration

+Ray, +Zhichao

(although, the actual patch seems to be missing from the posting)

Thanks
Laszlo

On 10/30/19 04:47, Ashish Singhal wrote:


Right now, any and every handle with a BlockIO or SimpleFileSystem
or LoadFile protocol installed on the system is used to enumerate BM
automatically. There may be cases where on a platform, some of these
are not desirable to be enumerated automatically. This patch adds
support for skipping this automatic enumeration if on the same
handle, a new protocol defined as EdkiiSkipBmAutoEnumerate is found
to be
installed.



Ashish Singhal (1):
 MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration

.../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40
+++++++++++++++++++++-


.../Library/UefiBootManagerLib/InternalBm.h        |  1 +
.../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
MdeModulePkg/MdeModulePkg.dec                      |  3 ++
5 files changed, 69 insertions(+), 1 deletion(-)  create mode
100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------




[-- Attachment #2: Type: text/html, Size: 17777 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  5:42             ` Ashish Singhal
@ 2019-11-05  6:15               ` Andrew Fish
  2019-11-05  9:54                 ` Laszlo Ersek
  0 siblings, 1 reply; 49+ messages in thread
From: Andrew Fish @ 2019-11-05  6:15 UTC (permalink / raw)
  To: Ashish Singhal
  Cc: devel@edk2.groups.io, Ni, Ray, Laszlo Ersek, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao, Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 7914 bytes --]



> On Nov 4, 2019, at 11:42 PM, Ashish Singhal <ashishsingha@nvidia.com> wrote:
> 
> Hi Andrew,
>
> I have a use case where I install Load File protocol on a handle and want to expose that as a boot option through platform boot manager driver as I need it to have a custom description and custom option data along with it. This is the reason I submitted this patch so that someone can keep using edk2 uefi boot manager library and not expose a boot option if desired using this new protocol. In my use case, I use the load file protocol to be able to load kernel packaged in a proprietary manner for my platform and want to use custom optional data to provide kernel command line and custom description to identify the boot option.
>
> Please suggest the best way for this and I would make necessary changes at my end.
>

Ashish,

Can you just have the BDS add the boot variable with the extra info you need? That way it would be handled in the BM lib as an existing nvram variable? You could also edit any existing variables that point to your Load File to make sure they follow the rules you care about? 

It is legal from an UEFI spec point of view for a platform to edit the nvram boot variables based on platform boot policy. 

Thanks,

Andrew Fish


> Thanks
> Ashish
>
> From: afish@apple.com <afish@apple.com> 
> Sent: Monday, November 4, 2019 10:22 PM
> To: Ashish Singhal <ashishsingha@nvidia.com>
> Cc: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Mike Kinney <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> Ashish,
>
> Just to be clear on your definition of enumerate. In this case it means the Boot Manager lib that is just one of may implementations a platform could use to manage its boot options. 3rd party code, or an OS boot loader could try to boot your handle since by definition of the UEFI spec it is a bootable device. 
>
> The simple answer is if you don't want your device to boot in normal cases, then don't add a Load File Protocol to your handle? What problem are you trying to solve?
>
> gBS->LoadImage () supports an optional Source Buffer so you can just add a custom protocol and call your protocol to get a memory buffer and then just pass that buffer into gBS->LoadImage ()?
>
> Thanks,
>
> Andrew Fish
> 
> 
> On Nov 4, 2019, at 11:06 PM, Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>> wrote:
>
> Hello Andrew,
>
> On my platform, I am installing Load File protocol on a handle which I do not want to be auto enumerated by boot manager. In order to achieve this, I submitted this match on edk2 side and have installed gEdkiiSkipBmAutoEnumerateProtocolGuid on the same handle to achieve this on platform side. If there is a different way to achieve what I am trying to do, please let me know and I would be happy to adopt that.
>
> Thanks
> Ashish
>
> From: afish@apple.com <mailto:afish@apple.com> <afish@apple.com <mailto:afish@apple.com>> 
> Sent: Monday, November 4, 2019 10:01 PM
> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>>
> Cc: Ni, Ray <ray.ni@intel.com <mailto:ray.ni@intel.com>>; Laszlo Ersek <lersek@redhat.com <mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com <mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com <mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com <mailto:zhichao.gao@intel.com>>; Mike Kinney <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> On Nov 4, 2019, at 9:24 PM, Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>> wrote:
>
> Hi Ray,
> 
> I did not see any example with which one can tell BDS not to enumerate a boot option. Can you please point me to an example where a protocol (Block IO, Simple FS or Load File) does not get enumerated as a boot option?
> 
> 
>
> Ashish,
>
> Are you asking for example code, or reasons that you would not want to enumerate something as bootable? 
>
> Most likely if you want to have a platform policy to add gEdkiiSkipBmAutoEnumerateProtocolGuid you are going to need an EFI Driver Model driver to add it to the handle based on some platform policy. This is the only way you can filter based on things getting connected at different times during boot. 
>
> Thanks,
>
> Andrew Fish
>
> 
> 
> 
> Thanks
> Ashish
> 
> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com <mailto:ray.ni@intel.com>> 
> Sent: Monday, November 4, 2019 7:42 PM
> To: Laszlo Ersek <lersek@redhat.com <mailto:lersek@redhat.com>>; devel@edk2.groups.io <mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com <mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com <mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com <mailto:zhichao.gao@intel.com>>
> Cc: Kinney, Michael D <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> + Mike
> 
> With the UEFI driver model, if a device is not needed by booting, it can skip the connecting.
> Then I do not see a need of the new protocol.
> 
> Thanks,
> Ray
> 
> 
> 
> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com <mailto:lersek@redhat.com>>
> Sent: Thursday, October 31, 2019 6:15 PM
> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>; Wang, Jian J 
> <jian.j.wang@intel.com <mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com <mailto:hao.a.wu@intel.com>>; Ni, Ray 
> <ray.ni@intel.com <mailto:ray.ni@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com <mailto:zhichao.gao@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
> 
> +Ray, +Zhichao
> 
> (although, the actual patch seems to be missing from the posting)
> 
> Thanks
> Laszlo
> 
> On 10/30/19 04:47, Ashish Singhal wrote:
> 
> 
> Right now, any and every handle with a BlockIO or SimpleFileSystem 
> or LoadFile protocol installed on the system is used to enumerate BM 
> automatically. There may be cases where on a platform, some of these 
> are not desirable to be enumerated automatically. This patch adds 
> support for skipping this automatic enumeration if on the same 
> handle, a new protocol defined as EdkiiSkipBmAutoEnumerate is found 
> to be
> installed.
> 
> 
> 
> Ashish Singhal (1):
>  MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration
> 
> .../Include/Protocol/SkipBmAutoEnumerate.h         | 25 ++++++++++++++
> MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   | 40
> +++++++++++++++++++++-
> 
> 
> .../Library/UefiBootManagerLib/InternalBm.h        |  1 +
> .../UefiBootManagerLib/UefiBootManagerLib.inf      |  1 +
> MdeModulePkg/MdeModulePkg.dec                      |  3 ++
> 5 files changed, 69 insertions(+), 1 deletion(-)  create mode 
> 100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h
> 
> 
> 
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information.  Any unauthorized review, use, disclosure or distribution
> is prohibited.  If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> 
> 


[-- Attachment #2: Type: text/html, Size: 26183 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  3:24     ` Ashish Singhal
  2019-11-05  5:00       ` Andrew Fish
@ 2019-11-05  9:33       ` Laszlo Ersek
  1 sibling, 0 replies; 49+ messages in thread
From: Laszlo Ersek @ 2019-11-05  9:33 UTC (permalink / raw)
  To: Ashish Singhal, Ni, Ray, devel@edk2.groups.io, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao
  Cc: Kinney, Michael D

On 11/05/19 04:24, Ashish Singhal wrote:
> Hi Ray,
> 
> I did not see any example with which one can tell BDS not to
> enumerate a boot option. Can you please point me to an example where
> a protocol (Block IO, Simple FS or Load File) does not get enumerated
> as a boot option?

(I'm going to state the same thing that's been said in this thread
already, just maybe with a different formulation.)

In order for you to end up with a particular auto-generated option in
the boot manager, two "kinds" of things are necessary.


(1) Producing the protocol instance:

(1a) Your PlatformBootManagerLib instance must actively *connect* the
device in question to a suitable UEFI driver that follows to the UEFI
driver model, such that the UEFI driver produce the LoadFile protocol
instance. For example, you could be calling the
EfiBootManagerConnectAll() API, from UefiBootManagerLib.

(1b) Alternatively, if the device is a platform device, then you might
need a DXE driver, built into your platform firmware, that produces
LoadFile on top of the device, running (directly or indirectly) in the
driver's entry point function.


(2) Creating a boot option for the protocol instance:

(2a) With the LoadFile protocol instance existing, your
PlatformBootManagerLib instance must actively call a UefiBootManagerLib
API -- such as EfiBootManagerRefreshAllBootOption() -- that scans the
UEFI protocol database for various "bootable" protocols, and
auto-generates UEFI Boot#### variables for them (and updates BootOrder too).

(2b) Alternatively, your PlatformBootManagerLib instance may be
auto-setting Boot#### / BootOrder, in response to the LoadFile instance
in question, in some different manner.

----

The point is that *all* of the above actions are under your control. If
you want to prevent the auto-generation of a particular boot option,
then break the dependency chain in any one spot above, and then the
option will not be auto-generated.

- do not connect the device to a driver in your PlatformBootManagerLib,
- or remove the platform DXE driver, if you have that,

or:

- do not call EfiBootManagerRefreshAllBootOption(),
- or stop manually creating Boot#### / BootOrder for the subject
LoadFile (if you do that currently).

(

I did not point out all this when I first responded to your posting,
because I assumed your next question would be:

  OK, but then what do I call *instead of*
  EfiBootManagerRefreshAllBootOption()? I do need the auto-generation of
  boot options, speaking generally, except for this one LoadFile
  instance. I don't want to rewrite all of
  EfiBootManagerRefreshAllBootOption() as a platform function, just for
  the sake of this one exception.

Anticipating that counter-argument, I was tempted to suggest a different
approach (which we've done in the past): namely, making some lower-level
functions in UefiBootManagerLib public, so that PlatformBootManagerLib
instances can reuse those utility functions with finer granularity.

However, that approach is not extremely far from controlling
UefiBootManagerLib by different means, and in this particular case, I
couldn't suggest any obvious low-level functions from
UefiBootManagerLib, for making public, and to call in place of
EfiBootManagerRefreshAllBootOption(). For that, I think quite a bit of
refactoring would be necessary too.

And so I figured I'd let Ray and others respond first, to your proposal.

)

Thanks
Laszlo


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  6:15               ` Andrew Fish
@ 2019-11-05  9:54                 ` Laszlo Ersek
  2019-11-05 16:52                   ` Andrew Fish
  0 siblings, 1 reply; 49+ messages in thread
From: Laszlo Ersek @ 2019-11-05  9:54 UTC (permalink / raw)
  To: devel, afish, Ashish Singhal
  Cc: Ni, Ray, Wang, Jian J, Wu, Hao A, Gao, Zhichao, Mike Kinney

On 11/05/19 07:15, Andrew Fish via Groups.Io wrote:

> You could also edit any existing variables that point to your Load File to make sure they follow the rules you care about? 
> 
> It is legal from an UEFI spec point of view for a platform to edit the nvram boot variables based on platform boot policy. 

Good point; for example OVMF and ArmVirtQemu* do this, with the help of
QemuBootOrderLib. In essence:

- connect a particular set of devices ("ConnectDevicesFromQemu")
  - if that fails, call EfiBootManagerConnectAll()

- call EfiBootManagerRefreshAllBootOption()

- register UEFI Shell boot option manually

- filter and reorder boot options in a platform specific way
  ("RemoveStaleFvFileOptions", "SetBootOrderFromQemu")

All this happens in PlatformBootManagerAfterConsole().

Thanks,
Laszlo


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05  9:54                 ` Laszlo Ersek
@ 2019-11-05 16:52                   ` Andrew Fish
  2019-11-05 18:00                     ` Ashish Singhal
  0 siblings, 1 reply; 49+ messages in thread
From: Andrew Fish @ 2019-11-05 16:52 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: devel, Ashish Singhal, Ni, Ray, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Mike Kinney



> On Nov 5, 2019, at 3:54 AM, Laszlo Ersek <lersek@redhat.com> wrote:
> 
> On 11/05/19 07:15, Andrew Fish via Groups.Io wrote:
> 
>> You could also edit any existing variables that point to your Load File to make sure they follow the rules you care about? 
>> 
>> It is legal from an UEFI spec point of view for a platform to edit the nvram boot variables based on platform boot policy. 
> 
> Good point; for example OVMF and ArmVirtQemu* do this, with the help of
> QemuBootOrderLib. In essence:
> 
> - connect a particular set of devices ("ConnectDevicesFromQemu")
>  - if that fails, call EfiBootManagerConnectAll()
> 
> - call EfiBootManagerRefreshAllBootOption()
> 
> - register UEFI Shell boot option manually
> 
> - filter and reorder boot options in a platform specific way
>  ("RemoveStaleFvFileOptions", "SetBootOrderFromQemu")
> 
> All this happens in PlatformBootManagerAfterConsole().
> 


The intent of the EFI Boot Variables was generally for the OS Installer to write the nvram boot variable with the EFI_LOAD_OPTION (BootXXXX variable name, XXXX is the UINT16 hex value in BootoOrder) info. The reasons being the EFI code may not know the path to the OS Loader, or the arguments that should be passed to the OS Loader. 

I'd also point out EFI_LOAD_OPTION.Attributes has LOAD_OPTION_ACTIVE  and LOAD_OPTION_HIDDEN bits that give you more control of how the Boot Manager/BDS will deal with the existing nvram boot option. 

Thanks,

Andrew Fish


> Thanks,
> Laszlo
> 


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05 16:52                   ` Andrew Fish
@ 2019-11-05 18:00                     ` Ashish Singhal
  2019-11-05 19:23                       ` Laszlo Ersek
  0 siblings, 1 reply; 49+ messages in thread
From: Ashish Singhal @ 2019-11-05 18:00 UTC (permalink / raw)
  To: Andrew Fish, Laszlo Ersek
  Cc: devel@edk2.groups.io, Ni, Ray, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 4384 bytes --]

Hello Andrew/Laszlo,

Thank you for walking me through the steps that happen and what I can do in terms of modifying variables. I think I did not do a good job stating the exact issue I see when I try these options so I will try to explain it here.

First of all, I do want the boot option to be created for the load file protocol I am installing, but I need specific optional data for my platform.

Right now, UefiBootManagerLib looks for all instances of Block IO, Simple FS and Load File protocol handles and creates a boot option for them with mBmAutoCreateBootOptionGuid being the optional data. This GUID as optional data is used to keep track of whether the boot option is an auto-created one from the library or not. Because of this, however, there is no way right now for a platform to have its own optional data for the boot option. Now I agree that I can use the platform boot manager protocol to modify the boot variable and give the custom optional data I need, but that would not stop UefiBootManagerLib from creating another boot option with mBmAutoCreateBootOptionGuid as the optional data on the next bootup which I would have to delete every time in the platform boot manager driver. With the patch that I have proposed, UefiBootManagerLib would never create a boot option automatically if the platform wants it not to do it and it can be dealt with in the platform boot manager driver.

Alternatively, we can have platform boot manager driver change the attribute of such a boot option to be hidden and not active, and add a new boot option with the specific optional data we want. This would require changing EfiBootMangerFindLoadOption function to ignore differences in Attributes as otherwise, the system will recreate a new option with the active attribute set and delete the hidden one.

Thanks
Ashish
________________________________
From: afish@apple.com <afish@apple.com> on behalf of Andrew Fish <afish@apple.com>
Sent: Tuesday, November 5, 2019 9:52 AM
To: Laszlo Ersek <lersek@redhat.com>
Cc: devel@edk2.groups.io <devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com>; Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Mike Kinney <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



> On Nov 5, 2019, at 3:54 AM, Laszlo Ersek <lersek@redhat.com> wrote:
>
> On 11/05/19 07:15, Andrew Fish via Groups.Io wrote:
>
>> You could also edit any existing variables that point to your Load File to make sure they follow the rules you care about?
>>
>> It is legal from an UEFI spec point of view for a platform to edit the nvram boot variables based on platform boot policy.
>
> Good point; for example OVMF and ArmVirtQemu* do this, with the help of
> QemuBootOrderLib. In essence:
>
> - connect a particular set of devices ("ConnectDevicesFromQemu")
>  - if that fails, call EfiBootManagerConnectAll()
>
> - call EfiBootManagerRefreshAllBootOption()
>
> - register UEFI Shell boot option manually
>
> - filter and reorder boot options in a platform specific way
>  ("RemoveStaleFvFileOptions", "SetBootOrderFromQemu")
>
> All this happens in PlatformBootManagerAfterConsole().
>


The intent of the EFI Boot Variables was generally for the OS Installer to write the nvram boot variable with the EFI_LOAD_OPTION (BootXXXX variable name, XXXX is the UINT16 hex value in BootoOrder) info. The reasons being the EFI code may not know the path to the OS Loader, or the arguments that should be passed to the OS Loader.

I'd also point out EFI_LOAD_OPTION.Attributes has LOAD_OPTION_ACTIVE  and LOAD_OPTION_HIDDEN bits that give you more control of how the Boot Manager/BDS will deal with the existing nvram boot option.

Thanks,

Andrew Fish


> Thanks,
> Laszlo
>


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 9135 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05 18:00                     ` Ashish Singhal
@ 2019-11-05 19:23                       ` Laszlo Ersek
  2019-11-05 23:19                         ` Jeff Brasen
  2019-11-06  1:07                         ` Ashish Singhal
  0 siblings, 2 replies; 49+ messages in thread
From: Laszlo Ersek @ 2019-11-05 19:23 UTC (permalink / raw)
  To: Ashish Singhal, Andrew Fish
  Cc: devel@edk2.groups.io, Ni, Ray, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Mike Kinney

On 11/05/19 19:00, Ashish Singhal wrote:

> I agree that I can use the platform boot manager protocol to modify
> the boot variable and give the custom optional data I need, but that
> would not stop UefiBootManagerLib from creating another boot option
> with mBmAutoCreateBootOptionGuid as the optional data on the next
> bootup which I would have to delete every time in the platform boot
> manager driver.

>From a purely pragmatic perspective, I would act exactly like you
describe above. I'm not saying that this is the cleanest design, or that
it has the best performance. However, it also does not introduce
technical debt -- it's not a "wrong" thing to do --, and (from past
experience) keeping it 100% in platform code produces the least amount
of friction, and allows for the smoothest development. Extending
UefiBootManagerLib has always been an uphill battle.

Thanks
Laszlo


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05 19:23                       ` Laszlo Ersek
@ 2019-11-05 23:19                         ` Jeff Brasen
  2019-11-06  0:20                           ` Andrew Fish
  2019-11-06  9:56                           ` Laszlo Ersek
  2019-11-06  1:07                         ` Ashish Singhal
  1 sibling, 2 replies; 49+ messages in thread
From: Jeff Brasen @ 2019-11-05 23:19 UTC (permalink / raw)
  To: Laszlo Ersek, devel

[-- Attachment #1: Type: text/plain, Size: 582 bytes --]

Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?

What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

Thanks,

Jeff

[-- Attachment #2: Type: text/html, Size: 622 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05 23:19                         ` Jeff Brasen
@ 2019-11-06  0:20                           ` Andrew Fish
  2019-11-06  9:56                           ` Laszlo Ersek
  1 sibling, 0 replies; 49+ messages in thread
From: Andrew Fish @ 2019-11-06  0:20 UTC (permalink / raw)
  To: devel, jbrasen; +Cc: Laszlo Ersek

[-- Attachment #1: Type: text/plain, Size: 981 bytes --]



> On Nov 5, 2019, at 5:19 PM, Jeff Brasen <jbrasen@nvidia.com> wrote:
> 
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
> 
What changes every boot that forces the variable to need to get modified? 

I would assume the NOR driver is smart enough to not update a variable that is not changing. 

The custom BDS could could only create the variable for this device if it does not exist. 

Thanks,

Andrew Fish
> 
> Thanks,
> 
> Jeff
>
> 
> 


[-- Attachment #2: Type: text/html, Size: 1680 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05 19:23                       ` Laszlo Ersek
  2019-11-05 23:19                         ` Jeff Brasen
@ 2019-11-06  1:07                         ` Ashish Singhal
  2019-11-06  1:34                           ` Jeff Brasen
  1 sibling, 1 reply; 49+ messages in thread
From: Ashish Singhal @ 2019-11-06  1:07 UTC (permalink / raw)
  To: Laszlo Ersek, Andrew Fish, Jeff Brasen
  Cc: devel@edk2.groups.io, Ni, Ray, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Mike Kinney

Reconciling the email chain from devel.io portal as it does not send email to individual participants.

On Nov 5, 2019, at 5:19 PM, Jeff Brasen <jbrasen@...> wrote:

Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified? 

I would assume the NOR driver is smart enough to not update a variable that is not changing. 

The custom BDS could could only create the variable for this device if it does not exist. 

Thanks,

Andrew Fish

Thanks,

Jeff

-----Original Message-----
From: Laszlo Ersek <lersek@redhat.com> 
Sent: Tuesday, November 5, 2019 12:24 PM
To: Ashish Singhal <ashishsingha@nvidia.com>; Andrew Fish <afish@apple.com>
Cc: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Mike Kinney <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

On 11/05/19 19:00, Ashish Singhal wrote:

> I agree that I can use the platform boot manager protocol to modify 
> the boot variable and give the custom optional data I need, but that 
> would not stop UefiBootManagerLib from creating another boot option 
> with mBmAutoCreateBootOptionGuid as the optional data on the next 
> bootup which I would have to delete every time in the platform boot 
> manager driver.

>From a purely pragmatic perspective, I would act exactly like you describe above. I'm not saying that this is the cleanest design, or that it has the best performance. However, it also does not introduce technical debt -- it's not a "wrong" thing to do --, and (from past
experience) keeping it 100% in platform code produces the least amount of friction, and allows for the smoothest development. Extending UefiBootManagerLib has always been an uphill battle.

Thanks
Laszlo

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-06  1:07                         ` Ashish Singhal
@ 2019-11-06  1:34                           ` Jeff Brasen
  2019-11-06  2:47                             ` Andrew Fish
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-11-06  1:34 UTC (permalink / raw)
  To: Ashish Singhal, Laszlo Ersek, Andrew Fish
  Cc: devel@edk2.groups.io, Ni, Ray, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 2410 bytes --]


Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified?

I would assume the NOR driver is smart enough to not update a variable that is not changing.

The custom BDS could could only create the variable for this device if it does not exist.

[JB] The current flow with no changes in the boot manager would be as follows


  1.  Scan for instance of the boot option in the variables
  2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
  3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
  4.  Delete/disable the boot option in the variable store

When you reboot it won't find the variable so 1/2/4 will re-occur

The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c

If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.

If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.


Thanks,

Andrew Fish

Thanks,

Jeff



-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 3742 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-06  1:34                           ` Jeff Brasen
@ 2019-11-06  2:47                             ` Andrew Fish
  2019-11-06  3:20                               ` Ni, Ray
  0 siblings, 1 reply; 49+ messages in thread
From: Andrew Fish @ 2019-11-06  2:47 UTC (permalink / raw)
  To: devel, jbrasen
  Cc: Ashish Singhal, Laszlo Ersek, Ni, Ray, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 4503 bytes --]



> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com> wrote:
> 
> 
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
> 
> What changes every boot that forces the variable to need to get modified? 
> 
> I would assume the NOR driver is smart enough to not update a variable that is not changing. 
> 
> The custom BDS could could only create the variable for this device if it does not exist. 
> 
> [JB] The current flow with no changes in the boot manager would be as follows
> 
> Scan for instance of the boot option in the variables
> It will not be found, so create a new boot option store it to a variable and update BootOrder
> Platform code runs creates the options for the boot option it wants and writes those to variable store
> Delete/disable the boot option in the variable store
> 
> When you reboot it won't find the variable so 1/2/4 will re-occur
> 
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
> 
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
> 
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
> 

Jeff,

Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about. 

I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from. 

I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable. 


[1]
/**
  The function creates boot options for all possible bootable medias in the following order:
  1. Removable BlockIo            - The boot option only points to the removable media
                                    device, like USB key, DVD, Floppy etc.
  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
                                    like HardDisk.
  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
                                    SimpleFileSystem Protocol, but not supporting BlockIo
                                    protocol.
  4. LoadFile                     - The boot option points to the media supporting
                                    LoadFile protocol.
  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior

  The function won't delete the boot option not added by itself.
**/
VOID
EFIAPI
EfiBootManagerRefreshAllBootOption (
  VOID
  );

Thanks,

Andrew Fish

> 
> Thanks,
> 
> Andrew Fish
> 
> Thanks,
> 
> Jeff
> 
> 
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
> 


[-- Attachment #2: Type: text/html, Size: 9510 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-06  2:47                             ` Andrew Fish
@ 2019-11-06  3:20                               ` Ni, Ray
  2019-11-06 16:19                                 ` Andrew Fish
  0 siblings, 1 reply; 49+ messages in thread
From: Ni, Ray @ 2019-11-06  3:20 UTC (permalink / raw)
  To: afish@apple.com, devel@edk2.groups.io, jbrasen@nvidia.com
  Cc: Ashish Singhal, Laszlo Ersek, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 5473 bytes --]

Andrew,
I agree with your opinion.
It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
called in every boot.
So you could:

  1.  Delete the auto-created option pointing to LoadFile instance
  2.  Create your own one with customized description.


From: afish@apple.com <afish@apple.com>
Sent: Wednesday, November 6, 2019 10:47 AM
To: devel@edk2.groups.io; jbrasen@nvidia.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration




On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:


Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified?

I would assume the NOR driver is smart enough to not update a variable that is not changing.

The custom BDS could could only create the variable for this device if it does not exist.

[JB] The current flow with no changes in the boot manager would be as follows


  1.  Scan for instance of the boot option in the variables
  2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
  3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
  4.  Delete/disable the boot option in the variable store

When you reboot it won't find the variable so 1/2/4 will re-occur

The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c

If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.

If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.


Jeff,

Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.

I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.

I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.


[1]
/**
  The function creates boot options for all possible bootable medias in the following order:
  1. Removable BlockIo            - The boot option only points to the removable media
                                    device, like USB key, DVD, Floppy etc.
  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
                                    like HardDisk.
  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
                                    SimpleFileSystem Protocol, but not supporting BlockIo
                                    protocol.
  4. LoadFile                     - The boot option points to the media supporting
                                    LoadFile protocol.
  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior

  The function won't delete the boot option not added by itself.
**/
VOID
EFIAPI
EfiBootManagerRefreshAllBootOption (
  VOID
  );

Thanks,

Andrew Fish



Thanks,

Andrew Fish

Thanks,

Jeff

________________________________
This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________



[-- Attachment #2: Type: text/html, Size: 17913 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-05 23:19                         ` Jeff Brasen
  2019-11-06  0:20                           ` Andrew Fish
@ 2019-11-06  9:56                           ` Laszlo Ersek
  2019-11-06 16:15                             ` Andrew Fish
  1 sibling, 1 reply; 49+ messages in thread
From: Laszlo Ersek @ 2019-11-06  9:56 UTC (permalink / raw)
  To: Jeff Brasen, devel

On 11/06/19 00:19, Jeff Brasen wrote:
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?

Yes, it most likely would.

[...]

Thanks
Laszlo


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-06  9:56                           ` Laszlo Ersek
@ 2019-11-06 16:15                             ` Andrew Fish
  2019-11-06 19:58                               ` Laszlo Ersek
  0 siblings, 1 reply; 49+ messages in thread
From: Andrew Fish @ 2019-11-06 16:15 UTC (permalink / raw)
  To: devel, Laszlo Ersek; +Cc: Jeff Brasen



> On Nov 6, 2019, at 3:56 AM, Laszlo Ersek <lersek@redhat.com> wrote:
> 
> On 11/06/19 00:19, Jeff Brasen wrote:
>> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> 
> Yes, it most likely would.

Should we write a BZ for the variable stack not to update a  variable if the data is not changing?

Thanks,

Andrew Fish

> 
> [...]
> 
> Thanks
> Laszlo
> 
> 
> 
> 


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-06  3:20                               ` Ni, Ray
@ 2019-11-06 16:19                                 ` Andrew Fish
  2019-11-07  4:12                                   ` Jeff Brasen
  2019-11-07  7:01                                   ` Ni, Ray
  0 siblings, 2 replies; 49+ messages in thread
From: Andrew Fish @ 2019-11-06 16:19 UTC (permalink / raw)
  To: Ni, Ray
  Cc: devel@edk2.groups.io, jbrasen@nvidia.com, Ashish Singhal,
	Laszlo Ersek, Wang, Jian J, Wu, Hao A, Gao, Zhichao, Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 5831 bytes --]

Ray,

Is there an obvious hook point we could point Jeff and Ashish at? 

Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS. 

Thanks,

Andrew Fish

> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com> wrote:
> 
> Andrew,
> I agree with your opinion.
> It’s expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
> The full configuration boot path is chosen when hardware changes happen. So it’s not expected EfiBootManagerRefresh…() be
> called in every boot.
> So you could:
> Delete the auto-created option pointing to LoadFile instance
> Create your own one with customized description.
>
>
> From: afish@apple.com <afish@apple.com> 
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io; jbrasen@nvidia.com
> Cc: Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> 
> 
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com <mailto:jbrasen@nvidia.com>> wrote:
>
> 
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
> 
> What changes every boot that forces the variable to need to get modified? 
> 
> I would assume the NOR driver is smart enough to not update a variable that is not changing. 
> 
> The custom BDS could could only create the variable for this device if it does not exist. 
> 
> [JB] The current flow with no changes in the boot manager would be as follows
>
> Scan for instance of the boot option in the variables
> It will not be found, so create a new boot option store it to a variable and update BootOrder
> Platform code runs creates the options for the boot option it wants and writes those to variable store
> Delete/disable the boot option in the variable store
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
> Jeff,
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about. 
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from. 
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable. 
>
>
> [1]
> /**
>   The function creates boot options for all possible bootable medias in the following order:
>   1. Removable BlockIo            - The boot option only points to the removable media
>                                     device, like USB key, DVD, Floppy etc.
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>                                     like HardDisk.
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>                                     protocol.
>   4. LoadFile                     - The boot option points to the media supporting
>                                     LoadFile protocol.
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>   The function won't delete the boot option not added by itself.
> **/
> VOID
> EFIAPI
> EfiBootManagerRefreshAllBootOption (
>   VOID
>   );
>
> Thanks,
>
> Andrew Fish
> 
> 
> 
> Thanks,
> 
> Andrew Fish
> 
> Thanks,
> 
> Jeff
> 
> 
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
> 


[-- Attachment #2: Type: text/html, Size: 22306 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-06 16:15                             ` Andrew Fish
@ 2019-11-06 19:58                               ` Laszlo Ersek
  0 siblings, 0 replies; 49+ messages in thread
From: Laszlo Ersek @ 2019-11-06 19:58 UTC (permalink / raw)
  To: Andrew Fish, devel; +Cc: Jeff Brasen

On 11/06/19 17:15, Andrew Fish wrote:
> 
> 
>> On Nov 6, 2019, at 3:56 AM, Laszlo Ersek <lersek@redhat.com> wrote:
>>
>> On 11/06/19 00:19, Jeff Brasen wrote:
>>> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
>>
>> Yes, it most likely would.
> 
> Should we write a BZ for the variable stack not to update a  variable if the data is not changing?

I'm not certain that, in this case, the write action would re-populate
exactly the same Boot#### variable with exactly the same data. It seems
like in the above, UefiBootManagerLib would create a new variable, and
then the PlatformBootManagerLib instance would make it disappear.

I don't think we should push down the recognition of the above pattern
to the variable driver -- the connection should be made at a higher
logical level. Ultimately, both UefiBootManagerLib and
PlatformBootManagerLib get linked into BdsDxe, so the current limitation
is due to API boundaries that we've created ourselves.

Thanks
Laszlo


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-06 16:19                                 ` Andrew Fish
@ 2019-11-07  4:12                                   ` Jeff Brasen
  2019-11-07  6:59                                     ` Ni, Ray
  2019-11-07  7:01                                   ` Ni, Ray
  1 sibling, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-11-07  4:12 UTC (permalink / raw)
  To: afish@apple.com, Ni, Ray
  Cc: devel@edk2.groups.io, Ashish Singhal, Laszlo Ersek, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao, Mike Kinney

[-- Attachment #1: Type: text/plain, Size: 7413 bytes --]

As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.

What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.

-Jeff

From: afish@apple.com <afish@apple.com>
Sent: Wednesday, November 6, 2019 9:20 AM
To: Ni, Ray <ray.ni@intel.com>
Cc: devel@edk2.groups.io; Jeff Brasen <jbrasen@nvidia.com>; Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Mike Kinney <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Ray,

Is there an obvious hook point we could point Jeff and Ashish at?

Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.

Thanks,

Andrew Fish


On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>> wrote:

Andrew,
I agree with your opinion.
It’s expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
The full configuration boot path is chosen when hardware changes happen. So it’s not expected EfiBootManagerRefresh…() be
called in every boot.
So you could:

  1.  Delete the auto-created option pointing to LoadFile instance
  2.  Create your own one with customized description.


From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 10:47 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration





On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:


Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified?

I would assume the NOR driver is smart enough to not update a variable that is not changing.

The custom BDS could could only create the variable for this device if it does not exist.

[JB] The current flow with no changes in the boot manager would be as follows


  1.  Scan for instance of the boot option in the variables
  2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
  3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
  4.  Delete/disable the boot option in the variable store

When you reboot it won't find the variable so 1/2/4 will re-occur

The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c

If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.

If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.


Jeff,

Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.

I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.

I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.


[1]
/**
  The function creates boot options for all possible bootable medias in the following order:
  1. Removable BlockIo            - The boot option only points to the removable media
                                    device, like USB key, DVD, Floppy etc.
  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
                                    like HardDisk.
  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
                                    SimpleFileSystem Protocol, but not supporting BlockIo
                                    protocol.
  4. LoadFile                     - The boot option points to the media supporting
                                    LoadFile protocol.
  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior

  The function won't delete the boot option not added by itself.
**/
VOID
EFIAPI
EfiBootManagerRefreshAllBootOption (
  VOID
  );

Thanks,

Andrew Fish




Thanks,

Andrew Fish

Thanks,

Jeff


________________________________
This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________



[-- Attachment #2: Type: text/html, Size: 20214 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-07  4:12                                   ` Jeff Brasen
@ 2019-11-07  6:59                                     ` Ni, Ray
  2019-11-07  7:02                                       ` Jeff Brasen
  0 siblings, 1 reply; 49+ messages in thread
From: Ni, Ray @ 2019-11-07  6:59 UTC (permalink / raw)
  To: Jeff Brasen, afish@apple.com
  Cc: devel@edk2.groups.io, Ashish Singhal, Laszlo Ersek, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao, Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 8462 bytes --]

Jeff,
RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).

From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Thursday, November 7, 2019 12:13 PM
To: afish@apple.com; Ni, Ray <ray.ni@intel.com>
Cc: devel@edk2.groups.io; Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.

What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.

-Jeff

From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 9:20 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Ray,

Is there an obvious hook point we could point Jeff and Ashish at?

Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.

Thanks,

Andrew Fish

On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>> wrote:

Andrew,
I agree with your opinion.
It’s expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
The full configuration boot path is chosen when hardware changes happen. So it’s not expected EfiBootManagerRefresh…() be
called in every boot.
So you could:

  1.  Delete the auto-created option pointing to LoadFile instance
  2.  Create your own one with customized description.


From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 10:47 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration




On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:


Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified?

I would assume the NOR driver is smart enough to not update a variable that is not changing.

The custom BDS could could only create the variable for this device if it does not exist.

[JB] The current flow with no changes in the boot manager would be as follows


  1.  Scan for instance of the boot option in the variables
  2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
  3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
  4.  Delete/disable the boot option in the variable store

When you reboot it won't find the variable so 1/2/4 will re-occur

The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c

If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.

If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.


Jeff,

Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.

I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.

I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.


[1]
/**
  The function creates boot options for all possible bootable medias in the following order:
  1. Removable BlockIo            - The boot option only points to the removable media
                                    device, like USB key, DVD, Floppy etc.
  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
                                    like HardDisk.
  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
                                    SimpleFileSystem Protocol, but not supporting BlockIo
                                    protocol.
  4. LoadFile                     - The boot option points to the media supporting
                                    LoadFile protocol.
  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior

  The function won't delete the boot option not added by itself.
**/
VOID
EFIAPI
EfiBootManagerRefreshAllBootOption (
  VOID
  );

Thanks,

Andrew Fish



Thanks,

Andrew Fish

Thanks,

Jeff

________________________________
This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________



[-- Attachment #2: Type: text/html, Size: 24215 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-06 16:19                                 ` Andrew Fish
  2019-11-07  4:12                                   ` Jeff Brasen
@ 2019-11-07  7:01                                   ` Ni, Ray
  1 sibling, 0 replies; 49+ messages in thread
From: Ni, Ray @ 2019-11-07  7:01 UTC (permalink / raw)
  To: devel@edk2.groups.io, afish@apple.com
  Cc: jbrasen@nvidia.com, Ashish Singhal, Laszlo Ersek, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao, Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 6891 bytes --]

Andrew,
PlatformBootManagerBeforeConsole() and PlatformBootManagerAfterConsole() are the only two hook points and I think they are general enough so that any thing can be done in the two points.

WIKI is a good way to explain. I will consider that : )

Thanks,
Ray

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Andrew Fish via Groups.Io
Sent: Thursday, November 7, 2019 12:20 AM
To: Ni, Ray <ray.ni@intel.com>
Cc: devel@edk2.groups.io; jbrasen@nvidia.com; Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Ray,

Is there an obvious hook point we could point Jeff and Ashish at?

Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.

Thanks,

Andrew Fish


On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>> wrote:

Andrew,
I agree with your opinion.
It’s expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
The full configuration boot path is chosen when hardware changes happen. So it’s not expected EfiBootManagerRefresh…() be
called in every boot.
So you could:

  1.  Delete the auto-created option pointing to LoadFile instance
  2.  Create your own one with customized description.


From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 10:47 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration





On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:


Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified?

I would assume the NOR driver is smart enough to not update a variable that is not changing.

The custom BDS could could only create the variable for this device if it does not exist.

[JB] The current flow with no changes in the boot manager would be as follows


  1.  Scan for instance of the boot option in the variables
  2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
  3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
  4.  Delete/disable the boot option in the variable store

When you reboot it won't find the variable so 1/2/4 will re-occur

The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c

If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.

If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.


Jeff,

Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.

I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.

I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.


[1]
/**
  The function creates boot options for all possible bootable medias in the following order:
  1. Removable BlockIo            - The boot option only points to the removable media
                                    device, like USB key, DVD, Floppy etc.
  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
                                    like HardDisk.
  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
                                    SimpleFileSystem Protocol, but not supporting BlockIo
                                    protocol.
  4. LoadFile                     - The boot option points to the media supporting
                                    LoadFile protocol.
  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior

  The function won't delete the boot option not added by itself.
**/
VOID
EFIAPI
EfiBootManagerRefreshAllBootOption (
  VOID
  );

Thanks,

Andrew Fish




Thanks,

Andrew Fish

Thanks,

Jeff


________________________________
This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________



[-- Attachment #2: Type: text/html, Size: 19883 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-07  6:59                                     ` Ni, Ray
@ 2019-11-07  7:02                                       ` Jeff Brasen
  2019-11-07  7:21                                         ` Ni, Ray
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-11-07  7:02 UTC (permalink / raw)
  To: Ni, Ray, afish@apple.com
  Cc: devel@edk2.groups.io, Ashish Singhal, Laszlo Ersek, Wang, Jian J,
	Wu, Hao A, Gao, Zhichao, Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 9315 bytes --]

The issue is there are some auto created options we do not want on our platform.

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Ni, Ray <ray.ni@intel.com>
Sent: Wednesday, November 6, 2019 11:59:31 PM
To: Jeff Brasen <jbrasen@nvidia.com>; afish@apple.com <afish@apple.com>
Cc: devel@edk2.groups.io <devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Jeff,

RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).



From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Thursday, November 7, 2019 12:13 PM
To: afish@apple.com; Ni, Ray <ray.ni@intel.com>
Cc: devel@edk2.groups.io; Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.



What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.



-Jeff



From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 9:20 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Ray,



Is there an obvious hook point we could point Jeff and Ashish at?



Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.



Thanks,



Andrew Fish



On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>> wrote:



Andrew,

I agree with your opinion.

It’s expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.

The full configuration boot path is chosen when hardware changes happen. So it’s not expected EfiBootManagerRefresh…() be
called in every boot.

So you could:

  1.  Delete the auto-created option pointing to LoadFile instance
  2.  Create your own one with customized description.





From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 10:47 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration







On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:



Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified?

I would assume the NOR driver is smart enough to not update a variable that is not changing.

The custom BDS could could only create the variable for this device if it does not exist.

[JB] The current flow with no changes in the boot manager would be as follows



  1.  Scan for instance of the boot option in the variables
  2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
  3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
  4.  Delete/disable the boot option in the variable store



When you reboot it won't find the variable so 1/2/4 will re-occur



The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c



If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.



If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.





Jeff,



Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.



I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.



I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.





[1]

/**

  The function creates boot options for all possible bootable medias in the following order:

  1. Removable BlockIo            - The boot option only points to the removable media

                                    device, like USB key, DVD, Floppy etc.

  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,

                                    like HardDisk.

  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting

                                    SimpleFileSystem Protocol, but not supporting BlockIo

                                    protocol.

  4. LoadFile                     - The boot option points to the media supporting

                                    LoadFile protocol.

  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior



  The function won't delete the boot option not added by itself.

**/

VOID

EFIAPI

EfiBootManagerRefreshAllBootOption (

  VOID

  );



Thanks,



Andrew Fish



Thanks,

Andrew Fish

Thanks,

Jeff


________________________________

This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

________________________________





[-- Attachment #2: Type: text/html, Size: 21211 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-07  7:02                                       ` Jeff Brasen
@ 2019-11-07  7:21                                         ` Ni, Ray
  2019-11-07 17:46                                           ` Jeff Brasen
  0 siblings, 1 reply; 49+ messages in thread
From: Ni, Ray @ 2019-11-07  7:21 UTC (permalink / raw)
  To: devel@edk2.groups.io, jbrasen@nvidia.com, afish@apple.com
  Cc: Ashish Singhal, Laszlo Ersek, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 10795 bytes --]

I treat the issue in this way:

  1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
  2.  But UiApp doesn't. It constantly call RefreshAll().

Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?

Thanks,
Ray

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jeff Brasen
Sent: Thursday, November 7, 2019 3:02 PM
To: Ni, Ray <ray.ni@intel.com>; afish@apple.com
Cc: devel@edk2.groups.io; Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

The issue is there are some auto created options we do not want on our platform.
Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Wednesday, November 6, 2019 11:59:31 PM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Jeff,

RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).



From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Thursday, November 7, 2019 12:13 PM
To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.



What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.



-Jeff



From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 9:20 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Ray,



Is there an obvious hook point we could point Jeff and Ashish at?



Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.



Thanks,



Andrew Fish



On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>> wrote:



Andrew,

I agree with your opinion.

It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.

The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
called in every boot.

So you could:

  1.  Delete the auto-created option pointing to LoadFile instance
  2.  Create your own one with customized description.





From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 10:47 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration







On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:



Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified?

I would assume the NOR driver is smart enough to not update a variable that is not changing.

The custom BDS could could only create the variable for this device if it does not exist.

[JB] The current flow with no changes in the boot manager would be as follows



  1.  Scan for instance of the boot option in the variables
  2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
  3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
  4.  Delete/disable the boot option in the variable store



When you reboot it won't find the variable so 1/2/4 will re-occur



The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c



If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.



If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.





Jeff,



Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.



I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.



I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.





[1]

/**

  The function creates boot options for all possible bootable medias in the following order:

  1. Removable BlockIo            - The boot option only points to the removable media

                                    device, like USB key, DVD, Floppy etc.

  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,

                                    like HardDisk.

  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting

                                    SimpleFileSystem Protocol, but not supporting BlockIo

                                    protocol.

  4. LoadFile                     - The boot option points to the media supporting

                                    LoadFile protocol.

  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior



  The function won't delete the boot option not added by itself.

**/

VOID

EFIAPI

EfiBootManagerRefreshAllBootOption (

  VOID

  );



Thanks,



Andrew Fish



Thanks,

Andrew Fish

Thanks,

Jeff

________________________________

This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

________________________________




[-- Attachment #2: Type: text/html, Size: 30040 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-07  7:21                                         ` Ni, Ray
@ 2019-11-07 17:46                                           ` Jeff Brasen
  2019-11-08 16:37                                             ` Laszlo Ersek
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-11-07 17:46 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io, afish@apple.com
  Cc: Ashish Singhal, Laszlo Ersek, Wang, Jian J, Wu, Hao A,
	Gao, Zhichao, Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 11848 bytes --]

Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Thanks,
Jeff


From: Ni, Ray <ray.ni@intel.com>
Sent: Thursday, November 7, 2019 12:21 AM
To: devel@edk2.groups.io; Jeff Brasen <jbrasen@nvidia.com>; afish@apple.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

I treat the issue in this way:

  1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
  2.  But UiApp doesn't. It constantly call RefreshAll().

Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?

Thanks,
Ray

From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Thursday, November 7, 2019 3:02 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

The issue is there are some auto created options we do not want on our platform.
Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Wednesday, November 6, 2019 11:59:31 PM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Jeff,

RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).



From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Thursday, November 7, 2019 12:13 PM
To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.



What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.



-Jeff



From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 9:20 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Ray,



Is there an obvious hook point we could point Jeff and Ashish at?



Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.



Thanks,



Andrew Fish



On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>> wrote:



Andrew,

I agree with your opinion.

It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.

The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
called in every boot.

So you could:

  1.  Delete the auto-created option pointing to LoadFile instance
  2.  Create your own one with customized description.





From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Sent: Wednesday, November 6, 2019 10:47 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration







On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:



Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?

What changes every boot that forces the variable to need to get modified?

I would assume the NOR driver is smart enough to not update a variable that is not changing.

The custom BDS could could only create the variable for this device if it does not exist.

[JB] The current flow with no changes in the boot manager would be as follows



  1.  Scan for instance of the boot option in the variables
  2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
  3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
  4.  Delete/disable the boot option in the variable store



When you reboot it won't find the variable so 1/2/4 will re-occur



The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c



If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.



If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.





Jeff,



Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.



I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.



I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.





[1]

/**

  The function creates boot options for all possible bootable medias in the following order:

  1. Removable BlockIo            - The boot option only points to the removable media

                                    device, like USB key, DVD, Floppy etc.

  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,

                                    like HardDisk.

  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting

                                    SimpleFileSystem Protocol, but not supporting BlockIo

                                    protocol.

  4. LoadFile                     - The boot option points to the media supporting

                                    LoadFile protocol.

  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior



  The function won't delete the boot option not added by itself.

**/

VOID

EFIAPI

EfiBootManagerRefreshAllBootOption (

  VOID

  );



Thanks,



Andrew Fish



Thanks,

Andrew Fish

Thanks,

Jeff

________________________________

This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

________________________________




[-- Attachment #2: Type: text/html, Size: 34451 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-07 17:46                                           ` Jeff Brasen
@ 2019-11-08 16:37                                             ` Laszlo Ersek
  2019-11-11 22:57                                               ` Jeff Brasen
  0 siblings, 1 reply; 49+ messages in thread
From: Laszlo Ersek @ 2019-11-08 16:37 UTC (permalink / raw)
  To: Jeff Brasen, Ni, Ray, devel@edk2.groups.io, afish@apple.com
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io; Jeff Brasen <jbrasen@nvidia.com>; afish@apple.com
> Cc: Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> I treat the issue in this way:
> 
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
> 
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
> 
> Thanks,
> Ray
> 
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
> 
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> Jeff,
> 
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
> 
> 
> 
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
> 
> 
> 
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
> 
> 
> 
> -Jeff
> 
> 
> 
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> Ray,
> 
> 
> 
> Is there an obvious hook point we could point Jeff and Ashish at?
> 
> 
> 
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
> 
> 
> 
> Thanks,
> 
> 
> 
> Andrew Fish
> 
> 
> 
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>> wrote:
> 
> 
> 
> Andrew,
> 
> I agree with your opinion.
> 
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
> 
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
> 
> So you could:
> 
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
> 
> 
> 
> 
> 
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> 
> 
> 
> 
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:
> 
> 
> 
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
> 
> What changes every boot that forces the variable to need to get modified?
> 
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
> 
> The custom BDS could could only create the variable for this device if it does not exist.
> 
> [JB] The current flow with no changes in the boot manager would be as follows
> 
> 
> 
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
> 
> 
> 
> When you reboot it won't find the variable so 1/2/4 will re-occur
> 
> 
> 
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
> 
> 
> 
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
> 
> 
> 
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
> 
> 
> 
> 
> 
> Jeff,
> 
> 
> 
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
> 
> 
> 
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
> 
> 
> 
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
> 
> 
> 
> 
> 
> [1]
> 
> /**
> 
>   The function creates boot options for all possible bootable medias in the following order:
> 
>   1. Removable BlockIo            - The boot option only points to the removable media
> 
>                                     device, like USB key, DVD, Floppy etc.
> 
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
> 
>                                     like HardDisk.
> 
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
> 
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
> 
>                                     protocol.
> 
>   4. LoadFile                     - The boot option points to the media supporting
> 
>                                     LoadFile protocol.
> 
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
> 
> 
> 
>   The function won't delete the boot option not added by itself.
> 
> **/
> 
> VOID
> 
> EFIAPI
> 
> EfiBootManagerRefreshAllBootOption (
> 
>   VOID
> 
>   );
> 
> 
> 
> Thanks,
> 
> 
> 
> Andrew Fish
> 
> 
> 
> Thanks,
> 
> Andrew Fish
> 
> Thanks,
> 
> Jeff
> 
> ________________________________
> 
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
> 
> ________________________________
> 
> 
> 
> 


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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-08 16:37                                             ` Laszlo Ersek
@ 2019-11-11 22:57                                               ` Jeff Brasen
  2019-11-11 23:58                                                 ` Ni, Ray
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-11-11 22:57 UTC (permalink / raw)
  To: Laszlo Ersek, Ni, Ray, devel@edk2.groups.io, afish@apple.com
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 14509 bytes --]

If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.

We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like

EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)

Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.


Thanks,

Jeff

________________________________
From: Laszlo Ersek <lersek@redhat.com>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com>; Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>; afish@apple.com <afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io; Jeff Brasen <jbrasen@nvidia.com>; afish@apple.com
> Cc: Ashish Singhal <ashishsingha@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
>
> 
>


[-- Attachment #2: Type: text/html, Size: 20628 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-11 22:57                                               ` Jeff Brasen
@ 2019-11-11 23:58                                                 ` Ni, Ray
  2019-11-12  0:00                                                   ` Jeff Brasen
  0 siblings, 1 reply; 49+ messages in thread
From: Ni, Ray @ 2019-11-11 23:58 UTC (permalink / raw)
  To: devel@edk2.groups.io, jbrasen@nvidia.com, Laszlo Ersek,
	afish@apple.com
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 18771 bytes --]

Jeff,
If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.

Thanks,
Ray

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com>; Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; afish@apple.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.

We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like

EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)

Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.


Thanks,

Jeff

________________________________
From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >


[-- Attachment #2: Type: text/html, Size: 28323 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-11 23:58                                                 ` Ni, Ray
@ 2019-11-12  0:00                                                   ` Jeff Brasen
  2019-11-13 18:42                                                     ` Jeff Brasen
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-11-12  0:00 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io, Laszlo Ersek, afish@apple.com
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 19563 bytes --]

I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.


Thanks,

Jeff

________________________________
From: Ni, Ray <ray.ni@intel.com>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com>; Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; afish@apple.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >



[-- Attachment #2: Type: text/html, Size: 28509 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-12  0:00                                                   ` Jeff Brasen
@ 2019-11-13 18:42                                                     ` Jeff Brasen
  2019-11-14  2:09                                                       ` Ni, Ray
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-11-13 18:42 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io, Laszlo Ersek, afish@apple.com
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 20814 bytes --]

Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.

We could change UiApp and BootManagerMenuApp (and any others that are relevant) from

EfiBootManagerRefreshAllBootOption ();

to

if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {
  EFI_EVENT Event;
  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );
  gBS->SignalEvent (Event);
  gBS->CloseEvent (Event);
} else {
  EfiBootManagerRefreshAllBootOption ();
}


Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.


Thanks,

Jeff

________________________________
From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.


Thanks,

Jeff

________________________________
From: Ni, Ray <ray.ni@intel.com>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com>; Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; afish@apple.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >



[-- Attachment #2: Type: text/html, Size: 32560 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-13 18:42                                                     ` Jeff Brasen
@ 2019-11-14  2:09                                                       ` Ni, Ray
  2019-11-14 17:04                                                         ` Jeff Brasen
  0 siblings, 1 reply; 49+ messages in thread
From: Ni, Ray @ 2019-11-14  2:09 UTC (permalink / raw)
  To: devel@edk2.groups.io, jbrasen@nvidia.com, Laszlo Ersek,
	afish@apple.com
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 22576 bytes --]

Jeff,
I think it's a good topic that we could discuss in the open design meeting.
Are you ok to present the problem you have and discuss the potential solutions in that meeting?
https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting

Thanks,
Ray

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jeff Brasen
Sent: Thursday, November 14, 2019 2:43 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.

We could change UiApp and BootManagerMenuApp (and any others that are relevant) from

EfiBootManagerRefreshAllBootOption ();

to

if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {
  EFI_EVENT Event;
  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );
  gBS->SignalEvent (Event);
  gBS->CloseEvent (Event);
} else {
  EfiBootManagerRefreshAllBootOption ();
}

Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.


Thanks,

Jeff

________________________________
From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.


Thanks,

Jeff

________________________________
From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >


[-- Attachment #2: Type: text/html, Size: 37563 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-14  2:09                                                       ` Ni, Ray
@ 2019-11-14 17:04                                                         ` Jeff Brasen
  2019-12-10 20:46                                                           ` Jeff Brasen
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-11-14 17:04 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io, Laszlo Ersek, afish@apple.com
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 24246 bytes --]

Yes, I think that would be good.

Summarizing everything in this thread

Problem: Platform needs to customize the boot options, this can be done for normal boot but the UiApp calls EfiBootManagerRefreshAllBootOption in a couple places.

Potential solutions:
1 - Define new PCD and event group if PCD is set true then signal event instead of calling EfiBootManagerRefreshAllBootOption in UiApp
2 - Add new function to boot manager library and replace call to EfiBootManagerRefreshAllBootOption in UiApp (need to coordinate rollout with updates to all platform.
3 - Add new protocol with new function, if supported call this otherwise call EfiBootManagerRefreshAllBootOption as is done now
4 - For 2/3 use  generic function so we don't need new APIs for future expansion
5 - Update EfiBootManagerRefreshAllBootOption to call platform specific function.

Thanks,
Jeff


From: Ni, Ray <ray.ni@intel.com>
Sent: Wednesday, November 13, 2019 7:09 PM
To: devel@edk2.groups.io; Jeff Brasen <jbrasen@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Jeff,
I think it's a good topic that we could discuss in the open design meeting.
Are you ok to present the problem you have and discuss the potential solutions in that meeting?
https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting

Thanks,
Ray

From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Thursday, November 14, 2019 2:43 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.

We could change UiApp and BootManagerMenuApp (and any others that are relevant) from

EfiBootManagerRefreshAllBootOption ();

to

if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {
  EFI_EVENT Event;
  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );
  gBS->SignalEvent (Event);
  gBS->CloseEvent (Event);
} else {
  EfiBootManagerRefreshAllBootOption ();
}

Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.


Thanks,

Jeff

________________________________
From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.


Thanks,

Jeff

________________________________
From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >


[-- Attachment #2: Type: text/html, Size: 40651 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-11-14 17:04                                                         ` Jeff Brasen
@ 2019-12-10 20:46                                                           ` Jeff Brasen
  2019-12-11  9:54                                                             ` [edk2-discuss] " Wang, Sunny (HPS SW)
  2019-12-11 14:00                                                             ` Ni, Ray
  0 siblings, 2 replies; 49+ messages in thread
From: Jeff Brasen @ 2019-12-10 20:46 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io, Laszlo Ersek, afish@apple.com,
	discuss@edk2.groups.io
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 24963 bytes --]

Can we discuss this at the design meeting this week (12/12)?


Thanks,

Jeff

________________________________
From: Jeff Brasen
Sent: Thursday, November 14, 2019 10:04 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Yes, I think that would be good.



Summarizing everything in this thread



Problem: Platform needs to customize the boot options, this can be done for normal boot but the UiApp calls EfiBootManagerRefreshAllBootOption in a couple places.



Potential solutions:

1 – Define new PCD and event group if PCD is set true then signal event instead of calling EfiBootManagerRefreshAllBootOption in UiApp

2 – Add new function to boot manager library and replace call to EfiBootManagerRefreshAllBootOption in UiApp (need to coordinate rollout with updates to all platform.

3 – Add new protocol with new function, if supported call this otherwise call EfiBootManagerRefreshAllBootOption as is done now

4 – For 2/3 use  generic function so we don’t need new APIs for future expansion

5 – Update EfiBootManagerRefreshAllBootOption to call platform specific function.



Thanks,
Jeff





From: Ni, Ray <ray.ni@intel.com>
Sent: Wednesday, November 13, 2019 7:09 PM
To: devel@edk2.groups.io; Jeff Brasen <jbrasen@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

I think it’s a good topic that we could discuss in the open design meeting.

Are you ok to present the problem you have and discuss the potential solutions in that meeting?

https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Thursday, November 14, 2019 2:43 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.



We could change UiApp and BootManagerMenuApp (and any others that are relevant) from



EfiBootManagerRefreshAllBootOption ();



to



if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {

  EFI_EVENT Event;

  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );

  gBS->SignalEvent (Event);

  gBS->CloseEvent (Event);

} else {

  EfiBootManagerRefreshAllBootOption ();

}



Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.



Thanks,

Jeff

________________________________

From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.



Thanks,

Jeff

________________________________

From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >



[-- Attachment #2: Type: text/html, Size: 39967 bytes --]

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

* Re: [edk2-discuss] [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-12-10 20:46                                                           ` Jeff Brasen
@ 2019-12-11  9:54                                                             ` Wang, Sunny (HPS SW)
  2019-12-11 14:00                                                             ` Ni, Ray
  1 sibling, 0 replies; 49+ messages in thread
From: Wang, Sunny (HPS SW) @ 2019-12-11  9:54 UTC (permalink / raw)
  To: discuss@edk2.groups.io, jbrasen@nvidia.com, Ni, Ray,
	devel@edk2.groups.io, Laszlo Ersek, afish@apple.com
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D, Spottswood, Jason, Wiginton, Scott,
	Wei, Kent (HPS SW), Wang, Sunny (HPS SW)

Hi all, 

Since I can't attend the design meeting (EMEA), I would like to add some use cases and a suggestion for your guys' reference before this topic being discussed:

We had similar needs (use cases) as Ashish like the following, so making this code change would be definitely good for system vendors like us. 
        - Disabling a specific boot option like a PXE boot option for a specific NIC port.
        - Hiding a partition that is used for special purpose rather than booting.   

If we don't have a strong reason to prevent creating a platform hook function (solution 5), I will prefer to use it because it is the simplest solution and can be easily extended and maintained. Also, solution 5 is our current implementation. We can even contribute our implementation to EDK2 if you guys need it. Moreover, if we finally choose solution 5, I will prefer to create a new platform library instead of adding a new function into the PlatformBootManagerLib, and let this new platform library only be called by UefiBootManagerLib. This would avoid a potential circular dependency problem.

For solutions 1, 2, 3, and 4, if I understand them correctly, they all require making changes in the EfiBootManagerRefreshAllBootOption callers. UiApp may not be the only application to call EfiBootManagerRefreshAllBootOption, so this may cause additional maintenance effort. However, if we still need to choose a solution other than solution 5, can we make the change directly in EfiBootManagerRefreshAllBootOption instead of UiApp? 

By the way, if we still need to discuss this further at a meeting, I will be at the other design meeting (APAC).

Regards,
Sunny Wang

-----Original Message-----
From: discuss@edk2.groups.io [mailto:discuss@edk2.groups.io] On Behalf Of Jeff Brasen
Sent: Wednesday, December 11, 2019 4:46 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com; discuss@edk2.groups.io
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-discuss] [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Can we discuss this at the design meeting this week (12/12)?


Thanks,

Jeff

________________________________
From: Jeff Brasen
Sent: Thursday, November 14, 2019 10:04 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Yes, I think that would be good.



Summarizing everything in this thread



Problem: Platform needs to customize the boot options, this can be done for normal boot but the UiApp calls EfiBootManagerRefreshAllBootOption in a couple places.



Potential solutions:

1 - Define new PCD and event group if PCD is set true then signal event instead of calling EfiBootManagerRefreshAllBootOption in UiApp

2 - Add new function to boot manager library and replace call to EfiBootManagerRefreshAllBootOption in UiApp (need to coordinate rollout with updates to all platform.

3 - Add new protocol with new function, if supported call this otherwise call EfiBootManagerRefreshAllBootOption as is done now

4 - For 2/3 use  generic function so we don't need new APIs for future expansion

5 - Update EfiBootManagerRefreshAllBootOption to call platform specific function.



Thanks,
Jeff





From: Ni, Ray <ray.ni@intel.com>
Sent: Wednesday, November 13, 2019 7:09 PM
To: devel@edk2.groups.io; Jeff Brasen <jbrasen@nvidia.com>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

I think it's a good topic that we could discuss in the open design meeting.

Are you ok to present the problem you have and discuss the potential solutions in that meeting?

https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Thursday, November 14, 2019 2:43 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.



We could change UiApp and BootManagerMenuApp (and any others that are relevant) from



EfiBootManagerRefreshAllBootOption ();



to



if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {

  EFI_EVENT Event;

  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );

  gBS->SignalEvent (Event);

  gBS->CloseEvent (Event);

} else {

  EfiBootManagerRefreshAllBootOption ();

}



Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.



Thanks,

Jeff

________________________________

From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.



Thanks,

Jeff

________________________________

From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the system, unless (perhaps) PlatformBootManagerLib specifically thinks otherwise.

Of course, then we arrive (again) at the problem that a call in UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define) the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen 
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; 
> afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo 
> Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael 
> D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>> 
> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gr
> oups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for 
> Android<INVALID URI REMOVED
> ei36&d=DwIF-g&c=C5b8zRQO1miGmBeVZ2LFWg&r=Z9cLgEMdGZCI1_R0bW6KqOAGzCXLJ
> UR24f8N3205AYw&m=tNOWNYcrAfOGKuSMyGZvQ46qeU3yiXGlPkDQK70Nshw&s=V7Nc8Wt
> ostFCvj8E2KL2RcggpHj8sblqsBrdrabOuoE&e= >
>
> ________________________________
> From: Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen 
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> m%3cmailto:jbrasen@nvidia.com>>>; 
> afish@apple.com<mailto:afish@apple.com> 
> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> o:afish@apple.com>>>
> Cc: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>> 
> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gr
> oups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen 
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> m%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>
> Cc: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> 
> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> o:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>
> Cc: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen 
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> m%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes 
> happen. So it's not expected EfiBootManagerRefresh...() be called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> 
> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> o:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>>; 
> jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as 
> follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in 
> BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device 
> supporting
>
>                                     SimpleFileSystem Protocol, but not 
> supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot 
> Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >






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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-12-10 20:46                                                           ` Jeff Brasen
  2019-12-11  9:54                                                             ` [edk2-discuss] " Wang, Sunny (HPS SW)
@ 2019-12-11 14:00                                                             ` Ni, Ray
  2019-12-12 17:52                                                               ` Jeff Brasen
  1 sibling, 1 reply; 49+ messages in thread
From: Ni, Ray @ 2019-12-11 14:00 UTC (permalink / raw)
  To: 'Jeff Brasen', devel@edk2.groups.io, Laszlo Ersek,
	afish@apple.com, discuss@edk2.groups.io
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 28293 bytes --]

Jeff,

Tom from AMD booked the meeting for SEV discussion months ago. I am afraid there is no time for this discussion.

Let's try to resolve it in mails.



Firstly, let me rephase the problem and your proposed solutions here (subjective + verb + objective). Sunny's input is also included. Hope Mike K and others can provide inputs.

Personally, I agree with 2.b. It helps us to gradually migrate the PlatformBootManagerLib to PlatformBootManager protocol. Protocol with Revision field helps to reduce the impact to old platforms with new APIs added.



**Problem:

               Platform requires certain BlockIo/SimpleFileSystem/LoadFile instances don't cause Boot#### created. It's a need of platform customization.



**Details:

               Boot#### for BlockIo/SimpleFileSystem/LoadFile are created by API EfiBootMangerRefreshAllBootOptions(). There are 2 places that call this API:

  1.  Platform Boot Manager calls the API (usually in the full configuration boot path)
  2.  UiApp calls the API when entering "Boot Manager" page and "Boot Maintenance Manager" page.



Platform can change Platform Boot Manager to remove the unneeded Boot#### in case #1.

But platform has no way to remove the Boot#### created in case #2 .



**Potential solutions:

  1.  Update UiApp
     *   Define a new PCD and a new event group.

If PCD is TRUE, UiApp signals the event. Event callback creates the Boot####. Otherwise, EfiBootManagerRefreshAllBootOptions() is called.

     *   Add a new PlatformBootManagerLib API (implemented by platform).

UiApp calls the new API instead of EfiBootManagerRefreshAllBootOption. (need to coordinate rollout with updates to all platforms).

     *   Add a new protocol (implemented by platform).

UiApp calls the new protocol if it exists otherwise calls EfiBootManagerRefreshAllBootOption.



  1.  Update EfiBootManagerRefreshAllBootOptions()
     *   Add a new library class (implemented by platform).

EfiBootManagerRefreshAllBootOption() calls the new library class.

     *   Add a new PlatformBootManager protocol (implemented by platform).

EfiBootManagerRefreshAllBootOption() calls the new protocol if it exists.

Thanks,
Ray

From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Wednesday, December 11, 2019 4:46 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com; discuss@edk2.groups.io
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Can we discuss this at the design meeting this week (12/12)?


Thanks,

Jeff

________________________________
From: Jeff Brasen
Sent: Thursday, November 14, 2019 10:04 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration


Yes, I think that would be good.



Summarizing everything in this thread



Problem: Platform needs to customize the boot options, this can be done for normal boot but the UiApp calls EfiBootManagerRefreshAllBootOption in a couple places.



Potential solutions:

1 - Define new PCD and event group if PCD is set true then signal event instead of calling EfiBootManagerRefreshAllBootOption in UiApp

2 - Add new function to boot manager library and replace call to EfiBootManagerRefreshAllBootOption in UiApp (need to coordinate rollout with updates to all platform.

3 - Add new protocol with new function, if supported call this otherwise call EfiBootManagerRefreshAllBootOption as is done now

4 - For 2/3 use  generic function so we don't need new APIs for future expansion

5 - Update EfiBootManagerRefreshAllBootOption to call platform specific function.



Thanks,
Jeff





From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Wednesday, November 13, 2019 7:09 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

I think it's a good topic that we could discuss in the open design meeting.

Are you ok to present the problem you have and discuss the potential solutions in that meeting?

https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Thursday, November 14, 2019 2:43 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.



We could change UiApp and BootManagerMenuApp (and any others that are relevant) from



EfiBootManagerRefreshAllBootOption ();



to



if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {

  EFI_EVENT Event;

  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );

  gBS->SignalEvent (Event);

  gBS->CloseEvent (Event);

} else {

  EfiBootManagerRefreshAllBootOption ();

}



Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.



Thanks,

Jeff

________________________________

From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.



Thanks,

Jeff

________________________________

From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >



[-- Attachment #2: Type: text/html, Size: 55117 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-12-11 14:00                                                             ` Ni, Ray
@ 2019-12-12 17:52                                                               ` Jeff Brasen
  2019-12-17 20:15                                                                 ` Ashish Singhal
  0 siblings, 1 reply; 49+ messages in thread
From: Jeff Brasen @ 2019-12-12 17:52 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io, Laszlo Ersek, afish@apple.com,
	discuss@edk2.groups.io
  Cc: Ashish Singhal, Wang, Jian J, Wu, Hao A, Gao, Zhichao,
	Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 29578 bytes --]

Thanks for the summary Ray, for the problem summary only thing I would add would be that platform also wants to create/modify boot options when full enumeration is requested as well.

For solutions I prefer option 2 as we don't have to put the same logic everywhere of how to modify the default enumerated list. And if we do that 2b makes more sense as then we don't have to modify all of the existing platforms.

I see two things the platform would need to do.

  1.  Update list created in BmEnumerateBootOptions
  2.  Delete any no longer valid platform created boot options


Thanks,

Jeff

________________________________
From: Ni, Ray <ray.ni@intel.com>
Sent: Wednesday, December 11, 2019 7:00 AM
To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>; discuss@edk2.groups.io <discuss@edk2.groups.io>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

External email: Use caution opening links or attachments


Jeff,

Tom from AMD booked the meeting for SEV discussion months ago. I am afraid there is no time for this discussion.

Let’s try to resolve it in mails.



Firstly, let me rephase the problem and your proposed solutions here (subjective + verb + objective). Sunny’s input is also included. Hope Mike K and others can provide inputs.

Personally, I agree with 2.b. It helps us to gradually migrate the PlatformBootManagerLib to PlatformBootManager protocol. Protocol with Revision field helps to reduce the impact to old platforms with new APIs added.



**Problem:

               Platform requires certain BlockIo/SimpleFileSystem/LoadFile instances don’t cause Boot#### created. It’s a need of platform customization.



**Details:

               Boot#### for BlockIo/SimpleFileSystem/LoadFile are created by API EfiBootMangerRefreshAllBootOptions(). There are 2 places that call this API:

  1.  Platform Boot Manager calls the API (usually in the full configuration boot path)
  2.  UiApp calls the API when entering “Boot Manager” page and “Boot Maintenance Manager” page.



Platform can change Platform Boot Manager to remove the unneeded Boot#### in case #1.

But platform has no way to remove the Boot#### created in case #2 .



**Potential solutions:

  1.  Update UiApp
     *   Define a new PCD and a new event group.

If PCD is TRUE, UiApp signals the event. Event callback creates the Boot####. Otherwise, EfiBootManagerRefreshAllBootOptions() is called.

     *   Add a new PlatformBootManagerLib API (implemented by platform).

UiApp calls the new API instead of EfiBootManagerRefreshAllBootOption. (need to coordinate rollout with updates to all platforms).

     *   Add a new protocol (implemented by platform).

UiApp calls the new protocol if it exists otherwise calls EfiBootManagerRefreshAllBootOption.



  1.  Update EfiBootManagerRefreshAllBootOptions()
     *   Add a new library class (implemented by platform).

EfiBootManagerRefreshAllBootOption() calls the new library class.

     *   Add a new PlatformBootManager protocol (implemented by platform).

EfiBootManagerRefreshAllBootOption() calls the new protocol if it exists.



Thanks,

Ray



From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Wednesday, December 11, 2019 4:46 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com; discuss@edk2.groups.io
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Can we discuss this at the design meeting this week (12/12)?



Thanks,

Jeff

________________________________

From: Jeff Brasen
Sent: Thursday, November 14, 2019 10:04 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Yes, I think that would be good.



Summarizing everything in this thread



Problem: Platform needs to customize the boot options, this can be done for normal boot but the UiApp calls EfiBootManagerRefreshAllBootOption in a couple places.



Potential solutions:

1 – Define new PCD and event group if PCD is set true then signal event instead of calling EfiBootManagerRefreshAllBootOption in UiApp

2 – Add new function to boot manager library and replace call to EfiBootManagerRefreshAllBootOption in UiApp (need to coordinate rollout with updates to all platform.

3 – Add new protocol with new function, if supported call this otherwise call EfiBootManagerRefreshAllBootOption as is done now

4 – For 2/3 use  generic function so we don’t need new APIs for future expansion

5 – Update EfiBootManagerRefreshAllBootOption to call platform specific function.



Thanks,
Jeff





From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Wednesday, November 13, 2019 7:09 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

I think it’s a good topic that we could discuss in the open design meeting.

Are you ok to present the problem you have and discuss the potential solutions in that meeting?

https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Thursday, November 14, 2019 2:43 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.



We could change UiApp and BootManagerMenuApp (and any others that are relevant) from



EfiBootManagerRefreshAllBootOption ();



to



if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {

  EFI_EVENT Event;

  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );

  gBS->SignalEvent (Event);

  gBS->CloseEvent (Event);

} else {

  EfiBootManagerRefreshAllBootOption ();

}



Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.



Thanks,

Jeff

________________________________

From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.



Thanks,

Jeff

________________________________

From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >



[-- Attachment #2: Type: text/html, Size: 51729 bytes --]

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

* Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-12-12 17:52                                                               ` Jeff Brasen
@ 2019-12-17 20:15                                                                 ` Ashish Singhal
  2019-12-18  3:54                                                                   ` [edk2-discuss] " Wang, Sunny (HPS SW)
  0 siblings, 1 reply; 49+ messages in thread
From: Ashish Singhal @ 2019-12-17 20:15 UTC (permalink / raw)
  To: Jeff Brasen, Ni, Ray, devel@edk2.groups.io, Laszlo Ersek,
	afish@apple.com, discuss@edk2.groups.io
  Cc: Wang, Jian J, Wu, Hao A, Gao, Zhichao, Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 30404 bytes --]

I have submitted a patch based on 2.b as suggested by Ray. I am open to making changes in the structure of the protocol functions as well as the verbal description. Please let me know what you all think about it.

Thanks
Ashish
________________________________
From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Thursday, December 12, 2019 10:52 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>; discuss@edk2.groups.io <discuss@edk2.groups.io>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Thanks for the summary Ray, for the problem summary only thing I would add would be that platform also wants to create/modify boot options when full enumeration is requested as well.

For solutions I prefer option 2 as we don't have to put the same logic everywhere of how to modify the default enumerated list. And if we do that 2b makes more sense as then we don't have to modify all of the existing platforms.

I see two things the platform would need to do.

  1.  Update list created in BmEnumerateBootOptions
  2.  Delete any no longer valid platform created boot options


Thanks,

Jeff

________________________________
From: Ni, Ray <ray.ni@intel.com>
Sent: Wednesday, December 11, 2019 7:00 AM
To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>; discuss@edk2.groups.io <discuss@edk2.groups.io>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

External email: Use caution opening links or attachments


Jeff,

Tom from AMD booked the meeting for SEV discussion months ago. I am afraid there is no time for this discussion.

Let’s try to resolve it in mails.



Firstly, let me rephase the problem and your proposed solutions here (subjective + verb + objective). Sunny’s input is also included. Hope Mike K and others can provide inputs.

Personally, I agree with 2.b. It helps us to gradually migrate the PlatformBootManagerLib to PlatformBootManager protocol. Protocol with Revision field helps to reduce the impact to old platforms with new APIs added.



**Problem:

               Platform requires certain BlockIo/SimpleFileSystem/LoadFile instances don’t cause Boot#### created. It’s a need of platform customization.



**Details:

               Boot#### for BlockIo/SimpleFileSystem/LoadFile are created by API EfiBootMangerRefreshAllBootOptions(). There are 2 places that call this API:

  1.  Platform Boot Manager calls the API (usually in the full configuration boot path)
  2.  UiApp calls the API when entering “Boot Manager” page and “Boot Maintenance Manager” page.



Platform can change Platform Boot Manager to remove the unneeded Boot#### in case #1.

But platform has no way to remove the Boot#### created in case #2 .



**Potential solutions:

  1.  Update UiApp
     *   Define a new PCD and a new event group.

If PCD is TRUE, UiApp signals the event. Event callback creates the Boot####. Otherwise, EfiBootManagerRefreshAllBootOptions() is called.

     *   Add a new PlatformBootManagerLib API (implemented by platform).

UiApp calls the new API instead of EfiBootManagerRefreshAllBootOption. (need to coordinate rollout with updates to all platforms).

     *   Add a new protocol (implemented by platform).

UiApp calls the new protocol if it exists otherwise calls EfiBootManagerRefreshAllBootOption.



  1.  Update EfiBootManagerRefreshAllBootOptions()
     *   Add a new library class (implemented by platform).

EfiBootManagerRefreshAllBootOption() calls the new library class.

     *   Add a new PlatformBootManager protocol (implemented by platform).

EfiBootManagerRefreshAllBootOption() calls the new protocol if it exists.



Thanks,

Ray



From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Wednesday, December 11, 2019 4:46 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com; discuss@edk2.groups.io
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Can we discuss this at the design meeting this week (12/12)?



Thanks,

Jeff

________________________________

From: Jeff Brasen
Sent: Thursday, November 14, 2019 10:04 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Yes, I think that would be good.



Summarizing everything in this thread



Problem: Platform needs to customize the boot options, this can be done for normal boot but the UiApp calls EfiBootManagerRefreshAllBootOption in a couple places.



Potential solutions:

1 – Define new PCD and event group if PCD is set true then signal event instead of calling EfiBootManagerRefreshAllBootOption in UiApp

2 – Add new function to boot manager library and replace call to EfiBootManagerRefreshAllBootOption in UiApp (need to coordinate rollout with updates to all platform.

3 – Add new protocol with new function, if supported call this otherwise call EfiBootManagerRefreshAllBootOption as is done now

4 – For 2/3 use  generic function so we don’t need new APIs for future expansion

5 – Update EfiBootManagerRefreshAllBootOption to call platform specific function.



Thanks,
Jeff





From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Wednesday, November 13, 2019 7:09 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

I think it’s a good topic that we could discuss in the open design meeting.

Are you ok to present the problem you have and discuss the potential solutions in that meeting?

https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Thursday, November 14, 2019 2:43 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.



We could change UiApp and BootManagerMenuApp (and any others that are relevant) from



EfiBootManagerRefreshAllBootOption ();



to



if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {

  EFI_EVENT Event;

  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );

  gBS->SignalEvent (Event);

  gBS->CloseEvent (Event);

} else {

  EfiBootManagerRefreshAllBootOption ();

}



Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.



Thanks,

Jeff

________________________________

From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.



Thanks,

Jeff

________________________________

From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the
system, unless (perhaps) PlatformBootManagerLib specifically thinks
otherwise.

Of course, then we arrive (again) at the problem that a call in
UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break
tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define)
the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for Android<https://aka.ms/ghei36>
>
> ________________________________
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>
> Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes happen. So it's not expected EfiBootManagerRefresh...() be
> called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailto:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.groups.io%3cmailto:devel@edk2.groups.io>>; jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3cmailto:lersek@redhat.com>>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang@intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.com%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao@intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
>
>                                     SimpleFileSystem Protocol, but not supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >



[-- Attachment #2: Type: text/html, Size: 53688 bytes --]

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

* Re: [edk2-discuss] [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-12-17 20:15                                                                 ` Ashish Singhal
@ 2019-12-18  3:54                                                                   ` Wang, Sunny (HPS SW)
  2019-12-18  8:43                                                                     ` Ni, Ray
  0 siblings, 1 reply; 49+ messages in thread
From: Wang, Sunny (HPS SW) @ 2019-12-18  3:54 UTC (permalink / raw)
  To: discuss@edk2.groups.io, ashishsingha@nvidia.com, Jeff Brasen,
	Ni, Ray, devel@edk2.groups.io, Laszlo Ersek, afish@apple.com
  Cc: Wang, Jian J, Wu, Hao A, Gao, Zhichao, Kinney, Michael D,
	Wang, Sunny (HPS SW)

Sorry for the delay. Somehow I didn't catch the follow-up email. Thanks for checking my comments, Ray and Ashish. 
Yeah, agree. 2.b is better. I will review the code change. 

Regards,
Sunny Wang

-----Original Message-----
From: discuss@edk2.groups.io [mailto:discuss@edk2.groups.io] On Behalf Of Ashish Singhal
Sent: Wednesday, December 18, 2019 4:16 AM
To: Jeff Brasen <jbrasen@nvidia.com>; Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com; discuss@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>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-discuss] [edk2-devel] [PATCH] Support skipping automatic BM enumeration

I have submitted a patch based on 2.b as suggested by Ray. I am open to making changes in the structure of the protocol functions as well as the verbal description. Please let me know what you all think about it.

Thanks
Ashish
________________________________
From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Thursday, December 12, 2019 10:52 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>; discuss@edk2.groups.io <discuss@edk2.groups.io>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

Thanks for the summary Ray, for the problem summary only thing I would add would be that platform also wants to create/modify boot options when full enumeration is requested as well.

For solutions I prefer option 2 as we don't have to put the same logic everywhere of how to modify the default enumerated list. And if we do that 2b makes more sense as then we don't have to modify all of the existing platforms.

I see two things the platform would need to do.

  1.  Update list created in BmEnumerateBootOptions
  2.  Delete any no longer valid platform created boot options


Thanks,

Jeff

________________________________
From: Ni, Ray <ray.ni@intel.com>
Sent: Wednesday, December 11, 2019 7:00 AM
To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>; afish@apple.com <afish@apple.com>; discuss@edk2.groups.io <discuss@edk2.groups.io>
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration

External email: Use caution opening links or attachments


Jeff,

Tom from AMD booked the meeting for SEV discussion months ago. I am afraid there is no time for this discussion.

Let's try to resolve it in mails.



Firstly, let me rephase the problem and your proposed solutions here (subjective + verb + objective). Sunny's input is also included. Hope Mike K and others can provide inputs.

Personally, I agree with 2.b. It helps us to gradually migrate the PlatformBootManagerLib to PlatformBootManager protocol. Protocol with Revision field helps to reduce the impact to old platforms with new APIs added.



**Problem:

               Platform requires certain BlockIo/SimpleFileSystem/LoadFile instances don't cause Boot#### created. It's a need of platform customization.



**Details:

               Boot#### for BlockIo/SimpleFileSystem/LoadFile are created by API EfiBootMangerRefreshAllBootOptions(). There are 2 places that call this API:

  1.  Platform Boot Manager calls the API (usually in the full configuration boot path)
  2.  UiApp calls the API when entering "Boot Manager" page and "Boot Maintenance Manager" page.



Platform can change Platform Boot Manager to remove the unneeded Boot#### in case #1.

But platform has no way to remove the Boot#### created in case #2 .



**Potential solutions:

  1.  Update UiApp
     *   Define a new PCD and a new event group.

If PCD is TRUE, UiApp signals the event. Event callback creates the Boot####. Otherwise, EfiBootManagerRefreshAllBootOptions() is called.

     *   Add a new PlatformBootManagerLib API (implemented by platform).

UiApp calls the new API instead of EfiBootManagerRefreshAllBootOption. (need to coordinate rollout with updates to all platforms).

     *   Add a new protocol (implemented by platform).

UiApp calls the new protocol if it exists otherwise calls EfiBootManagerRefreshAllBootOption.



  1.  Update EfiBootManagerRefreshAllBootOptions()
     *   Add a new library class (implemented by platform).

EfiBootManagerRefreshAllBootOption() calls the new library class.

     *   Add a new PlatformBootManager protocol (implemented by platform).

EfiBootManagerRefreshAllBootOption() calls the new protocol if it exists.



Thanks,

Ray



From: Jeff Brasen <jbrasen@nvidia.com>
Sent: Wednesday, December 11, 2019 4:46 AM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com; discuss@edk2.groups.io
Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Can we discuss this at the design meeting this week (12/12)?



Thanks,

Jeff

________________________________

From: Jeff Brasen
Sent: Thursday, November 14, 2019 10:04 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Yes, I think that would be good.



Summarizing everything in this thread



Problem: Platform needs to customize the boot options, this can be done for normal boot but the UiApp calls EfiBootManagerRefreshAllBootOption in a couple places.



Potential solutions:

1 - Define new PCD and event group if PCD is set true then signal event instead of calling EfiBootManagerRefreshAllBootOption in UiApp

2 - Add new function to boot manager library and replace call to EfiBootManagerRefreshAllBootOption in UiApp (need to coordinate rollout with updates to all platform.

3 - Add new protocol with new function, if supported call this otherwise call EfiBootManagerRefreshAllBootOption as is done now

4 - For 2/3 use  generic function so we don't need new APIs for future expansion

5 - Update EfiBootManagerRefreshAllBootOption to call platform specific function.



Thanks,
Jeff





From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Wednesday, November 13, 2019 7:09 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

I think it's a good topic that we could discuss in the open design meeting.

Are you ok to present the problem you have and discuss the potential solutions in that meeting?

https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Thursday, November 14, 2019 2:43 AM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Thinking about this more I think we could do this with a PCD and a new group event without having to define any new function interfaces.



We could change UiApp and BootManagerMenuApp (and any others that are relevant) from



EfiBootManagerRefreshAllBootOption ();



to



if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {

  EFI_EVENT Event;

  gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );

  gBS->SignalEvent (Event);

  gBS->CloseEvent (Event);

} else {

  EfiBootManagerRefreshAllBootOption ();

}



Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to do there.



Thanks,

Jeff

________________________________

From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Sent: Monday, November 11, 2019 5:00 PM
To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in UiApp but we need the platform code to be involved in that process.



Thanks,

Jeff

________________________________

From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Sent: Monday, November 11, 2019 4:58 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



Jeff,

If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to PlatformBootManagerLib.



Thanks,

Ray



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Jeff Brasen
Sent: Tuesday, November 12, 2019 6:58 AM
To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol, so this might not be the cleanest way to deploy this.



We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted to limit the number of disruption on new customization hooks. Something like



EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)



Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior in place for unsupported types as well as being a less than specific function to describe.



Thanks,

Jeff



________________________________

From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
Sent: Friday, November 8, 2019 9:37 AM
To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration



On 11/07/19 18:46, Jeff Brasen wrote:
> Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that occurs.

Fully agreed -- entering UiApp should expose everything bootable in the system, unless (perhaps) PlatformBootManagerLib specifically thinks otherwise.

Of course, then we arrive (again) at the problem that a call in UefiBootManagerLib, to a *new* PlatformBootManagerLib API, will break tens of out-of-tree platforms. :)

I think that can be prevented, as follows; but it will take quite some time:

- introduce the new function declaration in "PlatformBootManagerLib.h",
- modify all platforms (in tree and out of tree) to implement (define) the new function,
- call the new function from UefiBootManagerLib

For some history / background on this kind of problem, I suggest reading
through:

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

Thanks,
Laszlo

> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Thursday, November 7, 2019 12:21 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen 
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; 
> afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo 
> Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael 
> D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
> I treat the issue in this way:
>
>   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot options
>   2.  But UiApp doesn't. It constantly call RefreshAll().
>
> Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
>
> Thanks,
> Ray
>
> From: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>> 
> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gr
> oups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> Sent: Thursday, November 7, 2019 3:02 PM
> To: Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> Cc: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
> The issue is there are some auto created options we do not want on our platform.
> Get Outlook for 
> Android<INVALID URI REMOVED
> ei36&d=DwIF-g&c=C5b8zRQO1miGmBeVZ2LFWg&r=Z9cLgEMdGZCI1_R0bW6KqOAGzCXLJ
> UR24f8N3205AYw&m=EzQH7xR5u0kejdb3Oa18jqGGrV5AO_ROvd_Y_ajQQMk&s=yaH1ZcO
> LL9iVBCGMBGKtuwgPVbblPxtJooJMnpxn8P0&e= >
>
> ________________________________
> From: Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>
> Sent: Wednesday, November 6, 2019 11:59:31 PM
> To: Jeff Brasen 
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> m%3cmailto:jbrasen@nvidia.com>>>; 
> afish@apple.com<mailto:afish@apple.com> 
> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> o:afish@apple.com>>>
> Cc: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>> 
> <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gr
> oups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
>
> Jeff,
>
> RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot option list (through BootOrder).
>
>
>
> From: Jeff Brasen 
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> m%3cmailto:jbrasen@nvidia.com>>>
> Sent: Thursday, November 7, 2019 12:13 PM
> To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>
> Cc: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
>
>
> As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options with no place for the platform code to intervene.
>
>
>
> What about a solution where we add a new Platform library function that allows for override of the behavior of BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that would modify the load option array after the system does the standard enumeration.
>
>
>
> -Jeff
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> 
> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> o:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 9:20 AM
> To: Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>
> Cc: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen 
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> m%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
>
>
> Ray,
>
>
>
> Is there an obvious hook point we could point Jeff and Ashish at?
>
>
>
> Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> On Nov 5, 2019, at 9:20 PM, Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
>
>
>
> Andrew,
>
> I agree with your opinion.
>
> It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot path.
>
> The full configuration boot path is chosen when hardware changes 
> happen. So it's not expected EfiBootManagerRefresh...() be called in every boot.
>
> So you could:
>
>   1.  Delete the auto-created option pointing to LoadFile instance
>   2.  Create your own one with customized description.
>
>
>
>
>
> From: afish@apple.com<mailto:afish@apple.com> 
> <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> o:afish@apple.com>>>
> Sent: Wednesday, November 6, 2019 10:47 AM
> To: 
> devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> ups.io%3cmailto:devel@edk2.groups.io>>; 
> jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> Cc: Ashish Singhal 
> <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek 
> <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> cmailto:lersek@redhat.com>>>; Ni, Ray 
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> ilto:ray.ni@intel.com>>>; Wang, Jian J 
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A 
> <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao 
> <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D 
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM 
> enumeration
>
>
>
>
>
>
>
> On Nov 5, 2019, at 7:34 PM, Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
>
>
>
> Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the variable store lives on?
> What about the alternative approach where we allow the platform code to modify the attributes of the auto created variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing logic in the boot manager can stay basically the same?
>
> What changes every boot that forces the variable to need to get modified?
>
> I would assume the NOR driver is smart enough to not update a variable that is not changing.
>
> The custom BDS could could only create the variable for this device if it does not exist.
>
> [JB] The current flow with no changes in the boot manager would be as 
> follows
>
>
>
>   1.  Scan for instance of the boot option in the variables
>   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
>   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
>   4.  Delete/disable the boot option in the variable store
>
>
>
> When you reboot it won't find the variable so 1/2/4 will re-occur
>
>
>
> The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in 
> BmBoot.c
>
>
>
> If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the code wouldn't recognize that is the same boot option.
>
>
>
> If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in the store and thus we wouldn't have changes every boot.
>
>
>
>
>
> Jeff,
>
>
>
> Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
>
>
>
> I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to run if you have a valid EFI nvram variable to boot from.
>
>
>
> I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the same way then the answer is to have the BDS platform specific code write the boot variable.
>
>
>
>
>
> [1]
>
> /**
>
>   The function creates boot options for all possible bootable medias in the following order:
>
>   1. Removable BlockIo            - The boot option only points to the removable media
>
>                                     device, like USB key, DVD, Floppy etc.
>
>   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
>
>                                     like HardDisk.
>
>   3. Non-BlockIo SimpleFileSystem - The boot option points to a device 
> supporting
>
>                                     SimpleFileSystem Protocol, but not 
> supporting BlockIo
>
>                                     protocol.
>
>   4. LoadFile                     - The boot option points to the media supporting
>
>                                     LoadFile protocol.
>
>   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot 
> Behavior
>
>
>
>   The function won't delete the boot option not added by itself.
>
> **/
>
> VOID
>
> EFIAPI
>
> EfiBootManagerRefreshAllBootOption (
>
>   VOID
>
>   );
>
>
>
> Thanks,
>
>
>
> Andrew Fish
>
>
>
> Thanks,
>
> Andrew Fish
>
> Thanks,
>
> Jeff
>
> ________________________________
>
> This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
> ________________________________
>
> >






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

* Re: [edk2-discuss] [edk2-devel] [PATCH] Support skipping automatic BM enumeration
  2019-12-18  3:54                                                                   ` [edk2-discuss] " Wang, Sunny (HPS SW)
@ 2019-12-18  8:43                                                                     ` Ni, Ray
  0 siblings, 0 replies; 49+ messages in thread
From: Ni, Ray @ 2019-12-18  8:43 UTC (permalink / raw)
  To: Wang, Sunny (HPS SW), discuss@edk2.groups.io,
	ashishsingha@nvidia.com, Jeff Brasen, devel@edk2.groups.io,
	Laszlo Ersek, afish@apple.com
  Cc: Wang, Jian J, Wu, Hao A, Gao, Zhichao, Kinney, Michael D

Sunny,
Thanks for your comments.

Thanks,
Ray

> -----Original Message-----
> From: Wang, Sunny (HPS SW) <sunnywang@hpe.com>
> Sent: Wednesday, December 18, 2019 11:54 AM
> To: discuss@edk2.groups.io; ashishsingha@nvidia.com; Jeff Brasen <jbrasen@nvidia.com>; Ni, Ray <ray.ni@intel.com>;
> devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>;
> Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Sunny (HPS SW) <sunnywang@hpe.com>
> Subject: RE: [edk2-discuss] [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> Sorry for the delay. Somehow I didn't catch the follow-up email. Thanks for checking my comments, Ray and Ashish.
> Yeah, agree. 2.b is better. I will review the code change.
> 
> Regards,
> Sunny Wang
> 
> -----Original Message-----
> From: discuss@edk2.groups.io [mailto:discuss@edk2.groups.io] On Behalf Of Ashish Singhal
> Sent: Wednesday, December 18, 2019 4:16 AM
> To: Jeff Brasen <jbrasen@nvidia.com>; Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek
> <lersek@redhat.com>; afish@apple.com; discuss@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>;
> Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-discuss] [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> I have submitted a patch based on 2.b as suggested by Ray. I am open to making changes in the structure of the protocol
> functions as well as the verbal description. Please let me know what you all think about it.
> 
> Thanks
> Ashish
> ________________________________
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Thursday, December 12, 2019 10:52 AM
> To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>;
> afish@apple.com <afish@apple.com>; discuss@edk2.groups.io <discuss@edk2.groups.io>
> Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> Thanks for the summary Ray, for the problem summary only thing I would add would be that platform also wants to
> create/modify boot options when full enumeration is requested as well.
> 
> For solutions I prefer option 2 as we don't have to put the same logic everywhere of how to modify the default
> enumerated list. And if we do that 2b makes more sense as then we don't have to modify all of the existing platforms.
> 
> I see two things the platform would need to do.
> 
>   1.  Update list created in BmEnumerateBootOptions
>   2.  Delete any no longer valid platform created boot options
> 
> 
> Thanks,
> 
> Jeff
> 
> ________________________________
> From: Ni, Ray <ray.ni@intel.com>
> Sent: Wednesday, December 11, 2019 7:00 AM
> To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>;
> afish@apple.com <afish@apple.com>; discuss@edk2.groups.io <discuss@edk2.groups.io>
> Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> External email: Use caution opening links or attachments
> 
> 
> Jeff,
> 
> Tom from AMD booked the meeting for SEV discussion months ago. I am afraid there is no time for this discussion.
> 
> Let's try to resolve it in mails.
> 
> 
> 
> Firstly, let me rephase the problem and your proposed solutions here (subjective + verb + objective). Sunny's input is also
> included. Hope Mike K and others can provide inputs.
> 
> Personally, I agree with 2.b. It helps us to gradually migrate the PlatformBootManagerLib to PlatformBootManager
> protocol. Protocol with Revision field helps to reduce the impact to old platforms with new APIs added.
> 
> 
> 
> **Problem:
> 
>                Platform requires certain BlockIo/SimpleFileSystem/LoadFile instances don't cause Boot#### created. It's a need
> of platform customization.
> 
> 
> 
> **Details:
> 
>                Boot#### for BlockIo/SimpleFileSystem/LoadFile are created by API EfiBootMangerRefreshAllBootOptions(). There
> are 2 places that call this API:
> 
>   1.  Platform Boot Manager calls the API (usually in the full configuration boot path)
>   2.  UiApp calls the API when entering "Boot Manager" page and "Boot Maintenance Manager" page.
> 
> 
> 
> Platform can change Platform Boot Manager to remove the unneeded Boot#### in case #1.
> 
> But platform has no way to remove the Boot#### created in case #2 .
> 
> 
> 
> **Potential solutions:
> 
>   1.  Update UiApp
>      *   Define a new PCD and a new event group.
> 
> If PCD is TRUE, UiApp signals the event. Event callback creates the Boot####. Otherwise,
> EfiBootManagerRefreshAllBootOptions() is called.
> 
>      *   Add a new PlatformBootManagerLib API (implemented by platform).
> 
> UiApp calls the new API instead of EfiBootManagerRefreshAllBootOption. (need to coordinate rollout with updates to all
> platforms).
> 
>      *   Add a new protocol (implemented by platform).
> 
> UiApp calls the new protocol if it exists otherwise calls EfiBootManagerRefreshAllBootOption.
> 
> 
> 
>   1.  Update EfiBootManagerRefreshAllBootOptions()
>      *   Add a new library class (implemented by platform).
> 
> EfiBootManagerRefreshAllBootOption() calls the new library class.
> 
>      *   Add a new PlatformBootManager protocol (implemented by platform).
> 
> EfiBootManagerRefreshAllBootOption() calls the new protocol if it exists.
> 
> 
> 
> Thanks,
> 
> Ray
> 
> 
> 
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Wednesday, December 11, 2019 4:46 AM
> To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; afish@apple.com;
> discuss@edk2.groups.io
> Cc: Ashish Singhal <ashishsingha@nvidia.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Gao, Zhichao <zhichao.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> Can we discuss this at the design meeting this week (12/12)?
> 
> 
> 
> Thanks,
> 
> Jeff
> 
> ________________________________
> 
> From: Jeff Brasen
> Sent: Thursday, November 14, 2019 10:04 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>
> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>;
> afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>;
> Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> Yes, I think that would be good.
> 
> 
> 
> Summarizing everything in this thread
> 
> 
> 
> Problem: Platform needs to customize the boot options, this can be done for normal boot but the UiApp calls
> EfiBootManagerRefreshAllBootOption in a couple places.
> 
> 
> 
> Potential solutions:
> 
> 1 - Define new PCD and event group if PCD is set true then signal event instead of calling
> EfiBootManagerRefreshAllBootOption in UiApp
> 
> 2 - Add new function to boot manager library and replace call to EfiBootManagerRefreshAllBootOption in UiApp (need to
> coordinate rollout with updates to all platform.
> 
> 3 - Add new protocol with new function, if supported call this otherwise call EfiBootManagerRefreshAllBootOption as is
> done now
> 
> 4 - For 2/3 use  generic function so we don't need new APIs for future expansion
> 
> 5 - Update EfiBootManagerRefreshAllBootOption to call platform specific function.
> 
> 
> 
> Thanks,
> Jeff
> 
> 
> 
> 
> 
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Wednesday, November 13, 2019 7:09 PM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>;
> Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>;
> Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> Jeff,
> 
> I think it's a good topic that we could discuss in the open design meeting.
> 
> Are you ok to present the problem you have and discuss the potential solutions in that meeting?
> 
> https://github.com/tianocore/tianocore.github.io/wiki/Design-Meeting
> 
> 
> 
> Thanks,
> 
> Ray
> 
> 
> 
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On
> Behalf Of Jeff Brasen
> Sent: Thursday, November 14, 2019 2:43 AM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Laszlo
> Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>;
> Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> Thinking about this more I think we could do this with a PCD and a new group event without having to define any new
> function interfaces.
> 
> 
> 
> We could change UiApp and BootManagerMenuApp (and any others that are relevant) from
> 
> 
> 
> EfiBootManagerRefreshAllBootOption ();
> 
> 
> 
> to
> 
> 
> 
> if (FeaturePcdGet (PcdEventBasedRefreshAllBootOptionSupport) {
> 
>   EFI_EVENT Event;
> 
>   gBS->CreateEventEx ( 0, 0, NULL, NULL, &gEventBasedRefreshGuid, &Event );
> 
>   gBS->SignalEvent (Event);
> 
>   gBS->CloseEvent (Event);
> 
> } else {
> 
>   EfiBootManagerRefreshAllBootOption ();
> 
> }
> 
> 
> 
> Then a platform that wants to do this on its own would just set this pcd and create a group event and do what it needs to
> do there.
> 
> 
> 
> Thanks,
> 
> Jeff
> 
> ________________________________
> 
> From: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
> Sent: Monday, November 11, 2019 5:00 PM
> To: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>
> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>;
> afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>;
> Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> I am not sure a PCD would work (unless I am missing something) We do want to do a connect all and re-enumerate in
> UiApp but we need the platform code to be involved in that process.
> 
> 
> 
> Thanks,
> 
> Jeff
> 
> ________________________________
> 
> From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> Sent: Monday, November 11, 2019 4:58 PM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Jeff
> Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Laszlo Ersek
> <lersek@redhat.com<mailto:lersek@redhat.com>>; afish@apple.com<mailto:afish@apple.com>
> <afish@apple.com<mailto:afish@apple.com>>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>;
> Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> Jeff,
> 
> If adding a PCD to control UiApp can meet the real needs, I prefer to do in that way instead of adding new APIs to
> PlatformBootManagerLib.
> 
> 
> 
> Thanks,
> 
> Ray
> 
> 
> 
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On
> Behalf Of Jeff Brasen
> Sent: Tuesday, November 12, 2019 6:58 AM
> To: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>;
> devel@edk2.groups.io<mailto:devel@edk2.groups.io>; afish@apple.com<mailto:afish@apple.com>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>;
> Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> If we are concerned about deploying this and breaking builds we could do this via a new protocol instead. In that case
> though we would leave the old default behavior in the code to handle platforms that didn't implement the new protocol,
> so this might not be the cleanest way to deploy this.
> 
> 
> 
> We could also look at adding a generic platform boot hook function (either as a library function or protocol) if we wanted
> to limit the number of disruption on new customization hooks. Something like
> 
> 
> 
> EFI_STATUS PlatformBootNotify (CONST EFI_GUID *NotificationType, VOID *ContextData OPTIONAL)
> 
> 
> 
> Where Notification type describes where we are that we want platform to potentially handle and ContextData is per type
> caller allocated data that provides additional in/out data. This has the same issue of leaving the current default behavior
> in place for unsupported types as well as being a less than specific function to describe.
> 
> 
> 
> Thanks,
> 
> Jeff
> 
> 
> 
> ________________________________
> 
> From: Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>
> Sent: Friday, November 8, 2019 9:37 AM
> To: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>;
> devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>;
> afish@apple.com<mailto:afish@apple.com> <afish@apple.com<mailto:afish@apple.com>>
> Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Wang, Jian J
> <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>;
> Gao, Zhichao <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael D
> <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM enumeration
> 
> 
> 
> On 11/07/19 18:46, Jeff Brasen wrote:
> > Fixing UiApp seems reasonable, I do think we would want a hook to the platform library in here as the enumeration that
> occurs in the UiApp is intended to do a full enumeration of the system and there may be platform specifics to how that
> occurs.
> 
> Fully agreed -- entering UiApp should expose everything bootable in the system, unless (perhaps) PlatformBootManagerLib
> specifically thinks otherwise.
> 
> Of course, then we arrive (again) at the problem that a call in UefiBootManagerLib, to a *new* PlatformBootManagerLib
> API, will break tens of out-of-tree platforms. :)
> 
> I think that can be prevented, as follows; but it will take quite some time:
> 
> - introduce the new function declaration in "PlatformBootManagerLib.h",
> - modify all platforms (in tree and out of tree) to implement (define) the new function,
> - call the new function from UefiBootManagerLib
> 
> For some history / background on this kind of problem, I suggest reading
> through:
> 
>   https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.tianocore.org_show-5Fbug.cgi-3Fid-3D982&d=DwIF-
> g&c=C5b8zRQO1miGmBeVZ2LFWg&r=Z9cLgEMdGZCI1_R0bW6KqOAGzCXLJUR24f8N3205AYw&m=EzQH7xR5u0kejdb3Oa18jq
> GGrV5AO_ROvd_Y_ajQQMk&s=cTZCJVE04A0qq4imb3Pma8jdJIrunDornyDXBty-1Uk&e=
> 
> Thanks,
> Laszlo
> 
> > From: Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
> > Sent: Thursday, November 7, 2019 12:21 AM
> > To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Jeff Brasen
> > <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>;
> > afish@apple.com<mailto:afish@apple.com>
> > Cc: Ashish Singhal
> > <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>; Laszlo
> > Ersek <lersek@redhat.com<mailto:lersek@redhat.com>>; Wang, Jian J
> > <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>>; Wu, Hao A
> > <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com>>; Gao, Zhichao
> > <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com>>; Kinney, Michael
> > D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
> > Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM
> > enumeration
> >
> > I treat the issue in this way:
> >
> >   1.  Platform Boot Manager library does a good job. It doesn't always call RefreshAll() API to auto-create the boot
> options
> >   2.  But UiApp doesn't. It constantly call RefreshAll().
> >
> > Do you think that we can fix UiApp instead? For example, introducing a PCD to control the boot option refresh behavior?
> >
> > Thanks,
> > Ray
> >
> > From:
> > devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> > ups.io%3cmailto:devel@edk2.groups.io>>
> > <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gr
> > oups.io%3cmailto:devel@edk2.groups.io>>> On Behalf Of Jeff Brasen
> > Sent: Thursday, November 7, 2019 3:02 PM
> > To: Ni, Ray
> > <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> > ilto:ray.ni@intel.com>>>; afish@apple.com<mailto:afish@apple.com>
> > Cc:
> > devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> > ups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal
> > <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> > ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek
> > <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> > cmailto:lersek@redhat.com>>>; Wang, Jian J
> > <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> > @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A
> > <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> > m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao
> > <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> > @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D
> > <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> > ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> > Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM
> > enumeration
> >
> > The issue is there are some auto created options we do not want on our platform.
> > Get Outlook for
> > Android<https://urldefense.proofpoint.com/v2/url?u=https-3A__aka.ms_gh
> > ei36&d=DwIF-g&c=C5b8zRQO1miGmBeVZ2LFWg&r=Z9cLgEMdGZCI1_R0bW6KqOAGzCXLJ
> > UR24f8N3205AYw&m=EzQH7xR5u0kejdb3Oa18jqGGrV5AO_ROvd_Y_ajQQMk&s=yaH1ZcO
> > LL9iVBCGMBGKtuwgPVbblPxtJooJMnpxn8P0&e= >
> >
> > ________________________________
> > From: Ni, Ray
> > <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> > ilto:ray.ni@intel.com>>>
> > Sent: Wednesday, November 6, 2019 11:59:31 PM
> > To: Jeff Brasen
> > <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> > m%3cmailto:jbrasen@nvidia.com>>>;
> > afish@apple.com<mailto:afish@apple.com>
> > <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> > o:afish@apple.com>>>
> > Cc:
> > devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> > ups.io%3cmailto:devel@edk2.groups.io>>
> > <devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gr
> > oups.io%3cmailto:devel@edk2.groups.io>>>; Ashish Singhal
> > <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> > ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek
> > <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> > cmailto:lersek@redhat.com>>>; Wang, Jian J
> > <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> > @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A
> > <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> > m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao
> > <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> > @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D
> > <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> > ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> > Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM
> > enumeration
> >
> >
> > Jeff,
> >
> > RefreshAllBootOption() only modifies/creates the auto-created boot options. For the boot options created by platform
> boot manager library, they stay with no one touches. And all auto-created boot options are appended in the end of boot
> option list (through BootOrder).
> >
> >
> >
> > From: Jeff Brasen
> > <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> > m%3cmailto:jbrasen@nvidia.com>>>
> > Sent: Thursday, November 7, 2019 12:13 PM
> > To: afish@apple.com<mailto:afish@apple.com>; Ni, Ray
> > <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> > ilto:ray.ni@intel.com>>>
> > Cc:
> > devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> > ups.io%3cmailto:devel@edk2.groups.io>>; Ashish Singhal
> > <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> > ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek
> > <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> > cmailto:lersek@redhat.com>>>; Wang, Jian J
> > <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> > @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A
> > <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> > m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao
> > <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> > @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D
> > <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> > ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> > Subject: RE: [edk2-devel] [PATCH] Support skipping automatic BM
> > enumeration
> >
> >
> >
> > As the suggestions below made sense, we updated our platform boot manager library to behave in this manner and for
> normal boots everything works well. However the UiApp and boot maintenance applications in EDK2 also call
> EfiBootManagerRefreshAllBootOption() when ever a user goes into the menu which will re-create the skipped boot options
> with no place for the platform code to intervene.
> >
> >
> >
> > What about a solution where we add a new Platform library function that allows for override of the behavior of
> BmEnumerateBootOptions? For example, either a function or protocol that takes the same parameters as this function
> and only if it returns NULL then we continue to the default enumeration code.  Or a function call inserted at the end that
> would modify the load option array after the system does the standard enumeration.
> >
> >
> >
> > -Jeff
> >
> >
> >
> > From: afish@apple.com<mailto:afish@apple.com>
> > <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> > o:afish@apple.com>>>
> > Sent: Wednesday, November 6, 2019 9:20 AM
> > To: Ni, Ray
> > <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> > ilto:ray.ni@intel.com>>>
> > Cc:
> > devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> > ups.io%3cmailto:devel@edk2.groups.io>>; Jeff Brasen
> > <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.co
> > m%3cmailto:jbrasen@nvidia.com>>>; Ashish Singhal
> > <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> > ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek
> > <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> > cmailto:lersek@redhat.com>>>; Wang, Jian J
> > <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> > @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A
> > <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> > m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao
> > <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> > @intel.com%3cmailto:zhichao.gao@intel.com>>>; Mike Kinney
> > <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> > ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> > Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM
> > enumeration
> >
> >
> >
> > Ray,
> >
> >
> >
> > Is there an obvious hook point we could point Jeff and Ashish at?
> >
> >
> >
> > Long term it would be a good idea to have a Wiki page to give some guidance on how to customize the BDS.
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Andrew Fish
> >
> >
> >
> > On Nov 5, 2019, at 9:20 PM, Ni, Ray
> <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cmailto:ray.ni@intel.com>>> wrote:
> >
> >
> >
> > Andrew,
> >
> > I agree with your opinion.
> >
> > It's expected that Platform Boot Manager lib calls EfiBootManagerRefreshAllBootOption() only in full configuration boot
> path.
> >
> > The full configuration boot path is chosen when hardware changes
> > happen. So it's not expected EfiBootManagerRefresh...() be called in every boot.
> >
> > So you could:
> >
> >   1.  Delete the auto-created option pointing to LoadFile instance
> >   2.  Create your own one with customized description.
> >
> >
> >
> >
> >
> > From: afish@apple.com<mailto:afish@apple.com>
> > <afish@apple.com<mailto:afish@apple.com<mailto:afish@apple.com%3cmailt
> > o:afish@apple.com>>>
> > Sent: Wednesday, November 6, 2019 10:47 AM
> > To:
> > devel@edk2.groups.io<mailto:devel@edk2.groups.io<mailto:devel@edk2.gro
> > ups.io%3cmailto:devel@edk2.groups.io>>;
> > jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>
> > Cc: Ashish Singhal
> > <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com<mailto:ashishs
> > ingha@nvidia.com%3cmailto:ashishsingha@nvidia.com>>>; Laszlo Ersek
> > <lersek@redhat.com<mailto:lersek@redhat.com<mailto:lersek@redhat.com%3
> > cmailto:lersek@redhat.com>>>; Ni, Ray
> > <ray.ni@intel.com<mailto:ray.ni@intel.com<mailto:ray.ni@intel.com%3cma
> > ilto:ray.ni@intel.com>>>; Wang, Jian J
> > <jian.j.wang@intel.com<mailto:jian.j.wang@intel.com<mailto:jian.j.wang
> > @intel.com%3cmailto:jian.j.wang@intel.com>>>; Wu, Hao A
> > <hao.a.wu@intel.com<mailto:hao.a.wu@intel.com<mailto:hao.a.wu@intel.co
> > m%3cmailto:hao.a.wu@intel.com>>>; Gao, Zhichao
> > <zhichao.gao@intel.com<mailto:zhichao.gao@intel.com<mailto:zhichao.gao
> > @intel.com%3cmailto:zhichao.gao@intel.com>>>; Kinney, Michael D
> > <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com<mailto:m
> > ichael.d.kinney@intel.com%3cmailto:michael.d.kinney@intel.com>>>
> > Subject: Re: [edk2-devel] [PATCH] Support skipping automatic BM
> > enumeration
> >
> >
> >
> >
> >
> >
> >
> > On Nov 5, 2019, at 7:34 PM, Jeff Brasen
> <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com<mailto:jbrasen@nvidia.com%3cmailto:jbrasen@nvidia.com>>> wrote:
> >
> >
> >
> > Wouldn't having a variable that we create and delete on every boot put unnecessary stress on the SPI-NOR that the
> variable store lives on?
> > What about the alternative approach where we allow the platform code to modify the attributes of the auto created
> variable to disable it with hidden/!active but still match for detection purposes so that it doesn't delete and recreate the
> modified variable each boot? That way all the logic on what to disable can still be in the platform code and all the existing
> logic in the boot manager can stay basically the same?
> >
> > What changes every boot that forces the variable to need to get modified?
> >
> > I would assume the NOR driver is smart enough to not update a variable that is not changing.
> >
> > The custom BDS could could only create the variable for this device if it does not exist.
> >
> > [JB] The current flow with no changes in the boot manager would be as
> > follows
> >
> >
> >
> >   1.  Scan for instance of the boot option in the variables
> >   2.  It will not be found, so create a new boot option store it to a variable and update BootOrder
> >   3.  Platform code runs creates the options for the boot option it wants and writes those to variable store
> >   4.  Delete/disable the boot option in the variable store
> >
> >
> >
> > When you reboot it won't find the variable so 1/2/4 will re-occur
> >
> >
> >
> > The code that does this (1/2) is EfiBootManagerRefreshAllBootOption in
> > BmBoot.c
> >
> >
> >
> > If you modify the variable to disable it with hidden/not active it would delete that and create a new one as well as the
> code wouldn't recognize that is the same boot option.
> >
> >
> >
> > If however we modify EfiBootManagerFindLoadOption to not compare the attributes (at least allow for differences in
> active and hidden) then the when it refreshes every thing it would see the match and not delete/create a new variable in
> the store and thus we wouldn't have changes every boot.
> >
> >
> >
> >
> >
> > Jeff,
> >
> >
> >
> > Sorry if I'm a little off on the sequence of things as the platform I work on day to day has a custom BDS and does not use
> this library..... I though the patch changed BmEnumerateBootOptions(), so that is going to change how
> EfiBootManagerRefreshAllBootOption() works. I'd also point out the patch as given is invalid as it changed the behavior of
> the public library API for EfiBootManagerRefreshAllBootOption() [1] so for the patch to be valid it would need to change
> the comments to reflect the new behavior. This is kind of what Laszlo's technical debt comment was about.
> >
> >
> >
> > I think Laszlo advocated having the BDS platform specific code make sure the boot variables are in the correct state. That
> should happen before the Boot Manager code runs, and it is  not clear to me why the Boot Manager could would need to
> run if you have a valid EFI nvram variable to boot from.
> >
> >
> >
> > I think the question is how is your use case different than the boot variable that Windows installs? If it works kind of the
> same way then the answer is to have the BDS platform specific code write the boot variable.
> >
> >
> >
> >
> >
> > [1]
> >
> > /**
> >
> >   The function creates boot options for all possible bootable medias in the following order:
> >
> >   1. Removable BlockIo            - The boot option only points to the removable media
> >
> >                                     device, like USB key, DVD, Floppy etc.
> >
> >   2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
> >
> >                                     like HardDisk.
> >
> >   3. Non-BlockIo SimpleFileSystem - The boot option points to a device
> > supporting
> >
> >                                     SimpleFileSystem Protocol, but not
> > supporting BlockIo
> >
> >                                     protocol.
> >
> >   4. LoadFile                     - The boot option points to the media supporting
> >
> >                                     LoadFile protocol.
> >
> >   Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot
> > Behavior
> >
> >
> >
> >   The function won't delete the boot option not added by itself.
> >
> > **/
> >
> > VOID
> >
> > EFIAPI
> >
> > EfiBootManagerRefreshAllBootOption (
> >
> >   VOID
> >
> >   );
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Andrew Fish
> >
> >
> >
> > Thanks,
> >
> > Andrew Fish
> >
> > Thanks,
> >
> > Jeff
> >
> > ________________________________
> >
> > This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any
> unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the
> sender by reply email and destroy all copies of the original message.
> >
> > ________________________________
> >
> > >
> 
> 
> 
> 
> 


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

end of thread, other threads:[~2019-12-18  8:43 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-30  3:47 [PATCH] Support skipping automatic BM enumeration Ashish Singhal
2019-10-30  3:47 ` [PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping " Ashish Singhal
2019-10-31 10:14 ` [edk2-devel] [PATCH] Support skipping automatic " Laszlo Ersek
     [not found]   ` <DM6PR12MB33249A87560B32B0155D4FE0BA630@DM6PR12MB3324.namprd12.prod.outlook.com>
2019-11-01 21:42     ` Laszlo Ersek
2019-11-01 22:05       ` Ashish Singhal
2019-11-01 22:57         ` Laszlo Ersek
2019-11-04 17:51           ` Ashish Singhal
2019-11-05  2:42   ` Ni, Ray
2019-11-05  3:24     ` Ashish Singhal
2019-11-05  5:00       ` Andrew Fish
2019-11-05  5:06         ` Ashish Singhal
2019-11-05  5:21           ` Andrew Fish
2019-11-05  5:42             ` Ashish Singhal
2019-11-05  6:15               ` Andrew Fish
2019-11-05  9:54                 ` Laszlo Ersek
2019-11-05 16:52                   ` Andrew Fish
2019-11-05 18:00                     ` Ashish Singhal
2019-11-05 19:23                       ` Laszlo Ersek
2019-11-05 23:19                         ` Jeff Brasen
2019-11-06  0:20                           ` Andrew Fish
2019-11-06  9:56                           ` Laszlo Ersek
2019-11-06 16:15                             ` Andrew Fish
2019-11-06 19:58                               ` Laszlo Ersek
2019-11-06  1:07                         ` Ashish Singhal
2019-11-06  1:34                           ` Jeff Brasen
2019-11-06  2:47                             ` Andrew Fish
2019-11-06  3:20                               ` Ni, Ray
2019-11-06 16:19                                 ` Andrew Fish
2019-11-07  4:12                                   ` Jeff Brasen
2019-11-07  6:59                                     ` Ni, Ray
2019-11-07  7:02                                       ` Jeff Brasen
2019-11-07  7:21                                         ` Ni, Ray
2019-11-07 17:46                                           ` Jeff Brasen
2019-11-08 16:37                                             ` Laszlo Ersek
2019-11-11 22:57                                               ` Jeff Brasen
2019-11-11 23:58                                                 ` Ni, Ray
2019-11-12  0:00                                                   ` Jeff Brasen
2019-11-13 18:42                                                     ` Jeff Brasen
2019-11-14  2:09                                                       ` Ni, Ray
2019-11-14 17:04                                                         ` Jeff Brasen
2019-12-10 20:46                                                           ` Jeff Brasen
2019-12-11  9:54                                                             ` [edk2-discuss] " Wang, Sunny (HPS SW)
2019-12-11 14:00                                                             ` Ni, Ray
2019-12-12 17:52                                                               ` Jeff Brasen
2019-12-17 20:15                                                                 ` Ashish Singhal
2019-12-18  3:54                                                                   ` [edk2-discuss] " Wang, Sunny (HPS SW)
2019-12-18  8:43                                                                     ` Ni, Ray
2019-11-07  7:01                                   ` Ni, Ray
2019-11-05  9:33       ` Laszlo Ersek

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