FreeBSD/src 96f7757stand/efi/loader main.c

loader.efi: smbios: Favor the v3 (64-bit) entry point

Be consistent with what we are now doing with non-EFI boot (but with the
difference that EFI runs in 64-bit mode on 64-bit platforms, so there is
no restriction that the v3 entry point should be below 4GB).

While here, move out the EFI smbios detection code in a separate
sub-routine.

Reviewed by:    imp, markj
MFC after:      2 weeks
Relnotes:       yes
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49292
DeltaFile
+36-15stand/efi/loader/main.c
+36-151 files

FreeBSD/src 038457dstand/efi/loader main.c

stand/efi: Add more pl011-like uarts

The Arm SBSA uarts are handled by the pl011 driver. Add them to the
list of pl011 uarts.

Reviewed by:    manu, imp
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D48526
DeltaFile
+2-0stand/efi/loader/main.c
+2-01 files

FreeBSD/src 7eb3273stand/efi/loader main.c

stand/efi: Use hex values to get the uart type

To keep the SPCR uart type to name map aligned always use the hex value
as an index in the types array.

Reviewed by:    manu, imp
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D48525
DeltaFile
+4-4stand/efi/loader/main.c
+4-41 files

FreeBSD/src 780f289stand/efi/loader main.c, stand/libsa Makefile

stand: drop inttypes.h from safe list

Nothing uses it anymore, so drop it from the 'safe' list. Also, move
stand/efi/loader/main.c to using machine/_inttypes.h which is all it
really needs.

Sponsored by:           Netflix
DeltaFile
+1-1stand/efi/loader/main.c
+1-1stand/libsa/Makefile
+2-22 files

FreeBSD/src adce5eastand/efi/loader main.c

loader.efi: Fix LOADER_NET_SUPPORT=no builds

We include too many references to networking things in the
non-networking build for loader.efi. Ifdef out netserver command when we
are disabling network support to resolve.

PR: 277528
MFC After: 2 days
Reviewed by: imp

(cherry picked from commit 47ef2a131091508e049ab10cad7f91a3c1342cd9)
DeltaFile
+2-0stand/efi/loader/main.c
+2-01 files

FreeBSD/src 47ef2a1stand/efi/loader main.c

loader.efi: Fix LOADER_NET_SUPPORT=no builds

We include too many references to networking things in the
non-networking build for loader.efi. Ifdef out netserver command when we
are disabling network support to resolve.

PR: 277528
MFC After: 2 days
Reviewed by: imp
DeltaFile
+2-0stand/efi/loader/main.c
+2-01 files

FreeBSD/src 501983estand/efi/loader main.c

loader.efi: Parse SPCR v3 and v4

We can get the UART clock from v3 SPCR, and a precise baudrate from
v4. Some precise baudrates will currently be rejected by the kernel.

Sponsored by:           Netflix
Reviewed by:            adrian, andrew
Differential Revision:  https://reviews.freebsd.org/D47096
DeltaFile
+17-7stand/efi/loader/main.c
+17-71 files

FreeBSD/src 70253b5stand/efi/loader main.c

loader.efi: Parse SPCR table entry in ACPI tables

If there's a SPCR, then use it to create and pass the right values to
the uart.  We pass xo=0 in to calcuate the xo from the baud rate. We try
to be smart about what we set. We either set io or mm or pv/pd. Old
kernels will still work, despite pb/pd not being supported, because
we'll fall back to the SPCR parsing in the kernel.

We don't support Rev3 or Rev4 SPCR yet. It's too new to be in real
hardware yet.

Sponsored by:           Netflix
Differential Revision:  https://reviews.freebsd.org/D47085
DeltaFile
+205-15stand/efi/loader/main.c
+205-151 files

FreeBSD/src 9416410stand/efi/loader main.c

loader.efi: |= the boot flags how

how is assumed to be 0, so we directly assign to it. It might not always
be 0, so or-in these bits.

Sponsored by:           Netflix
Reviewed by:            bz, andrew
Differential Revision:  https://reviews.freebsd.org/D47084
DeltaFile
+2-2stand/efi/loader/main.c
+2-21 files

FreeBSD/src c5f3a7fstand/efi/loader main.c

loader.efi: Make rsdp global

Make rsdp pointer to the RSDP global so we can look up other tables.

Sponsored by:           Netflix
Reviewed by:            andrew
Differential Revision:  https://reviews.freebsd.org/D47083
DeltaFile
+5-1stand/efi/loader/main.c
+5-11 files

FreeBSD/src f470543stand/efi/loader main.c

loader: Expand EFI entropy if < 2048 bytes

