Commit graph

2274 commits

Author SHA1 Message Date
kitkat1424
7b3fb3caef loader.efi(8): clarify UEFI boot path and boot1.efi usage
Reorganise and clarify the legacy role of boot1.efi in DESCRIPTION to
improve clarity.

Add a minor missing word in the BUGS section ["...caution is required*..."].

See also - PR: 290794

Signed-off-by: Aaditya Singh <aadityavksingh@gmail.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1939
2026-01-09 14:16:24 -07:00
Minsoo Choo
fa6736526e stand: remove powerpcspe linker script
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1914
(cherry picked from commit 9c72e8e3500408f7ce5fc7be500dd3efc0307674)
2026-01-09 15:11:22 -05:00
Minsoo Choo
94d1731e73 Makefile*: remove powerpcspe
As reported on the freebsd-announce mailing list[1] FreeBSD is
continuing to retire 32-bit support.  Remove powerpcspe from build
infrastructure.

[1] https://lists.freebsd.org/archives/freebsd-announce/2024-February/000117.html

Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by:	jhibbits, emaste
Pull request:	https://github.com/freebsd/freebsd-src/pull/1914
2026-01-09 11:28:43 -05:00
Warner Losh
3989a3d817 loader: Only warn when we have neither FDT nor ACPI
Sponsored by:		Netflix
Reviewed by:		adrian, andrew
Differential Revision:	https://reviews.freebsd.org/D54510
2026-01-07 22:34:28 -07:00
Jarmo Jaakkola
d82698ac68 loader.efi: Only use SPCR if enabled.
SerialPort in the SPCR is zeroed when serial redirection is disabled,
rather than the SPCR being omitted from the ACPI tables ony many
systems. Check to see that SerialPort.Address is non-zero before using.

FreeBSD would fail to boot on systems that could have a serial port
redireciton, but don't have it enabled because the loader would create a
bogus hw.uart.console. While one could unset this value to boot, you
couldn't do that automatically very easily. Instead, don't even look
at the SPCR table if the SerialPort is zero'd.

PR: 292206
MFC After: 3 days
Sponsored by: Netflix
Co-authored-by: Warner Losh <imp@FreeBSD.org>
Closes:  https://github.com/freebsd/freebsd-src/pull/1948
2026-01-07 22:28:44 -07:00
Kyle Evans
e30086ab4c lualoader: fix pruning of non-existent default kernel
Removing the kernel from the list of available kernels is sufficient to
avoid rendering it in the list, but we need more for booting to actually
work.  Notably, the 'kernel' loader.conf var was left intact to its
default value, so if one didn't use the kernel selector in the menu then
we'd try to boot the nonexistent 'kernel' instead of the new default
(first autodetected).

There's room to improve the error messages here, but for now let's just
make it actually work correctly.

PR:		292232
Fixes:	d04415c520 ("loader: lua: remove the default kernel [...]")
2026-01-07 12:20:05 -06:00
Alexander Ziaee
1961785e35
pxeboot.8: Fix mdoc typo for emails, tag spdx
Fixes:		a37825313f (Fix mdoc typos for emails, tag spdx)
MFC after:	3 days
2026-01-06 17:47:54 -05:00
Frank Hilgendorf
be6ba97aae loader.efi: add stride & offset for MacBookPro3,1
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
Note that there are three variants of this MacBook. We only have the
stride and offset values for the 17" 1680x1050 model.

Reviewed by:	vexeduxr
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1584
2026-01-06 18:29:01 +02:00
Ahmad Khalifa
9595055ae7 loader.efi: only use firmware provided Blt on GOP
gfx_state.tg_private points to a EFI_GRAPHICS_OUTPUT_PROTOCOL only when
using GOP.

The firmware provided Blt functions on UGA platforms have been observed
to not work on old MacBooks, and are likley hit or miss anyways as UGA
has been deprecated since 2006.

Reviewed by:	tsoome
PR:		291935
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54432
2026-01-04 15:15:37 +02:00
Ahmad Khalifa
5d85dde27b loader.efi: probe for UGA if GOP isn't found
Probe for UGA instead of returning early if we can't find GOP.

Reviewed by:	tsoome
PR:		291935
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54431
2026-01-04 15:15:02 +02:00
Warner Losh
8e8d7d489f loader: Use C99 initializations for file_format
For greppability, use C99 initializers for the struct file_format.

Sponsored by:		Netflix
2025-12-27 22:37:56 -07:00
Warner Losh
424089a0fc loader: Fix powerpc64le by working around slof bug in qemu/slof
Fix powerpc 64 little endian booting by adding some padding. Due to

https://gitlab.com/slof/slof/-/blob/master/lib/libelf/elf32.c?ref_type=heads#L114
https://gitlab.com/slof/slof/-/blob/master/lib/libelf/elf32.c?ref_type=heads#L150

