Commit graph

1706 commits

Author SHA1 Message Date
Warner Losh 9d2f548bbe 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 064fa628ce)
2024-02-06 17:12:40 -07:00
Dag-Erling Smørgrav 6ef4fc44f9 stand: Add 1440p to the list of known resolutions.
MFC after:	1 week
Reviewed by:	manu, kevans, imp
Differential Revision:	https://reviews.freebsd.org/D43391

(cherry picked from commit 7edbf69b79)
2024-02-01 18:46:13 +01:00
Warner Losh 5d7b049f99 Add kenv .Xr in kldload(8) and loader.conf(5)
Sponsored by:		Netflix

(cherry picked from commit 64db9a0f82)
2024-02-01 18:46:13 +01:00
John Baldwin 7da77f0266 Stop #defining FREEBSD_ELF
This was originally used (along with FREEBSD_AOUT) to prefer the use
of ELF in various tools instead of a.out as part of the a.out to ELF
transition in the 3.x days.  The last use of it was removed from
<link.h> in commit 66422f5b7a back in
2002, but various files still #define it.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42964

(cherry picked from commit 4a3cf5f329)
2024-01-04 16:28:53 -08:00
Kyle Evans 1b959537ed loader: lua: remove the default kernel if it doesn't exist
The `kernel` env var provides the default kernel, usually "kernel".  It
may be the case that the user doesn't have a "kernel" kernel, just
"kernel.*" kernels, but have left `kernel` to the default because we
autodetect entries by default anyways.

If we're doing autodetection, take note of whether the default kernel
exists or not and remove it from the list if it doesn't and we had found
any other kernels.  We avoid it in the #kernels == 1 case because
something fishy has likely happened and we should just trust the
configuration.

Reviewed by:	imp, manu
Differential Revision:	https://reviews.freebsd.org/D42967

(cherry picked from commit d04415c520)
2024-01-02 22:47:27 -06:00
Kyle Evans bafbd6445e loader: provide a features table for binary compatibility advertisement
liblua now provides a loader.has_feature() function to probe the loader
binary for features advertised.  name => desc mappings are provided in
loader.features to get a list of all of the features loader *can*
support.  core.hasFeature is provided as a shim to loader.has_feature
so that individual consumers don't need to think about the logic of the
loader module not providing has_feature; we know that means the feature
isn't enabled.

The first consumer of this will be EARLY_ACPI to advertise that the
loader binary probes for ACPI presence before the interpreter has
started, so that we know whether we can trust the presence of acpi.rsdp
as relatively authoritative.  In general, it's intended to be used to
avoid breaking new scripts on older loaders within reason.

This will be used in lua as `core.hasFeature("EARLY_ACPI")`, while the
C bits of loader will `feature_enable(FEATURE_EARLY_ACPI)`.

Reviewed by:	imp

(cherry picked from commit 1631382cf2)
2024-01-02 22:47:26 -06:00
John Baldwin 37ba303aa0 Trim various $FreeBSD$
Approved by:	markj (cddl/contrib changes)
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41961

(cherry picked from commit f53355131f)
2023-10-24 11:23:57 -07:00
John Baldwin de270f81b2 Purge more stray embedded $FreeBSD$ strings
These do not use __FBSDID but instead use bare char arrays.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41957

(cherry picked from commit eba230afba)
2023-10-24 11:13:18 -07:00
Kyle Evans babfcc0aa6 stand: lua: module names should permit more
The module entries should generally allow whatever is allowed as an
env_var in the pattern table.  Notably, we're missing periods which
would allow proper entries for .dtb files in loader.conf that don't need
to specify a module_name entry for it.

%d in this expression is actually redundant as %w is actually
"all alphanumerics," but I've included it for now to match the env_var
entry.  We should really remove it from both.

Reported by:	"aribi" on the forums via allanjude@

(cherry picked from commit 5bc1e0c228)
2023-09-11 17:02:38 -05:00
Warner Losh 0f015abc46 Remove $FreeBSD$: one-line forth tag
Remove /^\\[\s*]*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit 26a58599a0)
2023-08-23 11:43:34 -06:00
Warner Losh a7385d2a90 Remove $FreeBSD$: two-line lua tag
Remove /^--\n--\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit 9636a14538)
2023-08-23 11:43:33 -06:00
Warner Losh 350f9ac5b3 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit 05248206f7)
2023-08-23 11:43:33 -06:00
Warner Losh b144e70a33 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit fa9896e082)
2023-08-23 11:43:31 -06:00
Warner Losh 023fc80ee3 Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit d0b2dbfa0e)
2023-08-23 11:43:30 -06:00
Warner Losh d103702541 Remove $FreeBSD$: one-line .S pattern
Remove /^\s\.(asciz|ident)\s+\"\$FreeBSD\$\".*\n/