The EFI RNG on some platforms takes a long time if we request 2048
bytes of entropy, so we would like to request less; but our kernel
Fortuna RNG needs to be fed 2048 bytes in order to consider itself
"fully seeded".  If we have between 64 bytes (the size of a single
Fortuna pool and enough to guarantee cryptographic security) and
2048 bytes (what Fortuna wants) then the boot process will hang
waiting for more entropy despite in fact having enough to operate
securely.

Since 64 bytes of entropy is plenty to be cryptographically secure
(an attack of cost ~ 2^128 is infeasible, which implies a mere 16
bytes of entropy), use PBKDF2 (aka pkcs5v2_genkey_raw) to spread
the entropy across 2048 bytes.  This is secure since PBKDF2 has
the property that every subset of output bytes has within O(1) of
the maximum possible amount of entropy.

Reviewed by:    pjd

    [5 lines not shown]
DeltaFile
+36-3stand/efi/loader/main.c
+36-31 files

FreeBSD/src 0d348c6stand/efi/loader main.c

loader: Instrument EFI GetRNG with TSLOG

On some systems, the EFI GetRNG is slow.  Make it show up in flamecharts.

MFC after:      1 week
Sponsored by:   Amazon
Differential Revision:  https://reviews.freebsd.org/D46631

(cherry picked from commit b58fe4eb29fbd3236df0f7fdfad4393d2536dbb5)
DeltaFile
+2-0stand/efi/loader/main.c
+2-01 files

FreeBSD/src c8ebbd2stand/efi/loader main.c

loader: Expand EFI entropy if < 2048 bytes

The EFI RNG on some platforms takes a long time if we request 2048
bytes of entropy, so we would like to request less; but our kernel
Fortuna RNG needs to be fed 2048 bytes in order to consider itself
"fully seeded".  If we have between 64 bytes (the size of a single
Fortuna pool and enough to guarantee cryptographic security) and
2048 bytes (what Fortuna wants) then the boot process will hang
waiting for more entropy despite in fact having enough to operate
securely.

Since 64 bytes of entropy is plenty to be cryptographically secure
(an attack of cost ~ 2^128 is infeasible, which implies a mere 16
bytes of entropy), use PBKDF2 (aka pkcs5v2_genkey_raw) to spread
the entropy across 2048 bytes.  This is secure since PBKDF2 has
the property that every subset of output bytes has within O(1) of
the maximum possible amount of entropy.

Reviewed by:    pjd

    [3 lines not shown]
DeltaFile
+36-3stand/efi/loader/main.c
+36-31 files

FreeBSD/src b58fe4estand/efi/loader main.c

loader: Instrument EFI GetRNG with TSLOG

On some systems, the EFI GetRNG is slow.  Make it show up in flamecharts.

MFC after:      1 week
Sponsored by:   Amazon
Differential Revision:  https://reviews.freebsd.org/D46631
DeltaFile
+2-0stand/efi/loader/main.c
+2-01 files

FreeBSD/src f8ca5d4stand/efi/loader Makefile, stand/efi/loader/arch/i386 elf64_freebsd.c amd64_tramp.S

stand: Add support for 64-bit machines with 32-bit UEFI implementations

Some machines have 64-bit capable cpus but are stuck on 32-bit uefi
firmware.

Add support for them by building a new "loader_ia32" with
LOADER_DEFAULT_INTERP along with the 64-bit one. The loader
can be disabled using MK_LOADER_IA32.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098
DeltaFile
+274-0stand/efi/loader/arch/i386/elf64_freebsd.c
+100-0stand/efi/loader/arch/i386/amd64_tramp.S
+75-0stand/efi/loader/arch/i386/start.S
+55-0stand/efi/loader/arch/i386/i386.ldscript
+51-0stand/efi/loader/arch/i386/setup.c
+18-6stand/efi/loader/Makefile
+573-611 files not shown
+621-2317 files

FreeBSD/src 6818ff7stand/efi/loader framebuffer.c main.c

loader: Fix 32-bit compatibility

main.c - Fix rsdp cast.
framebuffer.c -
        - Use temp variable instead of directly passing pointer when
          EFI_PHYSICAL_ADDRESS is expected.
          Also fix FreePages cast.
        - Mask framebuffer address given to us by UEFI.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098
DeltaFile
+15-6stand/efi/loader/framebuffer.c
+2-1stand/efi/loader/main.c
+17-72 files

FreeBSD/src d9288e8stand/efi/loader main.c

loader/efi: Small diff reduction

Make doing the boot once protocol more similar to copies of this code.

