Commit graph

1946 commits

Author SHA1 Message Date
Warner Losh 7fc95c31f0 loader: Simplify the loader.has_command
luaL_checkstring already checks for the right number of
arguments. There's no need to do that by hand here. Now an exception
will be thrown like any other function with the wrong args. Also,
push a boolean instead of an int.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43820
2024-02-15 20:59:22 -07:00
Warner Losh a27c1350e4 loader: Make vidc_biosputchar static
It's currently unused outside of vidconsole.c. Gerald Hicks' fix to the
beep code from de37e4a6d2333/1998 introduced the funciton as
static. Maxim Sobolev (sobomax) made it non-static since his spinconsole
called it in c4c3b35172d67/2009. When sobomax dropped the direct call
after making spinconsole console independent in b35172d67/2017,
vidc_biosputchar remained a harmless unreferenced global. Make it static
once again.

Fixes:		c7e10205ae
Sponsored by:	Netflix
2024-02-14 11:22:57 -07:00
Warner Losh 62a52c1542 loader: export the CMD_ constants in loader table
Export the CMD_OK, etc constants in the loader table. They are the
return values of loader.perform, etc.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43821
2024-02-14 10:55:38 -07:00
Warner Losh cd147a2a02 loader: Fetch initial script from loader_lua env
Sometimes it is nice to override the initial script that we run. Make it
possible by fetching loader_lua from the env and using that instead of
the default if prsent.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43819
2024-02-14 10:55:38 -07:00
Simon J. Gerraty f616d61ab6 libsecureboot do not report expected unverified files
By default only report unverified files at severity VE_WANT
and above.  This inlcudes *.conf but not *.hints, *.cookie
or *.tgz which get VE_TRY as their severity.

If Verbose is set to 0, then VerifyFlags should default to 0 too.
Thus the combination of

	module_verbose=0
	VE_VEBOSE=0

is sufficient to make the loader almost totally silent.

When verify_prep has to find_manifest and it is verified ok
return VE_NOT_CHECKED to verify_file so that it can skip
repeating verify_fd

Also add better debugging output for is_verified and add_verify_status.

vectx handle compressed modules

When verifying a compressed module (.ko.gz or .ko.bz2)
stat() reports the size as -1 (unknown).
vectx_lseek needs to spot this during closing - and just read until
EOF is hit.

Note: because of the way libsa's open() works, verify_prep will see
the path to be verified as module.ko not module.ko.bz2 etc.  This is
actually ok, because we need a separate module.ko.bz2 entry so that
the package can be verified, and the hash for module.ko is of the
uncompressed file which is what vectx will see.

Re-work local.trust.mk so site.trust.mk need only set
VE_SIGN_URL_LIST (if using the mentioned signing server)

interp.c: restrict interactive input

Apply the same restrictions to interactive input as for
unverified conf and hints files.

Use version.veriexec when LOADER_VERIEXEC is yes

Reviewed by:	kevans
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43810
2024-02-12 14:35:01 -08:00
Warner Losh 621dae89f3 loader: Document the lua loader table.
Document all the public functions from the "loader" table.

Sponsored by:		Netflix
Reviewed by:		pauamma_gundo.com, tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D43701
2024-02-10 11:49:09 -07:00
Warner Losh 064fa628ce 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
2024-02-04 14:09:48 -07:00
Warner Losh 18968b8274 loader: Move build_font_module to gfx_fb.c
The font module is part and parsel of the gfx_fb support. Move it to
gfx_fb.c where it can access the data it needs.

Sponsored by:		Netflix
2024-02-02 14:01:04 -07:00
Warner Losh 784f925e50 loader: Font module is EFI dependent
The font module is part of the gfx_fb support. Since we share this file
between EFI and kboot, we only want to pass the font data to the kernel
when we're booting from EFI, not kboot.

Sponsored by:		Netflix
2024-02-02 14:01:04 -07:00
Warner Losh fd577b59b2 libsa: Move hash functions up a level
This should have no functional change. Move compiling the sha256, sha512
and md5 hash functions up into libsa to allow them to be used elsewhere
in the boot loader when geli isn't configured. Since libsa is a .a, these
won't wind up in any boot loader that doesn't reference them, so should
be a nop.