Similar commit in main:
(cherry picked from commit b1cfcffa89)
2023-08-23 11:43:27 -06:00
Warner Losh 3d497e17eb Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in main:
(cherry picked from commit 1d386b48a5)
2023-08-23 11:43:26 -06:00
Warner Losh 8ad303d68c Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/

Similar commit in main:
(cherry picked from commit 2a63c3be15)
2023-08-23 11:43:23 -06:00
Warner Losh 34041aac83 Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/

Similar commit in main:
(cherry picked from commit 42b388439b)
2023-08-23 11:43:22 -06:00
Warner Losh 17da660ad5 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

Similar commit in main:
(cherry picked from commit b3e7694832)
2023-08-23 11:43:21 -06:00
Warner Losh 58bc4f0c2f generate-hfs.sh: don't embed $FreeBSD$ in generated code
Sponsored by:		Netflix

(cherry picked from commit bed13771a3)
2023-08-23 11:43:18 -06:00
Marius Strobl aa63608809 base: Remove support for the VTOC8 partitioning scheme
The removal of the sparc64 support in February 2020 obsoleted the
VTOC8 partitioning scheme as no other FreeBSD platform makes use
of it. Moreover, the code is bitrotting as nothing defines e. g.
LOADER_VTOC8_SUPPORT any more and, thus, should go now, too. With
this change, the following commits are reverted as far as VTOC8
is concerned and parts haven't already previously been deleted
along with prior sparc64 removals:
094fcb157d
a7d366e958
ba8d50d08b

The alignment example d9711c28ef
added to the VTOC8 section of gpart.8 is folded into the MBR one.

This should finally conclude the deorbit of sparc64-specific bits.

        We had joy, we had fun
        we ran Unix on a Sun.
        But that source and the song
        of FreeBSD have all gone.

Credits to Michael Bueker for the original "Unix on a Sun" and Rod
McKuen for the "Seasons in the Sun" lyrics.

(cherry picked from commit 4ef1c6f75d)
2023-08-06 19:49:05 +02:00
Warner Losh caa41f6417 spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix

(cherry picked from commit 4d846d260e)
2023-07-25 09:13:49 -06:00
Alfonso Gregory 679ff7a0c5 bug: efi_print_global only checks for the first 5 letters of "Driver"
As a result, it is only really checking for the word Drive, making
"Drive" appended to anything else considered for efi env.

Reviewed by:	imp, kevans

(cherry picked from commit 39ae24e3bf)
2023-07-11 10:05:31 -05:00
Mark Johnston 753f15c24f loader.efi: Fix some arm64 PE metadata
- Mark the file as an executable in the COFF header.
- Provide separate .text and .data sections.
- Provide sane file and section alignment values.  These values are the
  defaults defined in the PE specification.
- Set appropriate characteristics for each of .text and .data.

This is required for the MS devkit to load our UEFI image.

Obtained from:	OpenBSD via allanjude
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D37765

(cherry picked from commit 21d56b7966)
2023-05-29 09:12:55 -04:00
John Baldwin 7b9e747546 libsa: Disable -Wdangling-pointer for zfs.c.
GCC 12 warns about a dangling pointer to 'objid' in
zfs_bootenv_initial().  However, this appears to be a false positive
as the pointer to 'objid' is only passed to zfs_lookup_dataset() but
not saved anywhere that outlives the lifetime of the
zfs_bootenv_initial() function.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37533

(cherry picked from commit 0163de282e)
2023-05-02 17:03:01 -07:00
Kyle Evans 362677cae8 loader: comconsole: don't unconditionally wipe out hw.uart.console
It may be the case that we need to set hw.uart.console manually in some
scenarios that comconsole can't necessarily support.  Avoid clobbering
hw.uart.console unless we've actually selected comconsole so that one
could at least get kernel console output..

Discussed with:	imp
Sponsored by:	Zenith Electronics LLC
Sponsored by:	Klara, Inc.

(cherry picked from commit ec671f4980)
2023-04-26 12:30:19 -05:00
Gordon Bergling f8bab2c0fe stand: Remove a double word in a source code comment
- s/value value/value/

(cherry picked from commit 66095010d1)
2023-04-23 07:14:54 +02:00
Dimitry Andric 01bdf9acd2 libsa: make single bit bitfields unsigned to avoid clang 16 warning
Clang 16 introduced a warning about single bit bitfields in structs,
which is triggered by a declaration in libsa's tftp.c:

    stand/libsa/tftp.c:382:20: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                                    h->islastblock = 1;     /* very short file */
                                                   ^ ~
    stand/libsa/tftp.c:432:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    h->islastblock = 1;     /* EOF */
                                   ^ ~