Sponsored by:           Netflix
Reviewed by:            manu
Differential Revision:  https://reviews.freebsd.org/D44007

(cherry picked from commit 2425dbdff3d7c23f464262517faf1f99a1b51165)
DeltaFile
+2-1stand/efi/loader/main.c
+2-11 files

FreeBSD/src c05fe06stand/i386/libi386 textvidc.c vidconsole.c, stand/libsa strcasecmp.c strdup.c

libsa: Remove redundant sys/cdefs.h

Sponsored by:           Netflix

(cherry picked from commit 3e15b01d6914c927e37d1699645783acf286655c)
DeltaFile
+1-4stand/i386/libi386/textvidc.c
+1-4stand/libsa/strcasecmp.c
+1-2stand/i386/libi386/vidconsole.c
+0-2stand/libsa/strdup.c
+0-2stand/libsa/stand.h
+0-2stand/libsa/inet_ntoa.c
+3-16159 files not shown
+3-185165 files

FreeBSD/src 92f8c2fstand/efi/loader main.c

loader/efi: Make gcc friendlier by move md_dev

Move the extern struct devsw md_dev out of the function. gcc is happier
with this arrangemnt often. However, we really should move it to a
header file, but that requires a bit of a rework of md support and
config.

Sponsored by:           Netflix
Reviewed by:            manu, tsoome
Differential Revision:  https://reviews.freebsd.org/D44008

(cherry picked from commit b2822c40f61d351bf8a4cac87e12521db06ff962)
DeltaFile
+2-1stand/efi/loader/main.c
+2-11 files

FreeBSD/src 77d298estand/efi/loader main.c, stand/i386/libi386 biosacpi.c

loader: lua: assume late ACPI detection if the feature isn't enabled

While we're here, enable the feature in the places we detect ACPI.  This
lets us side-step the existing issues and provide a path forward for
folks upgrading from previous releases that haven't updated their ESP
yet.

Let's also fix core.setACPI: the hint already indicates that the
user's disabled it more consistently than loader.acpi_disabled_by_user.
Even more, the latter is wrong because we set it by default if we did
not detect ACPI.  The ACPI hint remains even when we're setting defaults
because ACPI loaded into the kernel will make some noise if it's not
hinted off, even when we didn't detect it.

imp notes that this will result in some relatively harmless noise on
platforms that don't support ACPI but aren't using the UEFI loader, as
we would enable the ACPI module for loading on them and then loader
would not be able to find it.  These are non-fatal, but should probably
be fixed by just declaring support for EARLY_ACPI in those loaders since

    [7 lines not shown]
DeltaFile
+11-10stand/lua/core.lua
+2-0stand/i386/libi386/biosacpi.c
+1-0stand/efi/loader/main.c
+14-103 files

FreeBSD/src 05cf4ddstand/efi/loader main.c, stand/efi/loader/arch/amd64 elf64_freebsd.c

loader: fix EFI ACPI detection

lua was previously unable to determine ACPI presence because this
probing was postponed until the final loading and execution of the
kernel.

This patch resolves that by detecting ACPI early (similar to
the order of operations in the legacy i386 loader).

Reviewed by:    kevans
Approved by:    kp
Sponsored by:   Rubicon Communications, LLC ("Netgate")
Differential Revision:  https://reviews.freebsd.org/D42459

(cherry picked from commit 0b01d45783c3ee5a544c882d1b147e4a60382c41)
DeltaFile
+1-53stand/efi/loader/arch/arm64/exec.c
+0-44stand/efi/loader/arch/amd64/elf64_freebsd.c
+42-0stand/efi/loader/main.c
+43-973 files

FreeBSD/src ac0776estand/efi/include efi.h, stand/efi/include/amd64 efibind.h

stand/efi: Consolidate integer types

We have no need for 5 different copies of these.

Sponsored by:           Netflix
Reviewed by:            rcm, kevans, andrew
Differential Revision:  https://reviews.freebsd.org/D42699

(cherry picked from commit 7a1bc422d109a7cee56dcfbac616eda613c1c43e)
DeltaFile
+0-83stand/efi/include/i386/efibind.h
+0-83stand/efi/include/amd64/efibind.h
+0-76stand/efi/include/riscv/efibind.h
+0-76stand/efi/include/arm64/efibind.h
+0-35stand/efi/include/arm/efibind.h
+31-0stand/efi/include/efi.h
+31-3531 files not shown
+31-3547 files

FreeBSD/src 58b95f5stand/efi/loader main.c

stand/efi: Request ACPI use the system inttypes

With the system inttypes, we build on all platforms again.

Suggested by:   andrew
Fixes:          0b01d45783c3
Sponsored by:   Netflix

