Page MenuHomeFreeBSD

Initial support for implementing the bootXXX.efi workaround
Needs ReviewPublic

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

Details

Reviewers
emaste
bcran
imp
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.Mon, Sep 14, 9:43 PM
imp created this revision.
emaste added inline comments.Mon, Sep 14, 9:56 PM
usr.sbin/bsdinstall/scripts/bootconfig
134

Do we want BOOTx64.EFI or bootx64.efi

imp updated this revision to Diff 77030.Mon, Sep 14, 9:59 PM

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).

emaste added inline comments.Mon, Sep 14, 11:14 PM
usr.sbin/bsdinstall/scripts/bootconfig
128

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

1983-01-06_gmx.net commandeered this revision.Tue, Sep 15, 6:30 AM
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?

imp added a comment.Tue, Sep 15, 2:55 PM

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.

imp added inline comments.Tue, Sep 15, 2:56 PM
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.

1983-01-06_gmx.net marked an inline comment as done.Tue, Sep 15, 3:51 PM
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.

bcran added a comment.EditedThu, Sep 17, 4:23 PM

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.

bcran added inline comments.Thu, Sep 17, 4:27 PM
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.