Sponsored by:		Netflix
2024-02-02 14:01:03 -07:00
Warner Losh 7c8b126c1a libsa: Move include file creation to the end of the Makefile
The include file symblic links, etc are out of place where they
are. Move them to the end of the file. No functional change intended.

Sponsored by:		Netflix
2024-02-02 14:01:03 -07:00
Stéphane Rochoy c475e61f66 stand/lua: always allow overriding with local config files
Loader now also read configuration files listed in local_loader_conf_files.
Files listed here are the last ones read. And /boot/loader.conf.local was
moved from loader_conf_files to local_loader_conf_files leaving only
loader.conf and device.hints in loader_conf_files by default.

The idea is to ensure local_loader_conf_files, i.e., /boot/loader.conf.local,
can always be used to override other user defined settings.

So the sequencing is now as follow:

 1. Bootstrap:
     /boot/defaults/loader.conf

 2. Read loader_conf_files files:
     /boot/device.hints
     /boot/loader.conf

 3. Read loader_conf_dirs files:
     /boot/loader.conf.d/*.conf

 4. And finally, rread local_loader_conf_files files:
     /boot/loader.conf.local

Reviewed by: imp, kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/759
2024-02-02 12:04:57 -07:00
Stéphane Rochoy c343eedc6d stand/lua: per-product conf if requested via product_vars
If product_vars is set, it must be a space separated list of environment
variable names to walk through to guess the product. Each time a product can be
guessed (i.e., the corresponding variable is defined), prepend
/boot/loader.conf.d/PRODUCT/ to loader_conf_dirs.

It can be typically used as follow:

    smbios.system.planar.maker="PLANAR_MAKER"
    smbios.system.planar.product="PLANAR_PRODUCT"
    smbios.system.product="PRODUCT"
    uboot.m_product="M_PRODUCT"
    product_vars="smbios.system.planar.maker smbios.system.planar.product smbios.system.product uboot.m_product"

to read files found in the following directories, in that order:

    /boot/loader.conf.d/PLANAR_MAKER
    /boot/loader.conf.d/PLANAR_PRODUCT
    /boot/loader.conf.d/PRODUCT
    /boot/loader.conf.d/M_PRODUCT

Reviewed by: imp, kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/759
2024-02-02 12:04:57 -07:00
Warner Losh 994865caf2 Revert "stand/lua: per-product conf if requested via product_vars"
This reverts commit 754cac4b28. No mail
went out and commit message was wrong.

Sponsored by:		Netflix
2024-02-02 12:04:57 -07:00
Warner Losh 5fdf01dbee Revert "stand/lua: always allow overriding with local config files"
This reverts commit d3d0b73557. no mail
sent out, and the commit message was wrong.

Sponsored by:		Netflix
2024-02-02 12:04:57 -07:00
Stéphane Rochoy d3d0b73557 stand/lua: always allow overriding with local config files
Loader now also read configuration files listed in local_loader_conf_files.
Files listed here are the last ones read. And /boot/loader.conf.local was
moved from loader_conf_files to local_loader_conf_files leaving only
loader.conf and device.hints in loader_conf_files by default.

The idea is to ensure local_loader_conf_files, i.e., /boot/loader.conf.local,
can always be used to override other user defined settings.

So the sequencing is now as follow:

 1. Bootstrap:
     /boot/defaults/loader.conf

 2. Read loader_conf_files files:
     /boot/device.hints
     /boot/loader.conf

 3. Read loader_conf_dirs files:
     /boot/loader.conf.d/*.conf

 4. And finally, rread local_loader_conf_files files:
     /boot/loader.conf.local
2024-02-02 11:58:28 -07:00
Stéphane Rochoy 754cac4b28 stand/lua: per-product conf if requested via product_vars
If product_vars is set, it must be a space separated list of environment
variable names to walk through to guess the product. Each time a product can be
guessed (i.e., the corresponding variable is defined), prepend
/boot/loader.conf.d/PRODUCT/ to loader_conf_dirs.

It can be typically used as follow:

    smbios.system.planar.maker="PLANAR_MAKER"
    smbios.system.planar.product="PLANAR_PRODUCT"
    smbios.system.product="PRODUCT"
    uboot.m_product="M_PRODUCT"
    product_vars="smbios.system.planar.maker smbios.system.planar.product smbios.system.product uboot.m_product"

to read files found in the following directories, in that order:

    /boot/loader.conf.d/PLANAR_MAKER
    /boot/loader.conf.d/PLANAR_PRODUCT
    /boot/loader.conf.d/PRODUCT
    /boot/loader.conf.d/M_PRODUCT
2024-02-02 11:57:52 -07:00
Warner Losh 8f7327dcee kboot: update copyright on these files.
host_syscalls.c: I've written, so put Netflix copyright on. It's
possible in the confusion that Nathan wrote the host_gettimeofday
implementation.

syscall_nr: These files likely can't enjoy copyright protection since
they are just facts (the per-arch Linux system calls), so add a note
they are in the public domain.

Sponsored by:		Netflix
2024-01-28 13:04:32 -07:00
Warner Losh 2b7918f13c kboot: Assert copyright here
According to git blame I've 95%+ rewritten this file. Update copyright to
reflect that, but give nod to Nathan for the original I started with.

Sponsored by:		Netflix
2024-01-28 13:04:32 -07:00
Warner Losh 36ef238cb6 kboot: Move termios to libkboot
Sponsored by:		Netflix
2024-01-28 13:04:31 -07:00
Warner Losh 2e3f49888e kboot: Move system calls to libkboot
Sponsored by:		Netflix
2024-01-28 13:04:31 -07:00
Warner Losh 099335814d kboot: Move syscall stubs to libkboot
Sponsored by:		Netflix
2024-01-28 13:04:31 -07:00
Warner Losh 4aabaa1890 kboot: Cleanup libkern reference
For aarch64 and amd64, we don't pull in anything from libkern, so we
don't need it in our path.  However, powerpc needs ucmpdi2 from libkern,
so bring it into libkboot's build and omit it from loader.kboot.

Sponsored by:		Netflix
2024-01-28 13:04:31 -07:00
Warner Losh a03411e847 kboot: Move _start out of kboot and into libkboot
Move the startup code from kboot/kboot to kboot/libkboot and add the
necessary infrastructure for it to build. move start_arch.h, a private
header for libkboot, over as well.

Sponsored by:		Netflix
2024-01-28 13:04:31 -07:00
Warner Losh 091c255b5b kboot: Move to kboot/kboot
In anticipation of separating the library elements from the kboot
prorgam elements, move kboot down a level into a subdirectory. There
will be libkboot and include directories in subsequent commits,
mirroring other subsystems like i386 and efi.

Sponsored by:		Netflix
2024-01-28 13:04:31 -07:00
Warner Losh dcc20bced5 stand: Use modern function definitions
Use modern function definitions for functions with no args.

Sponsored by:		Netflix
2024-01-28 13:04:31 -07:00
Dag-Erling Smørgrav 7edbf69b79 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
2024-01-23 15:20:27 +01:00
Jose Luis Duran ed76a9506a stand: Fix typo (triple S)
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/955
2023-12-27 20:24:31 -07:00
Warner Losh 64db9a0f82 Add kenv .Xr in kldload(8) and loader.conf(5)
Sponsored by:		Netflix
2023-12-20 21:17:38 -07:00
Kyle Evans d04415c520 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
2023-12-13 10:52:14 -06:00
John Baldwin 4a3cf5f329 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
2023-12-12 15:30:00 -08:00
Kyle Evans e183039f08 loader: lua: assume late ACPI detection if the feature isn't enabled
While we're here, enable the feature in the places we detect ACPI.  This
lets us side-step the existing issues and provide a path forward for
folks upgrading from previous releases that haven't updated their ESP
yet.

Let's also fix core.setACPI: the hint already indicates that the
user's disabled it more consistently than loader.acpi_disabled_by_user.
Even more, the latter is wrong because we set it by default if we did
not detect ACPI.  The ACPI hint remains even when we're setting defaults
because ACPI loaded into the kernel will make some noise if it's not
hinted off, even when we didn't detect it.

imp notes that this will result in some relatively harmless noise on
platforms that don't support ACPI but aren't using the UEFI loader, as
we would enable the ACPI module for loading on them and then loader
would not be able to find it.  These are non-fatal, but should probably
be fixed by just declaring support for EARLY_ACPI in those loaders since
we know they won't have ACPI early on -- punting on this for the time
being, though, in favor of providing a safer upgrade path sooner.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42727
2023-12-08 15:43:59 -06:00
Kyle Evans 1631382cf2 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
Differential Revision:	https://reviews.freebsd.org/D42695
2023-12-08 15:43:19 -06:00
Warner Losh c596126a5d pmbr: Only load the first 545k rather than error out
It would be nice to have larger boot partitions for ESPs to live in one
day. It's trivial to carve out 5M 10M or 200M when provisioning, but
logistical issues may make it hard to do it after the fact. So only warn
when the partition is > 545k. If we ever grow the boot loader larger
than that, then it will be responsible for loading the rest anyway.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D42774
2023-11-27 15:45:56 -07:00
Warner Losh 7c43148a97 stand: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Warner Losh 6e28a6bc2e stand: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:29 -07:00
Warner Losh 67d2bd974d stand: Retire setting hw.ata.wc: it doesn't exist.
hw.ata.wc was disconnected as part ot the 2013 cam-ification of ata. No
need to continue setting it. It's been unused in FreeBSD 10.x and newer.

Sponsored by:		Netflix
2023-11-24 11:28:44 -07:00
Warner Losh 21795c374a stand: Retire setting hw.eisa_slots.
When the eisa code was removed in 2017, prior to the stable/12 branch,
setting hw.eisa_slots became a nop. The oldest supported branch doesn't
have eisa at all. The need to set it manually on boot disappeared
largely by 2000...

Sponsored by:		Netflix
2023-11-24 10:58:44 -07:00
Mateusz Piotrowski 8ec79e8ae0 loader.efi.8: Fix a typo
MFC after:	3 days
Sponsored by:	Klara, Inc.
2023-11-22 13:25:34 +01:00
Warner Losh 7a1bc422d1 stand/efi: Consolidate integer types
We have no need for 5 different copies of these.

Sponsored by:		Netflix
Reviewed by:		rcm, kevans, andrew
Differential Revision:	https://reviews.freebsd.org/D42699
2023-11-21 19:58:20 -07:00
Warner Losh e4789047ff stand/efi: Define ACPI_USE_SYSTEM_INTTYPES to be 1 instead of blank
To avoid a redefinition warning... This needs to be redone correctly,
but this gets amd64 building again...  My amd64 environment is polluted
with something that caues earlier failures which I ignored...

Fixes:		488bc7e9a7
Sponsored by:	Netflix
2023-11-21 11:38:46 -07:00
Warner Losh 488bc7e9a7 stand/efi: Request ACPI use the system inttypes
With the system inttypes, we build on all platforms again.

Suggested by:	andrew
Fixes:		0b01d45783
Sponsored by:	Netflix
2023-11-21 08:59:05 -07:00
Warner Losh 0abe05aeac stand: bandaide for acpi
Old binaries do not set acpi.rsdp early enough. So when we boot with an
older loader.efi from an ESP that's not been updated, we assume there's
no ACPI on this system. This is unwise. Put a band-aide on this until we
can implement a proper 'feature' variable that the binary reports so we
can do conditionals for things like this in the future.

This is at best a rapid-response stop-gap.

Glanced at by: kevans
Sponsored by:		Netflix
2023-11-20 20:30:16 -07:00
R. Christian McDonald e0f3dc8272 loader: improve lua ACPI detection and handling
This is a follow-up patch to https://reviews.freebsd.org/D42459
that modifies the loader lua to use the correct loader variables
for determining ACPI availability.

This also fixes a bug where ACPI can be inadvertently disabled when
setting System Defaults at the loader menu.

Reviewed by:	imp, kevans
Approved by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42483
2023-11-20 14:03:59 -05:00
R. Christian McDonald 0b01d45783 loader: fix EFI ACPI detection
lua was previously unable to determine ACPI presence because this
probing was postponed until the final loading and execution of the
kernel.

This patch resolves that by detecting ACPI early (similar to
the order of operations in the legacy i386 loader).

Reviewed by:	kevans
Approved by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42459
2023-11-20 14:03:59 -05:00
Mark Johnston b247ff70e8 stand: Rename LIBFDT to LIBSAFDT
Preemptively address a collision with LIBFDT (to be added in the future)
from src.libnames.mk, which gets included via bsd.progs.mk.  No
functional change intended.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D42486
2023-11-07 09:57:32 -05:00
Benedict Reuschling 94eca4b5f3 loader.efi.8: Fix style warnings
This is a follow-up commit to bce728719e
to address mandoc(1) warnings.
2023-11-06 14:45:20 +00:00
Guido Falsi bce728719e Add paragraph documenting loader.env functionlity
Approved by:		docs (carlavilla)
Differential Revision:	https://reviews.freebsd.org/D42476
2023-11-06 13:21:53 +01:00
Alexander Motin c2588f5e06 stand/zfs: Remove one more read-compatible feature
This feature is marked as ZFEATURE_FLAG_READONLY_COMPAT and so
irrelevant for read-only pool imports by the loader:

	"com.delphix:spacemap_v2"

This should cause no functional changes, just a code cleanup.

I'm sorry, missed it in previous commit.

MFC after:	2 months
2023-11-04 13:07:31 -04:00
Alexander Motin 939a62d673 stand/zfs: Remove read-compatible features
These features are marked as ZFEATURE_FLAG_READONLY_COMPAT and so
irrelevant for read-only pool imports by the loader:

	"com.datto:resilver_defer",
	"com.delphix:obsolete_counts",
	"com.delphix:spacemap_histogram",
	"com.delphix:zpool_checkpoint",
	"com.intel:allocation_classes",
	"org.zfsonlinux:allocation_classes"

This should cause no functional changes, just a code cleanup.

MFC after:	2 months
2023-11-04 12:26:25 -04:00
Stephen J. Kiernan 2008043f38 loader: add target for dirdeps build
Update dependencies for the loader variations used for each
architecture.

Reviewed by:	sjg
Differential Revision:	https://reviews.freebsd.org/D39741
2023-11-02 19:35:08 -04:00
Stephen J. Kiernan e5b786625f dirdeps: Add missing dependency files
Some leaf directories were missing Makefile.depend files or needed
architecture-specific Makefile.depend.* files.
2023-10-29 17:08:29 -04:00
John Baldwin f53355131f Trim various $FreeBSD$
Approved by:	markj (cddl/contrib changes)
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41961
2023-10-10 10:34:43 -07:00
John Baldwin eba230afba 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
2023-09-25 07:54:56 -07:00
Gleb Smirnoff d13550f0c9 stand/loader.efi: fix regression with ignoring nvstore
To read/update the boot loader nvstore, we always need to call
zfs_attach_nvstore() regardless of whether we use bootonce key
in nvstore or the bootfs property of the pool.  The call was
unintentionally left in the block of code that is processed
only when bootonce key is present.

In particular this fixes broken 'nextboot -k'.

Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D41795
Fixes:			e3e2681d0e
2023-09-11 11:04:48 -07:00
Kyle Evans 5bc1e0c228 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@
MFC after:	1 week
2023-09-04 21:28:11 -05:00
Ed Maste 4722ceb7d5 Use 115200 bps by default for serial communication
9600 was a standard baud rate decades ago, but 115200 is now more common
so choose defaults that are useful to the largest number of users.

Note that boot0sio does not support rates above 9600 so it remains
unchanged.

Reviewed by:	bz, imp, manu
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36295
2023-08-17 13:31:38 -04:00
Warner Losh 26a58599a0 Remove $FreeBSD$: one-line forth tag
Remove /^\\[\s*]*\$FreeBSD\$.*$\n/
2023-08-16 11:55:43 -06:00
Warner Losh 9636a14538 Remove $FreeBSD$: two-line lua tag
Remove /^--\n--\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:30 -06:00
Warner Losh 05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh b1cfcffa89 Remove $FreeBSD$: one-line .S pattern
Remove /^\s\.(asciz|ident)\s+\"\$FreeBSD\$\".*\n/
2023-08-16 11:54:57 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Warner Losh bed13771a3 generate-hfs.sh: don't embed $FreeBSD$ in generated code
Sponsored by:		Netflix
2023-08-16 01:24:40 -06:00
Ed Maste 34d55be074 boot0: add a note about BIOS-supported serial rates
We plan to increase the default serial rate to 115200 (see review
D36295) but early boot components that use BIOS interfaces do not
support higher rates.  Add a note to that effect.

Reported by:	imp
Sponsored by:	The FreeBSD Foundation
2023-08-15 18:45:58 -04:00
Jessica Clarke 106c9ff5ac stand: Export _start on arm like other architectures
By not exporting _start, we get various warnings of the form:

  ld: warning: cannot find entry symbol _start

Note that in practice these don't matter because we manually construct
our PE header and use objcopy -O binary, so the entry point is set to
whatever we put explicitly in the PE header, but we should still do the
right thing and silence these warnings.

This was found in CheriBSD, where bsd.prog.mk has similar logic to
bsd.lib.mk and sets -Wl,--(no-)fatal-warnings based on LD_FATAL_WARNINGS
(unlike FreeBSD which only does so in the latter).
2023-08-05 01:14:16 +01:00
Gordon Bergling 34db0134a6 kboot: Fix a typo in a source code comment
- s/descriptoin/description/

MFC after:	3 days
2023-08-02 11:35:50 +02:00
Marius Strobl 4ef1c6f75d 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.
2023-07-26 13:16:12 +02:00
Alfonso Gregory 5762de7243 Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:17 -06:00
VexedUXR 3bf9e84f08 Stand: Silence undefined symbols check command
No need to print this...

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/786
2023-07-01 11:16:58 -06:00
John Baldwin b9f56cabed efi loader: Move 'module' variable under #ifdef MODINFOMD_MODULEP.
This quiets a set but unused warning on platforms without this module
info such as aarch64.

Differential Revision:	https://reviews.freebsd.org/D40672
2023-06-27 10:19:32 -07:00
VexedUXR 780332f1c1 loader.efi: Remove redundant error message
efi_copy_init already prints an error message (with more information) if it fails.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/777
2023-06-26 16:57:31 -06:00
Alfonso Gregory 39ae24e3bf 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
Pull Request:	https://github.com/freebsd/freebsd-src/pull/738
2023-06-22 22:31:58 -05:00
VexedUXR 6f6213ec90 Add comments for memory size
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/753
2023-06-12 08:57:20 -06:00
VexedUXR a8c1c0b727 Add boot1.efi to CLEANFILES
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/775
2023-06-12 08:41:22 -06:00
Gleb Smirnoff bbc64cf66c stand/boot1.efi: use the bootonce dataset as root dataset
Before this change we would only pass the bootonce dataset name
to the environment for the next loader, while actually reading
the next stage loader from the 'bootfs' dataset, not the bootonce
dataset.

Another problem fixed by this change is a boot from a configuration
when bootonce attribute is present, but 'bootfs' property is not set.

Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D40389
2023-06-08 11:14:45 -07:00
Gleb Smirnoff e3e2681d0e stand/loader.efi: read zfs bootonce attribute before checking currdev
First check if bootonce is configured and if it is, then change currdev
accordingly and after that do the sanity check.  This fixes boot in a
situation when ZFS pool doesn't have the "bootfs" property, but has
bootonce attribute set.  A strange, but legitimate case.

Reviewed by:		tsoome, imp
Differential Revision:	https://reviews.freebsd.org/D40388
2023-06-08 11:14:45 -07:00
Kyle Evans 9ed4ec4ae3 stand: libefi: avoid a null pointer deref in eficom
We don't keep comc_port around anymore if the console's not present, but
some things might still try to set one of the environment variables we
hook.  In particular, one need not even set efi_com_port/efi_com_speed
in loader.conf; loader may do it itself and induce the crash if ConOut
depicts an available uart.

Probably reported by:	dch
OK for now:	imp
2023-05-28 13:54:50 -05:00
Warner Losh 46927f6744 stand/efi/eficom: Free comc_port if we can't find the serial port
If we can't find the serial port, free comc_port and return early. The
serial port just isn't there.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D40223
2023-05-24 22:33:53 -06:00
Warner Losh e5d4e036f2 stand/efi/eficom: Make aarch64 compat code probe correctly
Make the compat code more correct by probing using the eficom console
structure, not the comconsole one.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D40222
2023-05-24 22:33:53 -06:00
Warner Losh 42b0b7a926 stand/efi/eficom: Don't allow this for !HYPERV machines
If the machine isn't hyperv on amd64, then this driver fails the probe
and will do nothing further now, even if explicitly listed in a config.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D40221
2023-05-24 22:33:53 -06:00
Warner Losh f28dff43ad stand/efi/eficom: better handling of absent device
Don't even have a comc_port when the port doesn't exist: always free it
if we probe that it's not there. Also, when it's not present, clear the
flags indicating presence to avoid disturbing other flags.

Sponsored by:		Netflix
Reviewed by:		tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D40220
2023-05-24 22:33:53 -06:00
Warner Losh 2efbc8e284 stand/efi/smbios: Move detection of smbios earlier.
It would be nice to make decisions early in boot, about maybe consoles,
based on smbios variables. Set them just after we setup the archsw so we
can use them everywhere.

Sponsored by:		Netflix
Reviewed by:		tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D40219
2023-05-24 22:33:53 -06:00
Toomas Soome f2b3bf5c4d libefi: add efi_devpath_next_instance()
UEFI device path may be path to one device, or concatenated list of instances
to different devices (textually represented as comma separated list).

Provide generic function to get next instance from device path.
Returns next instance or end node.

The use case is like:

EFI_DEVICE_PATH *node = (EFI_DEVICE_PATH *)buf;
while (!IsDevicePathEnd(node)) {
	process(node);
	node = efi_devpath_next_instance(node);
}

Where buf is pointing to either single device path or
concatenated list of device paths (such as from ConIn or ConOut).

Reviewers: imp
Differential Revision: https://reviews.freebsd.org/D40081
2023-05-13 15:16:10 +03:00
Ed Maste 48267a0a92 loader: restore userboot help file
Commit e32fecd0c2 intended to skip installing all but one copy of
each loader variant's help file, but accidentally skipped all copies for
the userboot help file.  (Other loaders install help files via the _simp
variant, but there is is no userboot_simp.)

PR:		271178
Fixes:		e32fecd0c2 ("loader: install help files only once")
Sponsored by:	The FreeBSD Foundation
2023-05-12 13:24:48 -04:00
Warner Losh 4d846d260e 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
2023-05-12 10:44:03 -06:00
Warner Losh c16e08e5f3 stand/efi: Retire i386 support
Remove the i386 ifdefs and files. It never worked.

Sponsored by:		Netflix
Reviewed by:		manu, tsoome, kevans
Differential Revision:	https://reviews.freebsd.org/D40012
2023-05-11 14:06:03 -06:00
Warner Losh 8c3d6917c1 stand: eficom: Only set baudrate when it changes
Only set the baudrate when it is different than what the device has
reported. In addition, pass in the args to effect no change to the other
parameters to the serial port. Some EFI firmware gets cranky when you
set them to the same value, so avoid doing so (we likely can remove the
HyperV workaround with this fix, but I kept it in place). Add comments
to the code for why we do this too.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D40010
2023-05-11 14:06:03 -06:00
Warner Losh cb2da74905 stand: eficom: Don't preemtively assume flow control
Remove rtsdtr_off. It's basically unused. Expand its meaning, but put
changing flow control to under an ifdef. We shouldn't set it unless
we're sure we need to do so. UEFI normally initializes the device
correctly, and we should avoid needless changes that aren't user
requested.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D40009
2023-05-11 14:06:03 -06:00
Warner Losh 66826fd54a stand: eficom : remove unused ignore_cd
Sponsored by:		Netflix
Reviewed by:	tsoome
Differential Revision:	https://reviews.freebsd.org/D40008
2023-05-11 14:06:03 -06:00
Warner Losh bab80c12a8 stand: Move eficom to libefi
Rename efiserialc to eficom.c and move it to libefi. Remove
loader.efi.h, since it's not needed. It's architecture independent
(though how we use it might vary). Drivers also belong in libfoo
in the boot loader: all the BIOS drivers are in i386/libi386 and
the console driver is in efi/libefi.

Sponsored by:		Netflix
Reviewed by:		tsoome
Differential Revision:	https://reviews.freebsd.org/D40007
2023-05-11 14:06:03 -06:00
Warner Losh 82cf061eba stand: Make non-matching console names OKer
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D39984
2023-05-11 14:06:03 -06:00
Warner Losh f93416d677 stand: add comconsole backwards compatibility shim for aarch64
Add a compat shim for the "comconsole" name so that people with a
"console=comconsole" in their loader.conf on aarch64 will continue to
work (though with a warning).

This is only aarch64: it will never be there for amd64 (where comconsole
always means talk to the hardware directly). To do that is too hard.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D39983
2023-05-11 14:06:03 -06:00
Warner Losh 2f131435bc stand: efi create eficom console device.
Fix the 'renaming kludge' that we absolutely cannot do going forward
(it's cost us days of engineering time).

console=comconsole talks to the hardware directly. This is available
only on amd64. It is not available anywhere else (and so requires
changes for people doing comconsole on aarch64)

console=eficom talks to the console via EFI protocols.  It's available
on amd64, aarch64 and riscv64. It's the first port that we find, though
it can be overriden by efi_com_port (which should be set to the UID of
the serial port, not the I/O port, despite the name). devinfo -v
will give the UID to uartX mapping.

This is an incompatible change for HYPER-V on amd64. It only works with
eficom console, so you'll need to change your configuration in
loader.conf. No compatibility hack will ever be provided for this (since
it requires renamig, which the loader cannot reliably do).

It's also an incompatible change for aarch64. comconsole will need to
change to eficom. There might be a comconsole "shim" for this.

All the interlock to keep only eficom and comconsole from both attaching
have been removed.

RelNotes:		Yes
Sponsored by:		Netflix
Discussed with:		kevans
Differential Revision:	https://reviews.freebsd.org/D39982
2023-05-11 14:06:03 -06:00
Kyle Evans 3cb2f5f369 lualoader: add support for .lua configuration files
If a file is specified in loader_conf_files that ends in '.lua', lualoader
will now load and execute that file. These may be used in place of a
traditional loader.conf to use more complicated logic, where some values
may be set based on others or based on the environment that the C bits has
left us with.

Lua scripts are run in a limited environment. In particular, it does not get
access to any modules or, in-fact, anything except environment variable.

A config.buildenv hook has been added so that a local module can add
whatever it may need to to the environment.

When a global var is set in the lua script, it does not immediately alter
the loader environment. Instead, the script's environment is initially
empty and processed only if the whole script executes successfully.
Effectively, a lua configuration file either takes effect or it does not,
an error will not leave it in a half-baked state.

Reviewed by:	bcr (manpages), imp
Differential Revision:	https://reviews.freebsd.org/D28450
2023-05-10 23:10:53 -05:00
Ed Maste e32fecd0c2 loader: install help files only once
Every file should be installed exactly once by `make installworld`.
This is especially important for pkgbase.

Loader help files were being installed by each loader variant (e.g.,
the simp, lua, and 4th EFI loaders).  Add a (slightly hacky) mechanism
to skip installing help files for all but one variant.

PR:		271178
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40021
2023-05-09 20:18:19 -04:00