Signed one-bit bitfields can only have values -1 and 0, but the intent
here is to use the field as a boolean, so make it unsigned.

MFC after:	3 days

(cherry picked from commit 1a3ccb8f15)
2023-04-22 10:58:48 +02:00
Cyrus Rahman f0cb734509 loader: lua: disable autoboot timer after password entry
In the lua loader, if one sets a password in loader.conf, the
autoboot_delay timer will start before the menu is displayed.  One can
interrupt the autoboot and bring up the menu by entering a keyboard
character before the timer expires.

If this is done a prompt for the password is displayed.  Entering the
password will bring up the menu, but the timer will again start and
another keyboard character must be entered or autoboot will abort the
menu and boot the system.

PR:		265472
Reviewed by:	kevans
MFC after:	3 days

(cherry picked from commit 0ab68e9272)
2023-04-19 23:15:15 -05:00
Cyrus Rahman 7e5811f76b loader: lua: unload the kernel when changing BEs
Usually the kernel is loaded later, but there are circumstances where it
could have been loaded earlier than changing BEs.  Unload anything that
is already there so that we know we're using artifacts from the proper
environment.

PR:		265471
Reviewed by:	kevans
MFC after:	3 days

(cherry picked from commit d7584aa09f)
2023-04-19 23:15:15 -05:00
Michael Paepcke 3464fc5f2a stand: fix build userboot without zfs
Fix regression in building userboot -DWITHOUT_LOADER_ZFS

Fixes: e307eb94ae
MFC After: 3 days
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/665

(cherry picked from commit 4d59545d0c)
2023-02-27 19:58:03 -07:00
Ed Maste 06d74a746e lua: reduce diffs between luaconf.h copies
Upstream luaconf.h is contrib/lua/src/luaconf.h.dist, while userland lua
and loader lua have copies in lib/liblua/luaconf.h and
stand/liblua/luaconf.h.

Adjust whitespace, VCS tags, etc. to match upstream's version, for ease
of comparison.

Reviewed By:	imp
Sponsored By:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38206