(cherry picked from commit 488bc7e9a77763dde6919d3c83e57d1fc8175ca2)
DeltaFile
+1-0stand/efi/loader/main.c
+1-01 files

FreeBSD/src beab67cstand/efi/loader main.c

stand/efi: Define ACPI_USE_SYSTEM_INTTYPES to be 1 instead of blank

To avoid a redefinition warning... This needs to be redone correctly,
but this gets amd64 building again...  My amd64 environment is polluted
with something that caues earlier failures which I ignored...

Fixes:          488bc7e9a777
Sponsored by:   Netflix

(cherry picked from commit e4789047ffd1319be337711ae4b6c594378f31b2)
DeltaFile
+1-1stand/efi/loader/main.c
+1-11 files

FreeBSD/src ebdd5d7stand/efi/loader main.c

stand/loader.efi: fix regression with ignoring nvstore

To read/update the boot loader nvstore, we always need to call
zfs_attach_nvstore() regardless of whether we use bootonce key
in nvstore or the bootfs property of the pool.  The call was
unintentionally left in the block of code that is processed
only when bootonce key is present.

In particular this fixes broken 'nextboot -k'.

Reviewed by:            imp
Differential Revision:  https://reviews.freebsd.org/D41795
Fixes:                  e3e2681d0ec28d6661fef6da76c9479049e2761c

(cherry picked from commit d13550f0c9c283e6bf7a2a3ec870f92a882c9f21)
DeltaFile
+1-1stand/efi/loader/main.c
+1-11 files

FreeBSD/src 2425dbdstand/efi/loader main.c

loader/efi: Small diff reduction

Make doing the boot once protocol more similar to copies of this code.

Sponsored by:           Netflix
Reviewed by:            manu
Differential Revision:  https://reviews.freebsd.org/D44007
DeltaFile
+2-1stand/efi/loader/main.c
+2-11 files

FreeBSD/src 3e15b01stand/common reloc_elf64.c, stand/efi/loader/arch/amd64 multiboot2.c

libsa: Remove redundant sys/cdefs.h

Sponsored by:           Netflix
DeltaFile
+1-4stand/i386/libi386/textvidc.c
+1-4stand/libsa/strcasecmp.c
+1-2stand/i386/libi386/vidconsole.c
+0-2stand/libsa/assert.c
+0-2stand/efi/loader/arch/amd64/multiboot2.c
+0-2stand/common/reloc_elf64.c
+3-16159 files not shown
+3-185165 files

FreeBSD/src b2822c4stand/efi/loader main.c

loader/efi: Make gcc friendlier by move md_dev

Move the extern struct devsw md_dev out of the function. gcc is happier
with this arrangemnt often. However, we really should move it to a
header file, but that requires a bit of a rework of md support and
config.

Sponsored by:           Netflix
Reviewed by:            manu, tsoome
Differential Revision:  https://reviews.freebsd.org/D44008
DeltaFile
+2-1stand/efi/loader/main.c
+2-11 files

FreeBSD/src 9d2f548stand/efi/loader main.c

loader: For EFI, if we don't have ConOut, try ConIn

Try ConIn if we don't have a ConOut variable. ConIn will contain HID
devices and/or serial devices. We currently just search for serial
devices and will use them instead of video with the current code. While
ConIn w/o ConOut is fairly common on laptops, is kinda rare on servers.
Some refinement may be needed in the future if servers come to
light. This is also minimal to allow possible integration into 13.3
release.

MFC After:              1 week
Sponsored by:           Netflix
Reviewed by:            dab, tsoome
Differential Revision:  https://reviews.freebsd.org/D43714

(cherry picked from commit 064fa628ce375028f2510182f4edbafa7f469ecb)
DeltaFile
+6-1stand/efi/loader/main.c
+6-11 files

FreeBSD/src 20a6f47stand/efi/loader main.c

loader: For EFI, if we don't have ConOut, try ConIn

Try ConIn if we don't have a ConOut variable. ConIn will contain HID
devices and/or serial devices. We currently just search for serial
devices and will use them instead of video with the current code. While
ConIn w/o ConOut is fairly common on laptops, is kinda rare on servers.
Some refinement may be needed in the future if servers come to
light. This is also minimal to allow possible integration into 13.3
release.

MFC After:              1 week
Sponsored by:           Netflix
Reviewed by:            dab, tsoome
Differential Revision:  https://reviews.freebsd.org/D43714

(cherry picked from commit 064fa628ce375028f2510182f4edbafa7f469ecb)
DeltaFile
+6-1stand/efi/loader/main.c
+6-11 files