Commit graph

2013 commits

Author SHA1 Message Date
Graham Perrin
45001ab45e loader.efi.8: BOOOTX64.EFI: fix typo
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1412
2024-09-21 05:25:15 -06:00
Ahmad Khalifa
b538d49110 Add a new sysctl in order to diffrentiate UEFI architectures
With the new 32-bit UEFI loader, it's convenient to have a sysctl to
figure out how we booted. Can be accessed at machdep.efi_arch

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098
2024-09-20 08:45:09 -06:00
Ahmad Khalifa
f8ca5d45c3 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
2024-09-20 08:45:08 -06:00
Ahmad Khalifa
6818ff7797 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
2024-09-20 08:45:07 -06:00
Ahmad Khalifa
95f75b0e6e loader: Fix shadow_fb allocation
Using AllocateMaxAddress here means that gfx_state->tg_shadow_fb is
treated as the highest address we can receive. Since
gfx_state->tg_shadow_fb is NULL, we never receive anything. Use
AllocateAnyPages instead.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098
2024-09-20 08:45:06 -06:00
Ahmad Khalifa
f0d5b1bdf0 stand/efi: Add a 32-bit variant of libefi
In preparation for supporting 64-bit machines with 32-bit UEFI firmware,
add a 32-bit variant of libefi since we need to compile both the 64-bit
version and the 32-bit version at the same time.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098
2024-09-20 08:45:05 -06:00
Stephen J. Kiernan
e47161e5f1 loader: update dependencies for dirdeps build
Add dependencies for MK_FDT and MK_FORTH knobs
Update dependencies for MK_LOADER_LUA knob
2024-09-18 11:22:34 -04:00
Baptiste Daroussin
7899f917b1 flua: move modules source into the main source directory
Follow the path of what is done with bsnmp, build the modules along
with the main binary, this allows to build the modules at a moment
where all needed libraries are already built and available in the
linker path instead of having to declare all the libraries which a
flua module will be linked to in _prebuild_libs.

Discused with:	markj
Reviewed by:	markj, jrtc27, kevans, imp
Accepted by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D46610
2024-09-12 09:03:44 +02:00
Jessica Clarke
18f7683e0d loader.efi.8: Remove rogue duplicated lines
Fixes:		871911a4ab ("loader.efi(8): beef up the updating the ESP")
MFC after:	1 week
2024-09-03 21:14:44 +01:00
Ed Maste
1b9cfd6a62 stand: bump arbitrary build date to 2024-01-01
For build reproducibility we set PE headers to an arbitrary timestamp.
Nothing in FreeBSD uses this timestamp, but bump it from 2016 to 2024 so
that the timestamp does not seem "too old" in case some third party tool
is used to inspect EFI boot components.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46527
2024-09-03 15:09:28 -04:00
Warner Losh
871911a4ab loader.efi(8): beef up the updating the ESP
There's a huge variety of situations when booting with UEFI. Document
more of them, hopefully better.

Feedback from: jrtc27
MFC After: 3 days
Sponsored by:		Netflix
2024-08-26 17:19:59 -06:00
Warner Losh
101afbc6ee loader/menu: tweak for added line
I added a line to the menu, but didn't adjust so things were a
line off. Make the necessary adjustments.

Fixes: 7cb65be96d
Sponsored by: Netflix
MFC After: 3 days
2024-08-22 17:28:51 -06:00
Dimitry Andric
f5ce3f4ef5 Fix EFI loader reproducibility with lld
When the various loaders under stand/efi are built, the resulting
binaries differ over multiple runs, even if WITH_REPRODUCIBLE_BUILD is
used. This is caused by lld multithreading and the custom linker scripts
for the loaders, and affects the following binaries:

* loader_4th.efi
* loader_4th.sym
* loader_4th.sym.full
* loader_lua.efi
* loader_lua.sym
* loader_lua.sym.full
* loader_simp.efi
* loader_simp.sym
* loader_simp.sym.full

Work around this by disabling lld threading for these binaries.

Reviewed by:	emaste
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D46271
2024-08-12 15:31:02 +02:00
Warner Losh
e1a6d93155 pxeboot: Enforce a 500k limit here
Have a separate PXEBOOTSIZE variable that acts much like LOADERSIZE
variable to limit the size of the loader used for pxeldr. This allows
people to override it independently of LOADERSIZE, which they may need
to set larger for other reasons. Combined with PXEBOOT_DEFAULT_INTERP,
you can build a larger lua loader, while still being able to build pxeldr
with the 4th one, for example.

MFC After:   	  	3 days
Sponsored by:		Netflix
Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D46214
2024-08-06 17:22:36 -06:00
Warner Losh
f4762e9135 pxeboot: Allow a different default loader for pxeboot
Sometimes you need / want a different boot loader than loader_lua for
pkeldr. Provide an option to get either the 4th one or the simp one.

