Commit graph

1986 commits

Author SHA1 Message Date
Warner Losh 195a96f0b3 stand: Stop building in fat, ext2fs, gzip and bzip to BIOS /boot/loader
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, amd64, amd64) (push) Waiting to run
This saves space to allow pxeboot to work again. Users desiring these
features can turn them on for their custom build. While these are useful
for some specialized applications, they aren't needed to boot the
typical system, and we're low on space.

          text    data     bss      dec       hex   filename
Before: 465866   20740   31612   518218   0x7e84a   loader_lua.bin
After:  441535   17484   31092   490111   0x77a7f   loader_lua.bin

Savings: 28,107 bytes

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D42416
2024-07-24 21:15:28 -06:00
Warner Losh e9ac41698b Remove residual blank line at start of Makefile
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, amd64, amd64) (push) Waiting to run
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Kyle Evans 41c233dec6 Prepare some build fixes in advance of more _FORTIFY_SOURCE
ZFS' libspl needs to be made aware that we have strlcat(3) and
strlcpy(3) to avoid some more complicated declaration duplication, so
go ahead and define these HAVE_ macros now.

libprocstat has to define `_KERNEL` and include kernel headers in order
to get what it wants, but this results in sys/cdefs.h being included too
late and we pick up the build breaking version of the __RENAME
definition.  Just explicitly include sys/cdefs.h earlier rather than
disabling _FORTIFY_SOURCE.  The zfs/ subdir only builds an object that
holds some structures and sizes, so just disable _FORTIFY_SOURCE there
entirely rather than trying to move #define _KERNEL into the file..

While we're here, make sure that we disable _FORTIFY_SOURCE in the
bootloader because we don't have the symbol renaming support today to do
it as cleanly as we'd like.  ssp/ssp.h needs to be pulled into the libsa
environment so that other bits can understand that ssp is disabled in
the consistent __SSP_FORTIFY_LEVEL way that we try to do.

Reviewed by:	allanjude (previous version), markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45676
2024-07-13 00:16:23 -05:00
Emmanuel Vadot 00460cc8c5 loader: Load a splash screen if "splash" variable is defined
Load a splash screen that vt(4) can use if the "splash" env variable is defined.
For now only png is supported and decoding is done in loader and not in kernel
compared to splash screen support in sc(4).

For using this add:
boot_mute="YES"
splash="/boot/images/freebsd-logo-rev.png"
in loader.conf

Differential Revision:	https://reviews.freebsd.org/D45932
Reviewed by:		imp, tsoome
Sponsored by:		Beckhoff Automation GmbH & Co. KG
2024-07-11 08:47:30 +02:00
Emmanuel Vadot 887062c1da stand: Fix logo alpha
The alpha wasn't done properly and some white stripes could be seen.

Differential Revision:	https://reviews.freebsd.org/D45933
Reviewed by:	imp. tsoome
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-07-10 08:11:30 +02:00
Ahmad Khalifa 1dbbce9744 loader.conf.5: Correct terminal size
Signed-off-by: Ahmad Khalifa <ahmadkhalifa570@gmail.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1292
2024-07-08 17:31:02 -06:00
Ahmad Khalifa 3b68c491d3 efi_console: Stay inline with the UEFI spec
The UEFI spec states that the minimum garunteed terminal resolution is
80x25.

Signed-off-by: Ahmad Khalifa <ahmadkhalifa570@gmail.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1292
2024-07-08 17:29:32 -06:00
Ahmad Khalifa ab08da5328 loader: Increase buffer size to accommodate longer commands
The longest command we have is "efi-autoresizecons". That combined with
the two spaces before and after the command gives us a total of 23
characters including the null-terminator.

Also move the two trailing spaces to their own pager_output call so they
don't get truncated if the command is too long and increase the minimum
string length to 20 in order to fix alignment issues caused by the
increased buffer size.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1277
2024-06-27 18:40:15 -06:00
Kyle Evans 3da568710f stand: module: unlink the entire tail when dependencies fail to load
Assume you have loader configured to load linux64, which has a
dependency on both linux_common and mqueuefs but neither the kernel
nor kernel config in question have the mqueuefs module included.

