public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
To: Pete Batard <pete@akeo.ie>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "zhichao.gao@intel.com" <zhichao.gao@intel.com>,
	"ray.ni@intel.com" <ray.ni@intel.com>,
	"ard.biesheuvel@arm.com" <ard.biesheuvel@arm.com>,
	"leif@nuviainc.com" <leif@nuviainc.com>,
	"Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
Subject: Re: [edk2-devel] [edk2][PATCH 1/1] MdeModulePkg/UefiBootManagerLib: Signal ReadyToBoot on platform recovery
Date: Wed, 17 Jun 2020 13:04:02 +0000	[thread overview]
Message-ID: <DF4PR8401MB058563E79440B3E3EAB47D8FA89A0@DF4PR8401MB0585.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <99904809-1e07-6bd8-f7ba-25e87b1fe543@akeo.ie>

Thanks for checking my comments, Pete. 

> Or is the "one more" the issue, meaning that it would get signaled more than once?
[Sunny] Yeah, it would get signaled more than once if the PlatformRecovery option (a UEFI application) calls EfiBootManagerBoot() to launch the recovered boot option inside of the application.      

> I don't mind trying an alternative approach, but I don't understand how what you describe would help. Can you please be more specific about what you have in mind?
[Sunny] Sure. I added more information below. If it is still not clear enough, feel free to let me know.
     1. Create a UEFI application with the code to signal ReadyToBoot and pick /efi/boot/bootaa64.efi from either SD or USB and run it.
     2. Then, call EfiBootManagerInitializeLoadOption like the following in a DXE driver or other places before "Default PlatformRecovery" registration:  
  Status = EfiBootManagerInitializeLoadOption (
             &LoadOption,
             0,                                                                             -> 0 is the OptionNumber to let application be load before " Default PlatformRecovery" option
             LoadOptionTypePlatformRecovery,
             LOAD_OPTION_ACTIVE,
             L"Application for recovering boot options",
             FilePath,                                                                -> FilePath is the Application's device path,
             NULL,
             0
             );


> My reasoning is that, if PlatformRecovery#### can execute a regular bootloader like /efi/boot/boot####.efi from installation media, then it should go through the same kind of initialization that happens for a regular boot option, and that should include signaling the ReadyToBoot event. 
[Sunny] Thanks for clarifying this, and Sorry about that I missed your cover letter for this patch.  I was just thinking that we may not really need to make this behavior change in both EDK II code and UEFI specification for solving the problem specific to the case that OS is loaded by "Default PlatformRecovery" option, and I'm also not sure if it is worth making this change to affect some of the system or BIOS vendors who have implemented their PlatformRecovery option. If the alternative approach I mentioned works for you, I think that would be an easier solution.

Regards,
Sunny Wang

-----Original Message-----
From: Pete Batard [mailto:pete@akeo.ie] 
Sent: Wednesday, June 17, 2020 6:59 PM
To: Wang, Sunny (HPS SW) <sunnywang@hpe.com>; devel@edk2.groups.io
Cc: zhichao.gao@intel.com; ray.ni@intel.com; ard.biesheuvel@arm.com; leif@nuviainc.com
Subject: Re: [edk2-devel] [edk2][PATCH 1/1] MdeModulePkg/UefiBootManagerLib: Signal ReadyToBoot on platform recovery

Hi Sunny, thanks for looking into this.

On 2020.06.17 09:16, Wang, Sunny (HPS SW) wrote:
> Hi Pete.
> 
> Since the EfiBootManagerProcessLoadOption is called by ProcessLoadOptions as well, your change would also cause some unexpected behavior like:
> 1. Signal one more ReadyToBoot for the PlatformRecovery option which is an application that calls EfiBootManagerBoot() to launch its recovered boot option.

I'm not sure I understand how this part is unwanted.

The point of this patch is to ensure that ReadyToBoot is signalled for the PlatformRecovery option, so isn't what you describe above exactly what we want?

Or is the "one more" the issue, meaning that it would get signalled more than once?