using <= instead of <, slof used to loop over the phdrs. It overruns by
1 and so on little endian it swizzles the first 32 bytes of .text. Work
around this by adding 32 bytes of padding after the headers. We should
fix this in slof, but it's in the just released QEMU 10.2, so we have to
pad things here for now.

Now powerpc64le + qemu works.

MFC After: 3 days (maybe EN too)
Reviewed by: adrian, jhibbits
Sponsored by: Netflix
2025-12-27 22:27:03 -07:00
Warner Losh
332096ebb6 kboot: Explicitly use host:/proc
When looking for the boot_params symbol we need to get the UEFI memory
map, use host: prefix. The short-circuit we have for this only works
when we have a filesystem. During the earliest parts of boot, we can
sometimes not have this yet, so making this explicit allows these
environments to function.

It's always in the host path. Print better
error messages, and add newlines in two palces.

Sponsored by:		Netflix
2025-12-10 12:03:47 -07:00
Bjoern A. Zeeb
f0ea859229 iwmfw(4): fix spelling of the iwm8000C firmware.
When migrating the firmware to be installed as plain firmware files
to /boot/firmware the iwm8000C firmware lost its "fw" suffix that
iwm(4) expects.
The follow-up change to defaults/loader.conf is also consistently
missing the "fw".

Fix both places, and add the wrongly spelt version to ObsoleteFiles.inc
(entirely untested).

PR:		291403
Reported by:	Augustin Hoffmann (avgwst tutanota.de)
Fixes:		af0a81b647
Fixes:		a0f06dfb0d
MFC after:	3 days
2025-12-08 03:16:00 +00:00
Warner Losh
7fe881e87b loader: Note current autoboot_delay behavior
Some time ago, the boot loader stopped polling for a key press during
the kernel and module loading prior to the transition to lua. Inspection
of the code shows the polling is no longer there. Document the change.

Sponsored by:		Netflix
2025-11-26 21:43:11 -07:00
Warner Losh
3c857567c1 stand: Rename ZFSSRC to SAZFSSRC to avoid confusion
ZFSSRC is abiguous on its surface and too clos to ZFSTOP, so rename it
to SAZFSSRC.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D53901
2025-11-24 17:50:26 -07:00
Warner Losh
05346243df stand: Move from OZFS to ZFSTOP
Use ZFSTOP instead of OZFS. They are the saame thing.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D53900
2025-11-24 17:35:46 -07:00
John Baldwin
46d05a49a1 loader.efi.8: Minor formatting nits
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
- Add several missing .Pp after lists and literal blocks.

- Fix the column widths for the console table and use a shorter indent
  so that it doesn't wrap on an 80-col display.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D53866
2025-11-22 08:10:20 -05:00
Gordon Bergling
6f14b6025a stand/lua: Fix two typos in the manual pages
- s/Additionnaly/Additionally/
- s/commmand/command/

MFC after:	3 days
2025-11-19 15:23:07 +01:00
Warner Losh
c62eaf8af9 stand: Update riscv efi booting to edk2 includes
Update to include the right includes for the riscv protocol to get the
hypervisor details.

Note: I expanded the GUID inline rather than using a #define because
there was none. This is only listed in UefiCpuPkg/UefiCpuPkg.dec, so
include it here inline until we can automate using those files.

Fixes:		43b8edb320
Sponsored by:	Netflix
2025-11-16 22:58:03 -07:00
Warner Losh
60f14d05d2 edk2: Fix fdt build
x86 doesn't use FDT things by default, but aarch64 does. I thought I'd
built the loader on aarch64 to test the EDK2 all the things series, but
apparently not. This fixes the aarch64 build.

Fixes:		43b8edb320
Sponsored by:	Netflix
2025-11-16 16:55:14 -07:00
Warner Losh
43b8edb320 stand: Cut over to using the EDK2 files
Remove the old EFI SDK files that we've been nursing along for too many
years. Replace them with files from EDK2 edk2-stable202502 and tweak the
interfaces we need to tweak. Mostly include different things or change
the names of the protocols that no longer have old-school compat names.

I gave up in the middle of env.c, too damn tedious to find all those new
GUIDs. Also, many of the guids were mystery meat, most likely from the
EDK2 sources, but just not the Include subdirectory. Need to investigate
those. And the memory info? Is it just an oboslete thing, or embedded
knowledge of EDK2.

