Page MenuHomeFreeBSD

Initial support for implementing the bootXXX.efi workaround
ClosedPublic

Authored by michaelo on Sep 14 2020, 9:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 11:32 PM
Unknown Object (File)
Nov 17 2024, 12:30 PM
Unknown Object (File)
Nov 4 2024, 3:43 AM
Unknown Object (File)
Oct 23 2024, 6:54 AM
Unknown Object (File)
Oct 22 2024, 6:02 PM
Unknown Object (File)
Oct 4 2024, 5:10 AM
Unknown Object (File)
Oct 3 2024, 10:13 AM
Unknown Object (File)
Sep 30 2024, 12:57 PM
Subscribers

Details

Summary

Too many BIOSes (so far only confirmed on amd64) don't really support
efibootmgr selection of boot. That's the most reliable, when it works,
since there's no guesswork. However, many do not save, unmolested, the
variables that efibootmgr sets, so as a fallback we also install
loader.efi as bootXXX.efi (where XXX is either aa64 or x64) if it
doesn't already exist in /efi/boot on the ESP. The standard only
defines this for removable devices, but it's almost ubiquitously used
as a fallback. Many BIOSes implement a drive selection feature that
takes over the efibootmgr protocol, rendinering it useless (either
generally, or for those vendors not on the short list). bootxxx.efi
works around this. However, we don't install it unconditionally there,
as that breaks some popular multi-boot setups.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33551
Build 30808: arc lint + arc unit

Event Timeline

imp requested review of this revision.Sep 14 2020, 9:43 PM
imp created this revision.
usr.sbin/bsdinstall/scripts/bootconfig
134

Do we want BOOTx64.EFI or bootx64.efi

Add comment documenting why we only conditionally install bootx64.efi

Another case where this might happen is in PR249320 - my laptop had a mb swap, and so lost the EFI variables. It was slightly awkward to get it booted again (to copy to bootx64.efi, or run efiboomgr).

usr.sbin/bsdinstall/scripts/bootconfig
128

style nit - other bsdinstall source lines up the cases themselves under case

michaelo added a reviewer: imp.
michaelo added a subscriber: michaelo.

You description is wrong. No BIOS will boot off an EFI partition. Don't mix BIOS and UEFI firmware implementation.

usr.sbin/bsdinstall/scripts/bootconfig
169

Are you certain that this will not overwrite existing entries?

In D26428#588030, @1983-01-06_gmx.net wrote:

You description is wrong. No BIOS will boot off an EFI partition. Don't mix BIOS and UEFI firmware implementation.

BIOS is the generic program that runs before the OS. UEFI is a kind of BIOS. This terminology pre-dates the IBM/PC and was used in CP/M and others.
CMS is what will never load a program from an ESP.

usr.sbin/bsdinstall/scripts/bootconfig
169
-f file       True if file exists and is a regular file.
! expression  True if expression is false.

So if ! -f --> no file exists, then we copy.

In D26428#588146, @imp wrote:
In D26428#588030, @1983-01-06_gmx.net wrote:

You description is wrong. No BIOS will boot off an EFI partition. Don't mix BIOS and UEFI firmware implementation.

BIOS is the generic program that runs before the OS. UEFI is a kind of BIOS. This terminology pre-dates the IBM/PC and was used in CP/M and others.
CMS is what will never load a program from an ESP.

I don't consider UEFI to be basic at all, both are completely different. If you would refer to it as firmware, I would agree, but not to UEFI as BIOS.

In D26428#588166, @1983-01-06_gmx.net wrote:

I don't consider UEFI to be basic at all, both are completely different. If you would refer to it as firmware, I would agree, but not to UEFI as BIOS.

Agreed. People still call it a "BIOS" due to inertia, but we should be precise and call it UEFI or perhaps system firmware.

For example, Microsoft has done a lot of work around UEFI, and talks about it like this:

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/boot-to-uefi-mode-or-legacy-bios-mode

Detect if WinPE is booted into BIOS or UEFI Mode
Return code Firmware mode
0x1 BIOS
0x2 UEFI

usr.sbin/bsdinstall/scripts/bootconfig
134

Since the EFI partition has a FAT filesystem which isn't case-sensitive it doesn't matter.

usr.sbin/bsdinstall/scripts/bootconfig
160

There are also ways to lose the boot manager entries on physical platforms too -- for example a firmware update often requires resetting the configuration, which is frustrating when BOOTx64.efi doesn't exist.

usr.sbin/bsdinstall/scripts/bootconfig
160

True, but this can be worked around.
http://bsdimp.blogspot.com/2020/10/how-to-recover-from-bios-upgrade.html
though that's also annoying... And having bootx64.efi in place that was loader.efi didn't prevent me from needing to do this process.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 9 2020, 12:16 AM
This revision was automatically updated to reflect the committed changes.