Commit graph

2029 commits

Author SHA1 Message Date
Toomas Soome
79a0d14fa0 loader: dosfs fails to access directory data with large cluster number
fsize is using 2 bytes for cluster number, but with fat32 we
actually do have 4 bytes and with large disks the high bytes will be in use.

illumos issue: https://www.illumos.org/issues/16821

Sponsored by:	MNX Cloud, Inc.
MFC after:	1 week
2024-10-03 16:51:59 +03:00
Tatsuki Makino
4fa4693dcd btx: Align the PXE prompt with other options
To fit within in the same space, drop the newline before the PXE
prompt to make room for the additional space character.

PR:		281494
2024-09-30 15:41:42 -04:00
Kyle Evans
e7a629c851 libmd, kern, stand: consolidate md5 implementations (NFC)
Reduce the number of md5c.c between the three of these from two to one
by just reaching into the kernel build for both userland builds.  The
precedent for this already exists for sha2 in both cases.

_libmd_ symbol privatization bits have been moved to sys/md5.h and
md5.h remains to #include <sys/md5.h> for compatibility.

This stops exporting MD5Pad() in the process because the kernel stopped
exporting it in 502a35d60f.  soversion is bumped accordingly.

This also renames the libc version of stack_protector.c; it previously
only worked by coincidence because .PATH ordering worked out such that
we got the right one, but this is not the case anymore.  Remove the
landmine.

PR:		280784 (exp-run)
Reviewed by:	allanjude, delphij
Differential Revision:	https://reviews.freebsd.org/D34497
2024-09-29 22:34:18 -05:00
Warner Losh
604919c47f loader: Fix 0 vs 1 confusion for column numbers
In two places we use '0' for a column number. However, the upper left
hand corner of the screen is 1, 1. Fix those two confusions. Also, fix
a comment that flipped the coordinates in a comment (I'm used to the
vt100 convention where it's row, column (eg y, x)) and didn't notice
the rest of the code uses x, y.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D46777
2024-09-24 14:18:42 -06:00
Warner Losh
3fb656f8ef loader: Use printc instead of print to fit in 24,80
print automatically adds a newline, while printc does not. Use printc in
preference to print for managing the autoboot message. This means we can
use line 24 safely on a 24x80 terminal, restoring some functionality
that was lost in 101afbc6ee.

Note: we still set the default curosor position to 25,1 in screen.lua,
but real VT100s (and successors) will treat any row larger than the
pnumber of rows in a cursor motion command to be the last physical row
(this is so you can move to 9999,9999 and do a cursor location query to
get the size of the screen). Keeping that as is looks better on a
typical VGA console.

Fixes: 101afbc6ee
Sponsored by: Netflix
Reviewed by: kevans
Differential Revision:	https://reviews.freebsd.org/D46771
2024-09-24 10:57:11 -06:00
Dimitry Andric
f97c7fdc59 Bump lld LINKER_FREEBSD_VERSION for reproducibility fix
The upstream fix to make lld output for our EFI loaders reproducible
again was committed in 54521a2ff9. Bump lld's LINKER_FREEBSD_VERSION
to be able to check this in the EFI loader Makefile.

MFC after:	3 days
2024-09-22 19:12:38 +02:00
Warner Losh
17cccb6f90 libsa: Fix a comment to be less vague
Be more specific about where this is used.

Sponsored by:		Netflix
2024-09-22 07:32:00 -06:00
Colin Percival
74a28cf6e7 loader: Load platform entropy even without menu
In 5c73b3e0a3 calls to core.loadEntropy were added to core.boot
and core.autoboot; but neither of those is invoked if we disable
the "beastie" menu.  Add a core.loadEntropy call to the no-menu
path.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Amazon
Fixes:	5c73b3e0a3 ("Add support for getting early entropy from UEFI")
Differential Revision:	https://reviews.freebsd.org/D46637
2024-09-22 00:35:48 -07:00
Colin Percival
c8ebbd28aa 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
MFC after:	1 week
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D46635
2024-09-22 00:35:48 -07:00
Colin Percival
925f15731e loader: Make pkcs5v2 unconditionally available
This was previously only available if GELI support was included, but I
want to use it for processing entropy from EFI

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D46634
2024-09-22 00:35:47 -07:00
Colin Percival
f4a69a933c loader: Make EFI entropy size configurable
Add a new loader variable entropy_efi_seed_size which defaults to 2048;
if not defined (e.g. if the /boot/lua/ is updated but /boot/defaults/
isn't) the same 2048 default will be used.

Reviewed by:	Val Packett
MFC after:	1 week
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D46632
2024-09-22 00:35:47 -07:00
Colin Percival
b58fe4eb29 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
2024-09-22 00:35:47 -07:00
Colin Percival
58ec2d0d4a loader: Add TSLOG to interpreter built-ins
Wrap each call to a built-in command with TSENTER/TSEXIT to make
it easier to see where time is going in the loader.

MFC after:	1 week
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D46630
2024-09-22 00:35:47 -07:00
Ahmad Khalifa
6fdb07d5b7 loader: provide error message in command_errmsg instead of printing
Also provide an error message when argc is too long instead of printing
"no error message".

Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1381
2024-09-21 05:25:16 -06:00
Ahmad Khalifa
a698c15a41 loader: remove unneeded variable
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1381
2024-09-21 05:25:16 -06:00
Ahmad Khalifa
c105113752 loader: actually change the staging slop
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1381
2024-09-21 05:25:15 -06:00
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