Delete the now-redundant copies of things in Guid and Protocol. I
debated keeping ZeroGuid.h, but EDK2 has moved on from when I snagged it
years ago (or maybe I just invented it out of whole cloth: edk2 does
radically different things today and I didn't do the git deep-dive to
find out).

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D53655
2025-11-16 11:29:03 -07:00
Warner Losh
84dc74b827 stand: switch the loader over to using efi-edk2.h
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D53652
2025-11-16 11:29:03 -07:00
Warner Losh
87795c6e95 stand: Rename EFI_ERROR_CODE to DECODE_ERROR to avoid Edk2 Clash
This follows what Illumos has done.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D53656
2025-11-16 11:29:02 -07:00
Alexander Ziaee
6fb0d67819
loader.8: Document module commands
Begin documenting module loader commands in loader(8), where the reader
would look for them. Segregate them by their availability in individual
loader implementations, like build(7) targets.
These details were graciously donated by kevans.

MFC after:		3 days
Reviewed by:		kevans
Co-authored-by:		Kyle Evans <kevans@freebsd.org>
Differential Revision:	https://reviews.freebsd.org/D50727
2025-11-14 10:00:16 -05:00
Alexander Ziaee
09ffaa4e07
loader manuals: Clarify console and boot_serial
console=comconsole is for the loader and boot_serial is for the kernel.

I think we should centralize documentation on the loader settings in one
manual, such a loader.8. The current proliferation is not obvious where
to find the documentation. To the user, these are all set in loader.conf
or at the loader prompt.

MFC after:		3 days
Differential Revision:	https://reviews.freebsd.org/D53695
2025-11-14 09:45:14 -05:00
Warner Losh
d18ed8e19c stand: Try to parse vdisk correctly
PR:			289306
Sponsored by:		Netflix
Reviewed by:		dab
MFC After:		5 days
Differential Revision:	https://reviews.freebsd.org/D52500
2025-11-10 17:56:11 -07:00
Mark Johnston
4d6801a6b5 stand: Teach the zfs loader about dynamic gang headers
There is a pool feature, dynamic_gang_header, that is enabled by default
in new pools.  When this feature is active, gang headers may be larger
than 512 bytes.  The loader needs to be taught to cope with that.

Try using the vdev ashift to pick the gang block header size.  If the
checksum fails, fall back to the old gang block header size.

This is based on a patch by Paul Dagnelie, with testing, bug-fixing and
some simplifications from me.

PR:		289690
Co-authored by:	Paul Dagnelie <paul.dagnelie@klarasystems.com>
Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53578
2025-11-06 16:02:33 +00:00
Lexi Winter
842942be28 packages: Remove the /boot hack from mtree-to-plist.awk
Currently, files in /boot (other than /boot/kernel) are assigned to the
bootloader package using a filename match in mtree-to-plist.awk.  This
causes some problems, most notably that debug info for userboot ends up
in the utilities-dbg package instead of bootloader-dbg.

Remove the path handling from mtree-to-plist and instead set PACKAGE
in the appropriate Makefiles to put these in the correct package.

While here, move userboot*.so from bootloader-dev to bootloader.

MFC after:	3 days
Reviewed by:	cperciva
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53179
2025-10-26 02:22:47 +00:00
Robert Clausecker
90fa789cfa sys/crypto: import md5c.c C rewrite
The reimplementation is a bit cleaner than the original code,
although it is also slightly slower. This shouldn't matter too
much as we will have asm code for the major platforms.

The code is unrolled when built in the kernel or user space, but
not when in libsa, as to reduce the code size.

Differential Revision:	https://reviews.freebsd.org/D45670
Reviewed by:	jrtc27, imp
Approved by:	markj (mentor)
MFC after:	1 month
2025-10-24 12:16:58 +02:00
Robert Clausecker
73a9b273d3 sys: move sys/kern/md[45].c to sys/crypto
Both files are used by kernel and userspace.
Move them to sys/crypto where they belong.

No functional changes intended.

In preparation of D45670.

Reviewed by:	markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D52909
2025-10-24 12:16:46 +02:00
Ryan Libby
c2fa94ad08 stand/i386: quiet gcc -Warray-bounds
GCC has started to warn about memory accesses under address 0x1000.
Tweak it to 0x400 for stand/i386 to avoid warnings for access to BIOS
data area memory and above but still retain most of the warning value.

Reviewed by:	dab, imp
Differential Revision:	https://reviews.freebsd.org/D53036
2025-10-16 23:49:22 -07:00
Alexander Ziaee
de36d0dbae
cli.lua.8: Reflow literal comments
Reflow comments in literal text blocks
so this manual is legible at MANWIDTH 78.

MFC after:	1 day
2025-10-09 17:13:54 -04:00
Olivier Certner
d3bfcd6640
libsa: smbios: Detect less-than-64-bit platforms via __SIZEOF_SIZE_T__
What we really want here is to know if pointers can refer to 64-bit
addresses, regardless of whether they also hold other information (such
as capabilities in CHERI).  __SIZEOF_SIZE_T__ is probably the closest
indication to that piece of information, so let's use it.  __ILP32__
wasn't wrong in practice though, as we don't support 32-bit CHERI
hardware (and likely never will).