When the load command for linux64 fails to find mqueuefs, it will
free both linux64 and linux_common as they were loaded first, but only
linux64 gets removed from the module list.  As a result, future
traversals hit an easy use-after-free with linux_common.

Fix it so that we unlink the entire tail of the list.  Anything after
the initially loaded module is, by definition, a dependency on the
loaded module while we're still in the load command, so we can just
discard the entire tail.  If linux_common were loaded before linux64, it
should not move to a position during this load where it would suddenly
be missing from the view presented to the kernel.

Reported by:	philip
Reviewed by:	imp, philip, tsoome
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45731
2024-06-25 15:32:08 -05:00
John F. Carr cadc9c7db7 boot/efi: Fix warning for non-standard formats when debugging
Add -Wno-format for zfs_module and regroup. This fixes warnings when
EFI_DEBUG is defined.

PR: 279071
Reviewed-by: imp
2024-06-14 11:11:05 -06:00
Warner Losh 4fd5b8aed8 boot1.chrp: Include memset
Normally, memset isn't used. However for OPT_INIT_ALL=zero it is. Always
include it since we're not space constrained and latter-day loaders won't
include a copy if it's not actually used.

Reviewed by: emaste
Sponsored by: Netflix
2024-06-14 09:34:05 -06:00
Ahmad Khalifa 5360d017be loader: Fix G overflowing for G(4) on 32-bit builds
Prevent G(4) and over from overflowing for 32-bit builds.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098
2024-05-29 08:37:17 -06:00
Ahmad Khalifa dcc7b3698d loader: Allow overriding NEWVERSWHAT
This can be useful when making alternate versions of the loader.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098
2024-05-29 08:29:30 -06:00
Andrew Turner 82854693ae arm64: Allow userspace to be built with PAC and BTI
Add the WITH/WITHOUT_BRANCH_PROTECTION build flags. This can be used
to enable the use of pointer authentication (FEAT_PAuth) and branch
target identification (FEAT_BTI) in userspace.

The kernel already handles both of these is userspace, we just need
to enable it.

Leave disabled for a short period for this to settle before enabling.

Reviewed by:	emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D42596
2024-05-22 17:02:26 +00:00
Andrew Turner 8e82c5e28d stand/kboot: Fix the linker script OUTPUT_FORMAT
ld.bfd doesn't understand elf64-aarch64 but does have
elf64-littleaarch64. Switch to this so we can link kboot with it.

While here switch to the single format version. We are unlikely to
support booting from a big-endian Linux.

Reviewed by:	imp, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45258
2024-05-22 08:17:52 +00:00
Andrew Turner 9f44638ef2 stand/efi: Fix for binutils when targeting arm64
When linking with ld.bfd it complain with the following:

/usr/local/bin/aarch64-unknown-freebsd14.0-ld: start.o: relocation
 R_AARCH64_ABS32 against `__data_size' can not be used when making a
 shared object

Fix this by marking the __data_size with ABSOLUTE. This returns a
non-relocatable value which appears to be the same behaviour of lld.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45257
2024-05-22 08:17:26 +00:00
Warner Losh c7581d76a1 loader: fix stupid typos
Sponsored by:		Netflix
2024-05-19 23:04:18 -06:00
Warner Losh 861f802b3e textvidc: Reindent
Since this is now 'new code' go ahead and reindent for modern project
preferences.

Sponsored by:		Netflix
2024-05-19 22:05:43 -06:00
Warner Losh 4cddd20e1e loader/ofw: Style(9) pass over return statements
Make these consistent. Some files weren't even consistent with
themselves. Make them all either return <space> ( <value> ); or
return;

Sponsored by:		Netflix
2024-05-19 22:05:43 -06:00
Warner Losh 3f012b9508 loader: stlye(9) nit: Space between return and the value
Sponsored by:		Netflix
2024-05-19 22:05:43 -06:00
Warner Losh 2d425b634f loader: c_init returns 0 or 1
c_init returns 0 (success) or 1 (failure). Don't return other values.

Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 125b181674 userboot: Use C99 Initializers for each of the consoles here
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 1f180d0a40 ofw: Use C99 initializers for the console struct
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 6e28b4aa15 uboot: Use c99 initializers for the console struct
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh b3551da9cd efi_console: Use c99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 5e7b0cd93a i386/nullconsole: Use C99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh 803060b217 i386/spinconsole: Use C99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh a578e2b896 boot/i386: Use C99 initializer for textvidc
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh f989ebd4de kboot: Use C99 initialiers for hostconsole.
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh 0111f09ca6 kboot: Initialize hostfs_root sooner (and remove kboot.conf)
Move the initialization of hostfs_root to be a bit sooner. While it
doesn't matter for the default case, we may want to use hostfs files
sooner.

Also, while we're here, remove kboot.conf. It duplicates the command
line and has proven difficult to use. It will be replaced by an early
script that can influence the state of the boot loader before we select
a device to boot from (including strongly suggesting which one to boot
from).

Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh 68344c9c6c loader: separate lang init from scripting init
Create interp_preinit() to initialize the scripting language to run
scripts. Make sure you can call it multiple times, but only the first
one has effect, After it's call, you can run scripts in the scripting
language. At the moment, no functional change.

Sponsored by:		Netflix
2024-05-19 22:05:40 -06:00
Warner Losh 1d7bdae9ca kboot: Move console, acpi and smbios init
Move the console probing to as early as possible. There's no real
support for anything but hostcons, and setting it up early will show
other error messages.

ACPI and SMBIOS probing can be done just after we have the console, so
move it there. This allows other parts of the early code to use info
from that, as well as overriding and env vars set by these things on the
command line (smbios data may be wrong during initial development phases
as the automated way to populate per-board data may not be established,
etc).

Sponsored by:		Netflix
2024-05-19 22:05:40 -06:00
Warner Losh e63d20b70e stand: Spell LUA_COMPILE_SET correctly.
MFC After: 2 days
Sponsored by:		Netflix
2024-05-11 12:09:51 -06:00
Warner Losh 75e5f5916e boot1.efi: Don't redundantly include devpath.c
devpath.c is on both the comand line and in libefi. This is redundant
and was a mistake in 4cf36aa101. It never should have been here. In
practice, this just means that the devpath.o from libefi.a goes unused.
This will cause problems with some upcoming changes (D44872) to enable
LTO to reduce the size of the binaries, so go ahead and make the change
now to reduce the changeset for that. No functional change indended.

Fixes:		4cf36aa101
Co-authored-by:	sobomax
Sponsored by:	Netflix
2024-05-07 08:53:50 -06:00
Stephen J. Kiernan 46b606c8fd userboot: support environment and symlinks in test application
Pass the environment on to the loader.
Also define USERBOOT=1 in the environment varables.

Add support for symlinks in the test application open callback.

stat the root directory when opening file
Without this, running "ls" command on the root directory encounters
issues getting the directory listing.

Reviewed by:	jhb
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D44625
2024-04-30 16:40:18 -04:00
Warner Losh cfcf475a66 stand: Install gptboot.efi(8)
We need to include bsd.init.mk first when we have man pages in the boot
loader.

Sponsored by:		Netflix
2024-04-05 16:53:47 -06:00
Stephen J. Kiernan 112783ebbc userboot: allow for overriding the version file location
Use ?= when assigning VERSION_FILE

Reviewed by:	imp
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D44624
2024-04-03 19:09:43 -04:00
Stephen J. Kiernan fe429e6794 stand/efi: Changes to efichar to allow it to be used in the kernel
Replace malloc/free with EFICHAR_MALLOC and EFICHAR_FREEE macros.

Obtained from:	Juniper Networks, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44541
2024-03-28 14:09:37 -04:00
Ed Maste 3bd637afbd boot0: remove reference to fdisk
fdisk is obsolete and there is no need to mention a specific tool used
to update the partition table.  Just refer to it as the MBR partition
table.

Sponsored by:	The FreeBSD Foundation
2024-03-25 15:59:09 -04:00
Simon J. Gerraty a8eb3b365e loader.4th dictthreshold too small
The dictthreshold in stand/forth/loader.4th is too small
resulting in full dictionary.

Reviewed by:	stevek, imp
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D44414
2024-03-18 16:16:29 -07:00
Simon J. Gerraty 01f3abbfcd uboot/Makefile move BINDIR
Set BINDIR before we include bsd.init.mk
so we can override it via local.init.mk

Reviewed by:	imp
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D44413
2024-03-18 16:14:15 -07:00
Warner Losh 462af7676b kboot: kbootfdt: fix error handling
If we are able to open /sys/firmware/fdt, but aren't able to read it,
fall back to /proc/device-tree. Remove comment that's not really true,
it turns out.

Sponsored by:		Netflix
2024-03-11 15:21:52 -06:00
Warner Losh d75524b3fe kboot: Use is_linux_error to check mmap return error
Rather than checking against the (incorrect) -511, use the
is_linux_error() function to check to see if host_mmap failed.

Sponsored by:		Netflix
2024-03-11 15:21:52 -06:00
Warner Losh a9cd3b675e kboot: Print UEFI memory map
If we can read the UEFI memory map, go ahead and print the memory map.
While the kernel prints this with bootverbose, having it at this stage
is useful for debugging other problems.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D44287
2024-03-11 15:21:52 -06:00
Warner Losh d650c3efb6 kboot: hostfs -- check for llseek failure correctly
The host_* syscalls are all raw Linux system calls, not the POSIX
wrappers that glibc / musl create. So we have to ranage change the
return value of host_llseek correctly to use the negative value hack
that all Linux system calls use.

This fixes a false positive error detection when we do something like
lseek(fd, 0xf1234567, ...); This returns 0xf1234567, which is a negative
value which used to trigger the error path.  Instead, we check using the
is_linux_error() and store the return value in a long. Translate that
errno to a host errno and set the global errno to that and return
-1. lseek can't otherwise return a negative number, since it's the
offset after seeking into the file, which by definition is positive.

This kept the 'read the UEFI memory map out of physical memory' from
working on aarch64 (whose boot loader falls back to reading it since
there are restrictive kernel options that can also prevent it), since
the physical address the memory map was at on my platform was like
0xfa008018.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D44286
2024-03-11 15:21:51 -06:00
Warner Losh 8b1925f29c kboot: Avoid UB in signed shift
offset is signed. Copy it to the unsigned res before shifting. This
avoids any possible undefined behavior for right shifting signed
numbers. No functional change intended (and the code generated is the
nearly same for aarch64).

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D44285
2024-03-11 15:21:51 -06:00
Warner Losh 3ae18fdfbc kboot: Create function for error checking.
Linux has the convention of returning -ERRNO to flag errors from its
system calls. Sometimes other negative values are returned that are
success...  However, only values -1 to -4096 (inclusive) are really
errors. The rest are either truncated values that only look negative (so
use long instead of int), or are things like addresses or legal unsigned
file offsets or similar that are successful returns. Filter out the
latter.

Sponsored by:		Netflix
2024-03-11 15:21:51 -06:00
Warner Losh 552f3072af loader/lua: Remove workaround for command_error
loader.command_error was available prior to stable/12 branching. No need
to check if it is available or not.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D44144
2024-02-29 10:58:59 -07:00
Warner Losh ab97d42add loader/lua: Remove compat shim for loader.lua_path
loader.lua_path was committed before stable/13 was branched, and merged
in to for 12.2. Remove workaround for it not being present.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D44143
2024-02-29 10:58:52 -07:00
Warner Losh 8b9178cd0d loader/lua: Remove pager shim
Just after 12.2 and before the stable/13 branch, kevans added lpager.c
to provide a pager interface for commands written in lua.  It was merged
into 12.3. Now that 12.2 is long since EOL, we can remove the pager shim
here. Nobody needs that old loader + new lua scripts.  Plus only one
command is affected.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D44142
2024-02-29 10:58:43 -07:00