From: Tom Rini <trini@konsulko.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: heinrich.schuchardt@canonical.com, sjg@chromium.org,
ilias.apalodimas@linaro.org, tuomas.tynkkynen@iki.fi,
patrick.rudolph@9elements.com, mkorpershoek@kernel.org,
u-boot@lists.denx.de
Subject: Re: [RFC 1/8] boot: EFI boot manager does not depend on BootOrder
Date: Tue, 6 May 2025 08:29:50 -0600 [thread overview]
Message-ID: <20250506142950.GV5430@bill-the-cat> (raw)
In-Reply-To: <87v7qe82av.fsf@bloch.sibelius.xs4all.nl>
[-- Attachment #1: Type: text/plain, Size: 9427 bytes --]
On Tue, May 06, 2025 at 12:24:24PM +0200, Mark Kettenis wrote:
> > Date: Mon, 5 May 2025 17:43:19 -0600
> > From: Tom Rini <trini@konsulko.com>
> >
> > On Tue, May 06, 2025 at 01:18:16AM +0200, Heinrich Schuchardt wrote:
> > > On 5/6/25 00:10, Tom Rini wrote:
> > > > On Tue, May 06, 2025 at 12:07:20AM +0200, Heinrich Schuchardt wrote:
> > > > > Tom Rini <trini@konsulko.com> schrieb am Mo., 5. Mai 2025, 21:54:
> > > > >
> > > > > > On Mon, May 05, 2025 at 09:51:52PM +0200, Heinrich Schuchardt wrote:
> > > > > > > Mark Kettenis <mark.kettenis@xs4all.nl> schrieb am Mo., 5. Mai 2025,
> > > > > > 21:03:
> > > > > > >
> > > > > > > > > Date: Fri, 2 May 2025 18:08:56 +0200
> > > > > > > > > From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> > > > > > > > >
> > > > > > > > > On 5/2/25 16:49, Simon Glass wrote:
> > > > > > > > > > Hi Heinrich,
> > > > > > > > > >
> > > > > > > > > > On Mon, 21 Apr 2025 at 10:26, Heinrich Schuchardt
> > > > > > > > > > <heinrich.schuchardt@canonical.com> wrote:
> > > > > > > > > > >
> > > > > > > > > > > The EFI boot manager bootmeth does not require variable BootOrder
> > > > > > to
> > > > > > > > be
> > > > > > > > > > > preexisting. It creates this variable.
> > > > > > > > > > >
> > > > > > > > > > > Signed-off-by: Heinrich Schuchardt <
> > > > > > heinrich.schuchardt@canonical.com
> > > > > > > > >
> > > > > > > > > > > ---
> > > > > > > > > > > boot/bootmeth_efi_mgr.c | 21 +++------------------
> > > > > > > > > > > 1 file changed, 3 insertions(+), 18 deletions(-)
> > > > > > > > > > >
> > > > > > > > > > > diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
> > > > > > > > > > > index 42b8863815e..1669cbed5bd 100644
> > > > > > > > > > > --- a/boot/bootmeth_efi_mgr.c
> > > > > > > > > > > +++ b/boot/bootmeth_efi_mgr.c
> > > > > > > > > > > @@ -47,30 +47,15 @@ static int efi_mgr_check(struct udevice *dev,
> > > > > > > > struct bootflow_iter *iter)
> > > > > > > > > > >
> > > > > > > > > > > static int efi_mgr_read_bootflow(struct udevice *dev, struct
> > > > > > > > bootflow *bflow)
> > > > > > > > > > > {
> > > > > > > > > > > - struct efi_mgr_priv *priv = dev_get_priv(dev);
> > > > > > > > > > > - efi_status_t ret;
> > > > > > > > > > > - efi_uintn_t size;
> > > > > > > > > > > - u16 *bootorder;
> > > > > > > > > > > -
> > > > > > > > > > > - if (priv->fake_dev) {
> > > > > > > > > > > - bflow->state = BOOTFLOWST_READY;
> > > > > > > > > > > - return 0;
> > > > > > > > > > > - }
> > > > > > > > > > > + int ret
> > > > > > > > > > >
> > > > > > > > > > > ret = efi_init_obj_list();
> > > > > > > > > > > if (ret)
> > > > > > > > > > > return log_msg_ret("init", ret);
> > > > > > > > > > >
> > > > > > > > > > > - /* Enable this method if the "BootOrder" UEFI exists. */
> > > > > > > > > > > - bootorder = efi_get_var(u"BootOrder",
> > > > > > > > &efi_global_variable_guid,
> > > > > > > > > > > - &size);
> > > > > > > > > > > - if (bootorder) {
> > > > > > > > > > > - free(bootorder);
> > > > > > > > > > > - bflow->state = BOOTFLOWST_READY;
> > > > > > > > > > > - return 0;
> > > > > > > > > > > - }
> > > > > > > > > > > + bflow->state = BOOTFLOWST_READY;
> > > > > > > > > > >
> > > > > > > > > > > - return -EINVAL;
> > > > > > > > > > > + return 0;
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > static int efi_mgr_read_file(struct udevice *dev, struct
> > > > > > bootflow
> > > > > > > > *bflow,
> > > > > > > > > > > --
> > > > > > > > > > > 2.48.1
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > How do we know if the board is using EFI bootmgr? My understanding
> > > > > > was
> > > > > > > > > > that this was a way to find out?
> > > > > > > > >
> > > > > > > > > The boot manager must always run.
> > > > > > > > >
> > > > > > > > > The check for the BootOrder variable introduced in commit
> > > > > > f2bfa0cb1794
> > > > > > > > > is a bug.
> > > > > > > >
> > > > > > > > Well, at the time the boot manager did not attempt to boot the default
> > > > > > > > path. So there was no point in running the boot manager code unless
> > > > > > > > BootOrder (or BootNext) was set. And of course before that commit the
> > > > > > > > boot manager didn't run at all on non-sandbox builds that had the
> > > > > > > > standard boot stuff enebaled.
> > > > > > > >
> > > > > > > > Anyway, I believe the thinking behind that commit is still sound. As
> > > > > > > > I explained earlier, I think that...
> > > > > > > >
> > > > > > > > > The boot manager handles in sequence:
> > > > > > > > >
> > > > > > > > > * Try to boot as indicated by BootNext.
> > > > > > > > > * Try to boot as indicated by BootOrder.
> > > > > > > > > * Try to boot default path for available media.
> > > > > > > > > This will add Boot#### entries and update BootOrder.
> > > > > > > >
> > > > > > > > ...doing this all in a monolithic sequence isn't the best way to
> > > > > > > > handle EFI boot in the u-boot ecosystem.
> > > > > > > >
> > > > > > > > Your series moves the boot manager further down the list because the
> > > > > > > > third step in the sequence has to happen late. But as a result
> > > > > > > > BootNext and BootOrder processing will also happen late. So what
> > > > > > > > happens if you have a board with two OS installations:
> > > > > > > >
> > > > > > > > 1. A generic Linux distro that boots via EFI.
> > > > > > > >
> > > > > > > > 2. Something like Armbian that provides an extlinux.conf file.
> > > > > > > >
> > > > > > > > Currently such a system will probably boot OS #1. But after your
> > > > > > > >
> > > > > > >
> > > > > > > This did not happen with distoboot. So migration from distroboot to
> > > > > > > standard boot results in a change that you want to avoid.
> > > > > > >
> > > > > > > changes it will probably boot OS #2. And if OS #1 sets BootOrder or
> > > > > > > > BootNext that will not change anything.
> > > > > > > >
> > > > > > > > So I think we need a solution where BootNext and BootOrder processing
> > > > > > > > happens early, like we do now.
> > > > > > > >
> > > > > > >
> > > > > > > As of today BootNext does not invoke the boot manager.
> > > > > > >
> > > > > > > If BootOrder is set the boot manager may fail because not all devices are
> > > > > > > detected as "hunters" have not been running. E.g. nvme scan and usb start
> > > > > > > are only invoked after the EFI boot manager.
> > > > > > >
> > > > > > > I originally suggested to probe all boot devices before the boot manager
> > > > > > > runs, but users complained that this slows down their non-EFI boot flows.
> > > > > > > This is why I now move it after all boot methods but PXE.
> > > > > >
> > > > > > Can we not see what BootOrder is and then ensure it's been "hunted" ?
> > > > > >
> > > > > > --
> > > > > > Tom
> > > > > >
> > > > >
> > > > > A load option may only contain the partition GUID and the file path. In
> > > > > this case you wouldn't be able to tell whether it is for an NVMe drive, or
> > > > > a USB stick.
> > > > >
> > > > > As numbering of devices cannot be expected to be stable, it is preferable
> > > > > to use this short form of device paths for load options.
> > > >
> > > > Ah, OK. So could we check and if not found print a human understandable
> > > > error message, and continue on? I want to figure out some path that does
> > > > not change the pre-bootstd behavior.
> > > >
> > >
> > > In distroboot scan_dev_for_efi is invoked for every boot device and each
> > > time calls the boot manager. As usb start is only called in usb_boot this
> > > will result in behavior that is as non-compliant with the UEFI
> > > specification.
> > >
> > > We should reach a behavior that complies with the UEFI specification.
> > > Not changing former distro boot behavior is not a valid option.
> >
> > Can we also not figure out some way to boot promptly? I was thinking
> > something along the lines of if we know BootOrder (or similar), we try
> > it. If we don't find it, we try again a bit later on when we can run all
> > the hunting that might be slow. If the only option is slow-but-compliant
> > I feel like a lot of use cases will opt out of using EFI boot instead.
>
> I think that is possible. But it will require tighter integration
> integration between the EFI loader and the standard boot device
> hunting code such that devices are probed as we walk to options
> specified by the BootOrder.
>
> A complication here is that a Boot#### option doesn't necessearily
> have the device encoded into the boot option. An option can reference
> just the GUID of a partition and many OS installers create such
> options. So if we see such an option we do need to probe devices
> until we find the right partition.
Right, I recall Heinrich mentioned it could (might often be?) a GUID
instead and so we might need to hunt, check what we found for a GUID,
repeat. I am assuming that would not be an expensive operation however.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2025-05-06 14:29 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 16:25 [RFC 0/8] boot: run EFI boot manager after block devices Heinrich Schuchardt
2025-04-21 16:25 ` [RFC 1/8] boot: EFI boot manager does not depend on BootOrder Heinrich Schuchardt
2025-05-02 9:26 ` Ilias Apalodimas
2025-05-02 14:49 ` Simon Glass
2025-05-02 16:08 ` Heinrich Schuchardt
2025-05-03 2:10 ` Simon Glass
2025-05-03 7:04 ` Heinrich Schuchardt
2025-05-03 21:26 ` Simon Glass
2025-05-04 5:34 ` Heinrich Schuchardt
2025-05-05 19:03 ` Mark Kettenis
2025-05-05 19:51 ` Heinrich Schuchardt
2025-05-05 19:54 ` Tom Rini
2025-05-05 22:07 ` Heinrich Schuchardt
2025-05-05 22:10 ` Tom Rini
2025-05-05 23:18 ` Heinrich Schuchardt
2025-05-05 23:43 ` Tom Rini
2025-05-06 10:24 ` Mark Kettenis
2025-05-06 13:24 ` Simon Glass
2025-05-06 14:29 ` Tom Rini [this message]
2025-05-06 15:56 ` Ilias Apalodimas
2025-04-21 16:25 ` [RFC 2/8] boot: BOOTMETH_DISTRO should select BOOTMETH_EFI_BOOTMGR Heinrich Schuchardt
2025-04-23 12:28 ` Simon Glass
2025-04-23 12:53 ` Heinrich Schuchardt
2025-05-02 9:28 ` Ilias Apalodimas
2025-05-02 13:23 ` Simon Glass
2025-05-02 13:28 ` Ilias Apalodimas
2025-04-21 16:25 ` [RFC 3/8] boot: make BOOTMETH_EFILOADER default=n Heinrich Schuchardt
2025-05-02 9:30 ` Ilias Apalodimas
2025-05-02 14:49 ` Simon Glass
2025-05-02 16:16 ` Heinrich Schuchardt
2025-05-03 2:10 ` Simon Glass
2025-05-03 7:15 ` Heinrich Schuchardt
2025-05-03 21:26 ` Simon Glass
2025-04-21 16:25 ` [RFC 4/8] boot: introduce BOOTDEVP_6_EFI Heinrich Schuchardt
2025-04-21 16:25 ` [RFC 5/8] boot: prevent recursion in bootdev_hunt_drv() Heinrich Schuchardt
2025-04-21 16:25 ` [RFC 6/8] boot: make EFI boot manager bootmeth non-global Heinrich Schuchardt
2025-04-21 16:25 ` [RFC 7/8] efi_loader: create EFI BOOTDEV Heinrich Schuchardt
2025-04-23 12:28 ` Simon Glass
2025-04-23 12:50 ` Heinrich Schuchardt
2025-05-02 9:44 ` Ilias Apalodimas
2025-04-21 16:25 ` [RFC 8/8] board/emulation/qemu-arm: enable EFI boot manager Heinrich Schuchardt
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-all 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=20250506142950.GV5430@bill-the-cat \
--to=trini@konsulko.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=ilias.apalodimas@linaro.org \
--cc=mark.kettenis@xs4all.nl \
--cc=mkorpershoek@kernel.org \
--cc=patrick.rudolph@9elements.com \
--cc=sjg@chromium.org \
--cc=tuomas.tynkkynen@iki.fi \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.