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
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
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
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
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)
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
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
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
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
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
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]
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)
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]
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
FreeBSD/src f8ca5d4 — stand/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
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
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)
FreeBSD/src c05fe06 — stand/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)
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)
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]
FreeBSD/src 05cf4dd — stand/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)
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)
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)
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)
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)
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
FreeBSD/src 3e15b01 — stand/common reloc_elf64.c, stand/efi/loader/arch/amd64 multiboot2.c
libsa: Remove redundant sys/cdefs.h
Sponsored by: Netflix
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
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)
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)