> 2. Signal ReadyToBoot for SysPrep#### or Driver#### that is not really a "boot" option.

Yes, I've been wondering about that, because BdsEntry.c's ProcessLoadOptions(), which calls EfiBootManagerProcessLoadOption(),
mentions that it will load will load and start every Driver####, SysPrep#### or PlatformRecovery####. But the comment about the while() loop in EfiBootManagerProcessLoadOption() only mentions PlatformRecovery####.

If needed, I guess we could amend the patch to detect the type of option and only signal ReadyToBoot for PlatformRecovery####.

> To solve your problem, creating a PlatformRecovery option with the smallest option number and using it instead of default one (with short-form File Path Media Device Path) looks like a simpler solution.

I don't mind trying an alternative approach, but I don't understand how what you describe would help. Can you please be more specific about what you have in mind?

Our main issue here is that we must have ReadyToBoot signalled so that the ReadyToBoot() function callback from EmbeddedPkg/Drivers/ConsolePrefDxe gets executed in order for the boot loader invoked from PlatformRecovery####  to use a properly initialized graphical console. So I'm not sure I quite get how switching from one PlatformRecovery#### option to another would improve things.

If it helps, here is what we currently default to, in terms of boot options, on a Raspberry Pi 4 platform with a newly build firmware:

[Bds]=============Begin Load Options Dumping ...=============
   Driver Options:
   SysPrep Options:
   Boot Options:
     Boot0000: UiApp              0x0109
     Boot0001: UEFI Shell                 0x0000
   PlatformRecovery Options:
     PlatformRecovery0000: Default PlatformRecovery               0x0001
[Bds]=============End Load Options Dumping=============

With this, PlatformRecovery0000 gets executed by default, which is what we want, since it will pick /efi/boot/bootaa64.efi from either SD or USB and run it, the only issue being that, because ReadyToBoot has not been executed, the graphical console is not operative so users can't interact with the OS installer.

So I'm really not sure how adding an extra PlatformRecovery#### would help. And I'm also not too familiar with how one would go around to add such an entry...