Consistently with this change, test whether we can actually address the
64-bit SMBIOS's structure table by converting the end address to
'size_t' and checking whether its value is preserved.

Suggested by:   jhb (for the __ILP32__ => __SIZEOF_SIZE_T__ part)
Reviewed by:    jhb, imp
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49318
2025-10-07 10:14:41 +02:00
Kyle Evans
b11a5709ec flua: kick out the remaining builtin modules
Bootstrap flua has some magic now to handle modules by building them in
and discovering them via linker sets.  This is slightly cleaner than
always building them in and baking them into loadedlibs for both
bootstrap and system flua.

Adjust the stand build now that these three libs have their own new
homes.

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D51891
2025-10-03 21:16:51 -05:00
Kyle Evans
d4c973fa14 Revert "flua: kick out the remaining builtin modules"
This reverts commit 80ada95900, because
bootstrap flua is about to get backed out.
2025-10-03 19:53:28 -05:00
Kyle Evans
80ada95900 flua: kick out the remaining builtin modules
Bootstrap flua has some magic now to handle modules by building them in
and discovering them via linker sets.  This is slightly cleaner than
always building them in and baking them into loadedlibs for both
bootstrap and system flua.

Adjust the stand build now that these three libs have their own new
homes.

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D51891
2025-10-03 13:09:25 -05:00
Warner Losh
ebc32e74b6 core.lua: Consistently check for single user
While boot_single:lower() should always be in {yes,no}, it might not
be. In one place we check == yes, and another ~= no. Make both places ~=
no for consistency. We generally try to test != default.

Sponsored by:		Netflix
2025-09-28 19:45:01 -06:00
Warner Losh
b7473a5d68 loader: make disable-device more rebust
Check the number of arguments and ensure that the passed-in device to
disable parses correctly.

Sponsored by:		Netflix
2025-09-28 19:45:01 -06:00
Warner Losh
55025f42f6 stand: Remove support for FreeBSD 12.2 and earlier
Remove 'pager' shim that was last not supported in FreeBSD 12.2, which
went EOL on March 31, 2022. People have had enough time to upgrade the
boot loader.

Sponsored by:		Netflix
2025-09-28 19:45:00 -06:00
Alexander Ziaee
a37825313f
stand/man: Fix mdoc typos for emails, tag spdx
MFC after:	3 days
2025-09-18 13:20:01 -04:00
kpowkitty
c8b87aa10d loader: Move ACPI RSDP detection
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1843
2025-09-13 20:24:19 -06:00
Warner Losh
8a4e4c9524 loader.efi: Properly scope variable
guid here is only used for EFI_ZFS_BOOT, so move the ifdef.

Noticed by: wosch and clang 20
Sponsored by:		Netflix
2025-09-13 09:46:25 -06:00
Toomas Soome
ed19c4ff84 loader.efi: improve StartImage error message
StartImage() may return additional data from failure. This data
has text message followed by optional binary blob. Print
out the text message (if present) and free the data.
See 7.4.2 EFI_BOOT_SERVICES.StartImage() page 199
UEFI_Spec_Final_2.11.pdf.

Reviewed by:	imp
2025-09-11 18:47:53 +03:00
Ahmad Khalifa
80661e2153 loader/efi: fix non-x86 build
Pointy hat to:	vexeduxr
Reported by:	Bakul Shah
2025-09-10 10:48:20 +03:00
Ahmad Khalifa
101a35e84d efi: translate errno to EFI status on exit
Translate the given errno to an efi status instead of always exiting
with EFI_LOAD_ERROR.
2025-09-09 20:19:59 +03:00
Ahmad Khalifa
18141961df loader/efi: remove is_last parameter from find_currdev
It is unused.

Reviewed by:	tsoome
Differential Revision:	https://reviews.freebsd.org/D52434
2025-09-09 20:19:55 +03:00
Ahmad Khalifa
b4c5d5827f loader/efi: plug memory leak
Reviewed by:	tsoome
Differential Revision:	https://reviews.freebsd.org/D52433
2025-09-09 20:19:50 +03:00
Ahmad Khalifa
cd9b43edd5 loader/efi: return error from efi_find_framebuffer
Also return actual errno values in other code paths.
(suggested by tsoome)

Reviewed by:	tsoome, imp
Differential Revision:	https://reviews.freebsd.org/D52432
2025-09-09 20:19:33 +03:00
Ahmad Khalifa
7d48a56205 stand: remove unused variables 2025-09-09 20:19:24 +03:00