MFC After:		3 days
Sponsored by:		Netflix
Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D46213
2024-08-06 17:22:36 -06:00
Warner Losh
20d35d5817 loader: Add WITH/WITHOUT_LOADER_PXEBOOT build option
Make it possible to disable pxeboot. This loader will fail to build when
it's too large. When /boot/loader needs to be larger like that, this
options will disable a component whose build will fail. It is an explicit
option rather than implicit when things are too large to force the user to
make the explicit tradeoffs rather than wonder why they have a stale pxeboot
or other odd failure mode.

MFC After:		3 days
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D46212
2024-08-06 17:22:36 -06:00
Warner Losh
b45d64fd0c loader: Minor comentary tweak
Reword slightly to cleanup awkward constructs.

Sponsored by:		Netflix
2024-08-02 17:50:47 -06:00
Warner Losh
46ea2ffc3f stand: Reduce limit to 500k for x86 loader
The largest loader that works for PXE boot is about 500k. PXE needs low
memory for packets and other driver state, so the largest safe size for
the loader is about 500k. Reduce the size from 560k to 500k so we don't
accidentally break PXE in the future.

Add a comment for people with special needs. If you control the
hardware, it can be safe to have boot loaders as large as 580k or 600k
in some cases. Since the BIOS loader is becoming more and more of a
legacy item, the build variable LOADERSIZE isn't documented. This change
doesn't change that: there's been little demand for this documentation
and in general, users shouldn't change it lightly.

PR: 257018
Sponsored by: Netflix
2024-08-01 15:30:26 -06:00
Warner Losh
7cb65be96d stand: Use correct loader needs to be updated code
Use the correct loader code that adds an inactive highlighted menu item
indicating that an update is needed.

My laptop is the only machine that I have a boot menu. I'd debugged the
menu part there, but had all the other changes, including my original
menu code, on my server and hadn't copied it back before pushing.

Fixes: 0eac99f76e
Sponsored by: Netflix
2024-07-29 20:26:11 -06:00
Warner Losh
0eac99f76e stand: Add "Loader needs updating" to the first menu item"
When the boot loader version is too old, add a warning to the boot menu
to maybe catch people's attention.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D45890
2024-07-29 16:57:37 -06:00
Warner Losh
a2fd7ae879 stand: Print a warning of the loader is too old
If the loader is < 3.0, print a warning that it's too old and needs to
be upgraded.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D45889
2024-07-29 16:57:30 -06:00
Warner Losh
9f7f905075 loader: Bump all versions to 3.0
Each incompatible change we make, we bump the major version. We've not
done the bump in a while, so sync everybody to 3.0. Anything older than
3.0 will be given a warning that their boot loader is too old. We check
only the major version, though, so minor versions can still be bumped
for individual loaders (though I honestly doubt we'll ever need to do
that again).

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D45888
2024-07-29 16:57:22 -06:00
Warner Losh
809edb3636 Revert "loader/lua: Remove workaround for command_error"
This reverts commit 552f3072af.

loader.command_error was added just after 11.2, but appears to not have
been back ported to 11.x. 11.0 was the first lua loader release, so keep
this compat shim until we sort out what to do.

MFC After:		3 days
Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D45883
2024-07-29 16:57:13 -06:00
Warner Losh
522a65a8d9 Revert "loader/lua: Remove compat shim for loader.lua_path"
This reverts commit ab97d42add.

There's too many people in the field with FreeBSD 12.0 loader.efi that
stubbed their toe on upgrading to 14.1 since they'd not updated
loader.efi. While we sort out that mess, add back this workaround.  Can
revisit after 14.2 maybe.

MFC After: 		3 days
Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D45882
2024-07-29 16:57:04 -06:00
Warner Losh
b38a82c77a Revert "loader/lua: Remove pager shim"
This reverts commit 8b9178cd0d.

Really old loader.efi files persist in the field. Revert this to support
it. We need to support this through at least 14.2 now, alas.

MFC After:		3 days
Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D45881
2024-07-29 16:56:55 -06:00
Warner Losh
65300ca729 stand: Kill commented out line
This line is no longer needed as fallback, and should have been deleted
in 7870a52598 instead of commented out, but 26 years later, I have a
high degree of confidence that old change was right and we won't need
this line as a fallback.

Sponsored by:		Netflix
Reviewed by:		kevans, jhb
Differential Revision:	https://reviews.freebsd.org/D45880
2024-07-29 16:56:48 -06:00
Warner Losh
8165650389 stand: Remove obsolete junk
We long ago changed newvers.sh to make these comments bogus.  Remove
them since every single one of them is broken after the $FreeBSD$
removal.

Sponsored by:		Netflix
Reviewed by:		kevans, jhb
Differential Revision:	https://reviews.freebsd.org/D45879
2024-07-29 16:56:28 -06:00
Warner Losh
195a96f0b3 stand: Stop building in fat, ext2fs, gzip and bzip to BIOS /boot/loader
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
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