> By the way, I also checked the UEFI specification. It looks making sense to only signal ReadyToBoot for boot option (Boot####).

That's something I considered too, but I disagree with this conclusion.

My reasoning is that, if PlatformRecovery#### can execute a regular bootloader like /efi/boot/boot####.efi from installation media, then it should go through the same kind of initialization that happens for a regular boot option, and that should include signalling the ReadyToBoot event.

If there was a special bootloader for PlatformRecovery#### (e.g. 
/efi/boot/recovery####.efi) then I would agree with only signalling ReadyToBoot for a formal Boot#### option. But that isn't the case, so I think it is reasonable to want to have ReadyToBoot also occur when a /efi/boot/boot####.efi bootloader is executed from PlatformRecovery####., especially when we know it can be crucial to ensuring that the end user can actually use the graphical console.

> Therefore, your change may also require specification change.

Yes, I mentioned that in the cover letter for this patch (https://edk2.groups.io/g/devel/message/61327 ), which also describes the issue we are trying to solve in greater details. This is what I wrote:

------------------------------------------------------------------------
Note however that this may require a specs update, as the current UEFI specs for EFI_BOOT_SERVICES.CreateEventEx() have:

 >  EFI_EVENT_GROUP_READY_TO_BOOT
 >    This event group is notified by the system when the Boot Manager
 >    is about to load and execute a boot option.

and, once this patch has been applied, we may want to update this section to mention that it applies to both Boot Manager and Platform Recovery.
------------------------------------------------------------------------


Again, I don't have an issue with trying to use an alternate approach to solve our problem (though I ultimately believe that, if PlatformRecovery#### can launch a /efi/boot/boot####.efi bootloader then we must update the specs and the code to have ReadyToBoot also signalled then, because that's the logical thing to do). But right now, I'm not seeing how to achieve that when PlatformRecovery#### is the option that is used to launch the OS installation the bootloader. So if you can provide mode details on how exactly you think creating an alternate PlatformRecovery option would help, I would appreciate it.

Regards,

/Pete

> 
> Regards,
> Sunny Wang
> 
> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of 
> Pete Batard
> Sent: Tuesday, June 16, 2020 5:56 PM
> To: devel@edk2.groups.io
> Cc: zhichao.gao@intel.com; ray.ni@intel.com; ard.biesheuvel@arm.com; 
> leif@nuviainc.com
> Subject: [edk2-devel] [edk2][PATCH 1/1] 
> MdeModulePkg/UefiBootManagerLib: Signal ReadyToBoot on platform 
> recovery
> 
> Currently, the ReadyToBoot event is only signaled when a formal Boot Manager option is executed (in BmBoot.c -> EfiBootManagerBoot ()).
> 
> However, with the introduction of Platform Recovery in UEFI 2.5, which may lead to the execution of a boot loader that has similar requirements to a regular one, yet is not launched as a Boot Manager option, it also becomes necessary to signal ReadyToBoot when a Platform Recovery boot loader runs.
> 
> Especially, this can be critical to ensuring that the graphical console is actually usable during platform recovery, as some platforms do rely on the ConsolePrefDxe driver, which only performs console initialization after ReadyToBoot is triggered.
> 
> This patch fixes that behaviour by calling EfiSignalEventReadyToBoot () in EfiBootManagerProcessLoadOption (), which is the function that sets up the platform recovery boot process.
> 
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
>   MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c 
> b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
> index 89372b3b97b8..117f1f5b124c 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
> @@ -1376,6 +1376,15 @@ EfiBootManagerProcessLoadOption (
>       return EFI_SUCCESS;
>     }
>   
> +  //
> +  // Signal the EVT_SIGNAL_READY_TO_BOOT event when we are about to load and execute the boot option.
> +  //
> +  EfiSignalEventReadyToBoot ();
> +  //
> +  // Report Status Code to indicate ReadyToBoot was signalled  // 
> + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_DXE_BS_DRIVER | 
> + EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT));
> +
>     //
>     // Load and start the load option.
>     //
> --
> 2.21.0.windows.1
> 
> 
> 
> 


  reply	other threads:[~2020-06-17 13:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16  9:56 [edk2][PATCH 0/1] MdeModulePkg/UefiBootManagerLib: Signal ReadyToBoot on platform recovery Pete Batard
2020-06-16  9:56 ` [edk2][PATCH 1/1] " Pete Batard
2020-06-17  8:16   ` [edk2-devel] " Wang, Sunny (HPS SW)
2020-06-17 10:59     ` Pete Batard
2020-06-17 13:04       ` Wang, Sunny (HPS SW) [this message]
2020-06-17 16:34         ` Pete Batard
2020-06-17 16:36           ` Andrei Warkentin
2020-06-17 16:41             ` Pete Batard
2020-06-17 16:41             ` Samer El-Haj-Mahmoud
     [not found]             ` <161962620CFC252E.28613@groups.io>
2020-06-17 17:06               ` Samer El-Haj-Mahmoud
2020-06-30 17:17                 ` Pete Batard
2021-02-17 11:42                   ` [EXTERNAL] " Leif Lindholm
2021-02-17 12:18                     ` Pete Batard
2021-02-17 14:25                       ` Laszlo Ersek
2021-02-22  9:28                         ` Wang, Sunny (HPS SW)
2021-02-25 10:54                           ` Pete Batard
2021-04-13 19:47                             ` Samer El-Haj-Mahmoud
     [not found]                             ` <167582A230C8C2FD.9378@groups.io>
2021-04-29 14:50                               ` Samer El-Haj-Mahmoud
2021-04-30 18:36                         ` [EXTERNAL] " Samer El-Haj-Mahmoud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DF4PR8401MB058563E79440B3E3EAB47D8FA89A0@DF4PR8401MB0585.NAMPRD84.PROD.OUTLOOK.COM \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox