Page MenuHomeFreeBSD

Initial support for implementing the bootXXX.efi workaround
ClosedPublic

Authored by 1983-01-06_gmx.net on Sep 14 2020, 9:43 PM.

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 OK
Unit
No Unit Test Coverage
Build Status
Buildable 33555
Build 30810: 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
133

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

1983-01-06_gmx.net added a reviewer: imp.

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
166

Are you certain that this will not overwrite existing entries?

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
166
-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:

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.

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
133

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

usr.sbin/bsdinstall/scripts/bootconfig
157

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
157

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.