(cherry picked from commit ec96506307)
2023-02-20 09:21:08 -07:00
Warner Losh 402df99daa stand: Update mfc notes
Using some automation I found a few mistakes in my earlier list and also
a change merged without a cherry-pick -x (and evidentally changed as
well, since git log --cherry didn't know it had been merged). Fix them
so I can use this list with my experimental mfc script.

Sponsored by:		Netflix

This is a direct commit to stable/13
2023-02-20 09:21:08 -07:00
Mitchell Horne a2b4abce0e loader: always install help files
Address two issues with current help file logic:

The existing condition prevents the common help file from being
installed when there are no additional help files defined. This results
in no loader.help on EFI platforms, for example.

Second, due to the fact that we build and install multiple loader types,
each successive install will clobber the previous loader.help. The
result is that we could lose type-specific commands, or possibly list
them in loaders that do not have such commands.

Instead, give each loader type a uniquely named help file. The EFI
loader will look for /boot/loader.help.efi, userboot will look for
/boot/loader.help.userboot, etc. The interpreter variant has no effect
on which help file is loaded.

This leaves the old /boot/loader.help unused.

Some credit for the final approach goes to Mathieu <sigsys@gmail.com>
for their version of the fix in https://reviews.freebsd.org/D22951.

PR:		267134
Reported by:	Daniel O'Connor <darius@dons.net.au>
Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28591

(cherry picked from commit 8859960436)
2023-02-15 12:44:21 -04:00
Toomas Soome 4b2322bba1 efiserialio: use port settings (sio->Mode) for initial setup
Use serial port setup done by system firmware.
ARM64 Hyper-V does hung if we attempt to override the defaults,
therefore we should default to use settings from firmware.

Tested by: schakrabarti@microsoft.com
PR:		266248
MFC after:	1 week

(cherry picked from commit c243de11cf)
2023-02-10 09:37:49 +02:00
Emmanuel Vadot 86957b873f loader: md: Use default func for fmtdev and parsedev
The default function are enough for md so use them instead of the
disks ones that doesn't work for it anymore.

Reviewed by:	imp
Sponsored by:	Beckhoff Automation GmbH & Co. KG
MFC after:	now
Differential Revision:	https://reviews.freebsd.org/D38218

(cherry picked from commit 04afa8cc37)
2023-01-27 19:07:13 +01:00
Warner Losh ef72e52e8e stand/mips: retire BERI boot loader
The folks that created the BERI boot loader no longer need it. They've
long since moved on to other research platforms. Since BERI loader
contains yet another copy of code that I've consolodated; and since it's
impossible to test this platform; and since there are no users, retire
it completely to ease future MFCs.

OK'd by:	brooks@
Sponsored by:	Netflix

This is a direct commit to stable/13
2023-01-25 11:33:20 -07:00
Warner Losh 20840247bc stand: updated MFC info.
This is a direct commit to stable/13
2023-01-25 11:26:44 -07:00
Warner Losh d428dcc996 stand/mips64: Make beri loader compile
The devdesc reorgs in main were done after mips was deleted. Make the
minimal changes to beri's devicename.c needed after that. I have no
ability to test this, however, so it builds with similar warnings to
before all my MFC changes.

This is a direct commit to stable/13
2023-01-25 08:21:04 -07:00
Warner Losh 8c7293a0ea stand: update mips uboot to uboot reorg
uboot reorg in main happened after the mips support was removed. Go
ahead and do the same reorg here. Move the mips files from mips/uboot to
uboot/arch/mips. Move mips/uboot/Makefile to
uboot/arch/mips/Makefile.inc and cut out the common lines. Split uboot
target into uboot and uboot.bin to better fit into reorg.

This is a direct commit to stable/13
2023-01-25 08:21:04 -07:00
Warner Losh 54112db5c4 stand/uboot: Remove -fPIC here
When needed, -fPIC is added in defs.mk. While not in main, mips on
stable/13 can't tolerate it. Remove it here.

MFC After:		now (it's a build issue)
Sponsored by:		Netflix

(cherry picked from commit 4410e85796)
2023-01-25 08:21:04 -07:00
Warner Losh a72d533769 stand: mfc notes
MFCing stand is getting complicated. This file contains notes about
merging from 14, in summary:
o UFS changes have already been merged.
o The ZFS changes, on the whole, cannot be merged because OpenZFS
  versions are different.
o MIPS is still present in 13, so commits to tear down mips
  support.
o Some of the 14 GELI changes depend on crypto changes not yet merged.
o One change bumped the version to 14.x, and that shouldn't be merged.

The hashes listed should not be merged, unless something changes.

This is a direct commit to stable/13.
2023-01-24 21:40:22 -07:00
Warner Losh b02419fc40 Revert "mips: remove saf1761"
Mips is still in stable/13, so this should not have been merged.

This reverts commit 622ab2c483.

Sponsored by:		Netflix
2023-01-24 21:00:23 -07:00
Warner Losh b08ee04492 Revert "Bump the FreeBSD kernel version in kernel boot shim."
This should not have been merged.

This reverts commit 8cc2156f85.

Sponsored by:		Netflix
2023-01-24 20:56:41 -07:00
Warner Losh 1f1a1568a7 Revert "stand: remove mips support"
This change slipped through my checks, and should not have been merged.
mips is still supported in stable/13.

This reverts commit e006859bce.
2023-01-24 20:54:38 -07:00
Warner Losh 3ececb0f35 stand: dev can't be NULL in default_prasedev
We pass in the address of a variable to store this value always in the
only place that calls this function, so there is no need to test for NULL.

Sponsored by:		Netflix
Notied by:		tsoome in D38041

(cherry picked from commit 4883f347f6)
2023-01-24 14:49:47 -07:00
Warner Losh f9ab67f200 kboot: Use standard set_currdev
Use the standard set_currdev instead of the (now very old) copy of
setting currdev and loaddev directly. We do this only when we don't go
find the ZFS pool to boot from.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D38012

(cherry picked from commit eb1795782c)
2023-01-24 14:49:47 -07:00
Warner Losh 0b569fe671 kboot: Add hostdisk override
When hostdisk_override is set, all the /dev devices are hidden, and only
the files in that directory are used. This will allow filesystem testing
on FreeBSD without root, for example. Adjust the parse routine to not
require devices start with /dev (plus fix a leak for an error
condition). Add a match routine to allow the device name to be something
like "/home/user/testing/zfsfoo:" instead of strictly in /dev. Note:
since we need to look at all the devices in the system to probe for ZFS
zpools, you can't generally use a full path to get a 'virtual disk' at
this time.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D38011

(cherry picked from commit b7ecfa195f)
2023-01-24 14:49:47 -07:00
Warner Losh eaed7ff9d0 kboot: Fetch hostfs_root and bootdev from the environment
Fetch bootdev from the environment variable (so it should be set on the
command line). Default to 'zfs:' which will in the future look for the
first zpool that we can boot from. Prior versions of kboot would set
this from the second argument on the command line.

Fetch hostfs_root from the environment (defaulting to '/'). Prior
versions of kboot would set this from the first arg on the command line.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D38010

(cherry picked from commit 4f3be6b8d9)
2023-01-24 14:49:47 -07:00
Warner Losh d11df0599d kboot: Add ZFS support build glue
Now that all the pieces are in place, allow kboot to be built with ZFS
support.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D38009

(cherry picked from commit 42e37d8caf)
2023-01-24 14:49:47 -07:00