]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
17 months agolualoader: Add loader_menu_multi_user_prompt config variable
Jessica Clarke [Fri, 2 Sep 2022 19:30:40 +0000 (20:30 +0100)]
lualoader: Add loader_menu_multi_user_prompt config variable

This allows the "Multi user" in "[B]oot Multi user" to be substituted
with another string, for example with "Installer" in installer media.
Note that this is lua-only at the moment, since loader.4th's menu.rc
defines the alternate name as Boot [M]ulti User, unlike lualoader which
leaves it as [B]oot Multi user. Ideally loader.4th would adopt the newer
and simpler lualoader behaviour and then it could gain support for this
option, but loader.4th is on the way out and isn't used by any official
installer media so this is not a significant concern.

Reviewed by: kevans, rpokala
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36418

(cherry picked from commit 9b17aa27406f3716383e71c6687d53599a8f8d8a)

17 months agostand: Parse BIOS revision from SMBIOS
Kornel Dulęba [Fri, 2 Sep 2022 11:08:32 +0000 (13:08 +0200)]
stand: Parse BIOS revision from SMBIOS

Add a smbios.bios.revision kenv, which contains the system BIOS revision
as defined in SMBIOS specification, section 3.3.1.
Since the revision is stored in two separate byte fields,
the smbios_setenv helper can't be used.
Read and construct the kenv manually instead.

Approved by: mw(mentor)
Sponsored by: Stormshield
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D36413

(cherry picked from commit 66c73af7ea59382ce5ca7cfb2eedb0491790276c)

17 months agokboot: List sources one per line to make merges easier
Warner Losh [Thu, 1 Sep 2022 17:07:34 +0000 (11:07 -0600)]
kboot: List sources one per line to make merges easier

Make SRC an alphabetical list of files, one per line.

Sponsored by: Netflix

(cherry picked from commit 69818bcf38e0bb1716a8d29f61ed392d447cea83)

17 months agokboot: add minmalist init functionality
Warner Losh [Thu, 1 Sep 2022 17:06:43 +0000 (11:06 -0600)]
kboot: add minmalist init functionality

It is desirable to run kboot as the first program in some LinuxBoot
environments. This is the traditional "pid 1" or "init" program. When
running as pid 1. rovide a minimal environment based on what sysvinit,
u-root, initramfs-tools and other like projects do. We mount /dev, /sys,
/proc, make symlinks from /dev/fd to /dev/proc, and create /tmp, /run,
and /var. We also setup stdin/out/err to the console, set the tty
characteristics of same and block the appropriate signals.

This is indended as an environment that never does a fork/exec. If
that's required, the process groups, session leaders and all things
POSIX terminal handlers will need to be added.

Unlike the general purpose linux projects in this area, no attempt is
made to support very old kernels.

When not pid 1, we skip all of the above.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36368

(cherry picked from commit 57f90cf81338ca9d1e403fdfeac16f21def72763)

17 months agostand: Add lua binding loader.has_command
Warner Losh [Thu, 1 Sep 2022 17:06:19 +0000 (11:06 -0600)]
stand: Add lua binding loader.has_command

Give scripts the ability to determine if the currently running loader
has provided a command.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36365

(cherry picked from commit 29fc4075e69fd27de0cded313ac6000165d99f8b)

17 months agostand: Add interp_has_builtin_cmd to see if we have a command
Warner Losh [Thu, 1 Sep 2022 17:06:01 +0000 (11:06 -0600)]
stand: Add interp_has_builtin_cmd to see if we have a command

interp_has_builtin_cmd() will try to lookup the passed in command and
returns true if it was found, false otherwise.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36364

(cherry picked from commit a5948d40ad060140bf5b995f5409458a18ced0ce)

17 months agostand: separate the command lookup from the command execution
Warner Losh [Thu, 1 Sep 2022 17:05:42 +0000 (11:05 -0600)]
stand: separate the command lookup from the command execution

Factor out interp_lookup_cmd to search for a command from
interp_builtin_cmd. This simplifies the latter and can be used to expand
lua to ask if a command exists.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36363

(cherry picked from commit 113dfadd5c8c2b8a566bf4d0e969e1dff62c9e2f)

17 months agostand: Document EFI consoles
Warner Losh [Thu, 1 Sep 2022 16:34:30 +0000 (10:34 -0600)]
stand: Document EFI consoles

Document how EFI consoles work, at least on x86. There's a number of
weird quirks and limitations that are generally known, but not
documented until now. Include information on how EFI decides what the
defualt console is, how to set it and how to cope with common
situations. Note limitations and mismatch between ACPI (which uses UID
to identify a device) and our console code (which uses a raw address)
and explain why we can't translate between them in the loader.

Sponsored by: Netflix
Reviewed by: manu, kevans, rpokala, pauamma
Differential Revision: https://reviews.freebsd.org/D36286

(cherry picked from commit 75a91c70f8d12825ded5a6d14841bf3065ba6595)

17 months agostand: Stop setting hints for bios loader too
Warner Losh [Thu, 1 Sep 2022 16:33:09 +0000 (10:33 -0600)]
stand: Stop setting hints for bios loader too

Catch up to 2753bbe71b5a and remove the old hints.

Sponsored by: Netflix

(cherry picked from commit b1819983e70f5b8890404b7e07d17888d0cccfb6)

17 months agostand: Document that boot0 uses BIOS
Warner Losh [Fri, 26 Aug 2022 21:47:21 +0000 (15:47 -0600)]
stand: Document that boot0 uses BIOS

And thus has a limited range of supported baud rates. Also add that
setting BOOT_BOOT0_COMCONSOLE_SPEED=0 will leave it unchanged which
sometimes can give you 115200 if the BIOS initialized things outside of
the normal BIOS baud rates (which many x86 enbedded-targetted boards
do).

Sponsored by: Netflix
Reviewed by: emaste, manu (earlier versions)
Suggestions by: jhb
Differential Revision: https://reviews.freebsd.org/D36300

(cherry picked from commit 7ed3228323ef4f9e3130603ea68c3be9c2ed50ce)

17 months agostand: More sensible defaults when ConOut is missing
Warner Losh [Fri, 26 Aug 2022 21:46:33 +0000 (15:46 -0600)]
stand: More sensible defaults when ConOut is missing

When ConOut is missing, we used to default to serial. Except we did it
in the worst way possible by just setting the howto bits and not
updating the console setting, which lead to weird behavior where we'd
get some things on the video port, others on serial.

Instead, set console to "efi,comconsole" for this case. Also set
RB_MULTIPLE always (so we get dual consoles from the kernel) and or in
RB_SERIAL when we can't find GOPs that suggest the precense of a video
console. This will put output in the most places and have a sensible
default for 'primary' console.

Sponsored by: Netflix
Reviewed by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D36299

(cherry picked from commit df065f699f1ff819bb9607c44a6754275ab335ed)

17 months agostand: Use bool for stage_offset_set
Warner Losh [Sun, 21 Aug 2022 15:45:44 +0000 (09:45 -0600)]
stand: Use bool for stage_offset_set

stage_offset_set is a boolean, convert it to a bool.

Sponsored by: Netflix

(cherry picked from commit 9d70108a74efe327ed9d1f68bc1e9e271810d94c)

17 months agoloader: zfs reader should only store devdesc in f_devdata
Toomas Soome [Sun, 14 Aug 2022 21:49:50 +0000 (00:49 +0300)]
loader: zfs reader should only store devdesc in f_devdata

Use d_opendata for device specific data.

PR: 265825
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D36202

(cherry picked from commit d98de7440507aea1648c8f4bc302bf88c0eb9458)

17 months agostand: Raise limit to 550,000 bytes for loader
Warner Losh [Fri, 12 Aug 2022 04:59:51 +0000 (22:59 -0600)]
stand: Raise limit to 550,000 bytes for loader

Raise the limit for /boot/loader to be 550k. The IBM PC imposes a limit
of 640k of RAM below 1MB, which is needed for real mode calls. BTX takes
40k of that. The BIOS takes some amount (25k seems a good "99% take less
than or equal to this" estimate for that, though some systems consume
more). Most typical setups need 25k of stack.  This leaves 550k for
code. We set the limit to 550,000 which gives about an extra 13,000
bytes of buffer for machines that whose setups use a little more stack
or whose BIOS reserves a bit more...

Add this derivation in the Makefile. Also recommend setting LOADERSIZE
lower in /etc/src.conf when the loader has to run on a system whose BIOS
takes up more space, or for a complex setup. Add a recipe for how to
find how much RAM your BIOS uses as well (thanks to jhb@ for the
trick). Network cards that boot via PXE and HBAs with their BIOS enabled
are known to be large consumers of lomem space.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D36152

(cherry picked from commit f8a199f28f9de46fe7360c3a4a0e19e71be72721)

stand: Fix a couple of comment typos in f8a199f28f9d

The commit message documented it as /etc/src.conf but the comment in the
source mentioned the non-existent /etc/loader.conf.

Fixes: f8a199f28f9d ("stand: Raise limit to 550,000 bytes for loader")
(cherry picked from commit 3179bb2737493bc4191c3239226bda50f0b64b8f)

17 months agostand: Go back to a.out format for /boot/loader
Warner Losh [Thu, 11 Aug 2022 23:29:10 +0000 (17:29 -0600)]
stand: Go back to a.out format for /boot/loader

Turns out there's two hidden a.out dependencies. pxeldr.S assumes it has
access to the a.out header from /boot/loader and cdboot.S assumes that
/boot/loader is also a.out and doesn't use boot2.

So, go back to making a.out files for these and adjust the size checks
to use ls, but we only need to check loader.bin. Trim the size we check
against by 2,000. The difference in size between loader and loader.bin
is about 3000 bytes, but clang15 produces binaries that are a smidge
bigger so we need to relax the check just a little and accept some
additional risk for the moment.

Add some comments to loader's Makefile about this.

Sponsored by: Netflix
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D36142

(cherry picked from commit 4c8ea3efe73c12d595472a7fc37177432a77858e)

17 months agostand: Make BIOS loader size limits settable
Warner Losh [Thu, 11 Aug 2022 16:24:58 +0000 (10:24 -0600)]
stand: Make BIOS loader size limits settable

It's sometimes desirable to override the size limit: It's a soft limit
and there are times we exceed the limit by just a little bit and don't
want the build to fail (or we are hitting runtime failures below the
510,000 byte limit).

Sponsored by: Netflix

(cherry picked from commit 7d72ff905770a64a22125c890438189db71104ae)

17 months agostand: i386_fmtdev can be reduced to devformat
Warner Losh [Thu, 11 Aug 2022 15:09:03 +0000 (09:09 -0600)]
stand: i386_fmtdev can be reduced to devformat

devformat produces the same output as i386_fmtdev, so just use it to
reduce on the dependencies.

Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D35927

(cherry picked from commit 362322294045943703e03dee263bbc237002525c)

17 months agostand: uboot_fmtdev can be reduced to devformat
Warner Losh [Thu, 11 Aug 2022 15:08:52 +0000 (09:08 -0600)]
stand: uboot_fmtdev can be reduced to devformat

devformat produces the same output as uboot_fmtdev, so just use it to
reduce on the dependencies.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35926

(cherry picked from commit add8154e451f441778fb9c2fb7d10d281dea9611)

17 months agostand: userboot_fmtdev can be reduced to devformat
Warner Losh [Thu, 11 Aug 2022 15:08:26 +0000 (09:08 -0600)]
stand: userboot_fmtdev can be reduced to devformat

devformat produces the same output as userboot_fmtdev, so just use it to
reduce on the dependencies. In addition, we don't need to use the
incomplete struct userboot_devdesc type, we can use struct devdesc
instead (in fact, there's no userboot_devdesc defined anywhere).

Sponsored by: Netflix
Reviewed by: jhb (prior version)
Differential Revision: https://reviews.freebsd.org/D35925

(cherry picked from commit 1e9b23448a3010e8403eae08ad890fe1eb75da8b)

17 months agostand: efi_fmtdev can be reduced to devformat
Warner Losh [Thu, 11 Aug 2022 15:08:08 +0000 (09:08 -0600)]
stand: efi_fmtdev can be reduced to devformat

devformat produces the same output as efi_fmtdev, so just use it to
reduce on the dependencies.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35924

(cherry picked from commit 1e7a2eb93a527a2f4b22be66788caf50e4ba1f89)

17 months agostand: Replace zfs_fmtdev with generic devformat()
Warner Losh [Thu, 11 Aug 2022 15:07:44 +0000 (09:07 -0600)]
stand: Replace zfs_fmtdev with generic devformat()

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35973

(cherry picked from commit edb26097cb6416adb89b54c830d36c0ead3ca64c)

17 months agostand: For zfs, set dv_fmtdev to zfs_fmtdev
Warner Losh [Thu, 11 Aug 2022 15:07:26 +0000 (09:07 -0600)]
stand: For zfs, set dv_fmtdev to zfs_fmtdev

Add a generic way to get the string representation of a zfs device / mount.

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35923

[ Dropped changes to stand/libsa/zfs/Makefile.inc file, depends
  on newer OpenZFS ]

(cherry picked from commit 654b7837a6a08ec5b51635badd14794754fab7c5)

17 months agostand: Use devformat instead of disk_devfmt
Warner Losh [Thu, 11 Aug 2022 15:07:13 +0000 (09:07 -0600)]
stand: Use devformat instead of disk_devfmt

Use devformat instead of disk_devfmt. This allows us to avoid knowing
the details of the device that's underneath us. Remove disk.h include
and the -I${LDRSRC} from the build of ufs.c since they are no longer
needed.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35922

[ minor tweaks due to earlier UFS MFC ]

(cherry picked from commit 0b3a4a588fb6b30d923686828dab4685b94ec1ea)

17 months agostand: Use devformat rather than disk_devfmt
Warner Losh [Thu, 11 Aug 2022 15:06:53 +0000 (09:06 -0600)]
stand: Use devformat rather than disk_devfmt

Fix layering violation and use devformat to get the string
representation of the device to see if we're mounted yet or not. Remove
added include to pickup disk.h.

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35919

[ minor changes because UFS changes interferred and were already merged ]

(cherry picked from commit ec9f3e776f39286ccec9915f38cca9729e6f9241)

17 months agostand: Add disk_fmtdev for dv_fmtdev for all the disk devices
Warner Losh [Thu, 11 Aug 2022 15:06:28 +0000 (09:06 -0600)]
stand: Add disk_fmtdev for dv_fmtdev for all the disk devices

All of the archsw fmtdev functions treat DEVT_DISK as a call to
disk_fmtdev. Set all disks' dv_fmtdev to disk_fmtdev so devformat
will return the same thing.

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35917

(cherry picked from commit ad759c73522efb606135e2891ac03864926b80a3)

17 months agostand: Add devformat to return formatted string for a device
Warner Losh [Thu, 11 Aug 2022 15:06:09 +0000 (09:06 -0600)]
stand: Add devformat to return formatted string for a device

Use dv_fmtdev to return a formatted string for a device. If this is a
null pointer, return the device name and unit followed by a colon (eg
disk3:).

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35916

(cherry picked from commit dc472f67021320309ced970d3d26d30a04da0ef2)

17 months agostand: Add dv_devfmt to return a string represenation of the device
Warner Losh [Thu, 11 Aug 2022 15:05:34 +0000 (09:05 -0600)]
stand: Add dv_devfmt to return a string represenation of the device

Add a new pointer, dv_devfmt, to allow devices to format themselves. We
will use this to simplify many of the fmtdev functions in the tree as
they are all almost the same, or all are isomorphic to each other.

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35915

(cherry picked from commit 4d4b1a298c84f2357c304583dfe78d0e4b8fa2f1)

17 months agostand: Change zfs_fmtdev to take a struct devdesc *
Warner Losh [Thu, 11 Aug 2022 15:05:15 +0000 (09:05 -0600)]
stand: Change zfs_fmtdev to take a struct devdesc *

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35974

(cherry picked from commit d2d4e1271b33b233f57fd18a61a1b5c1b0aeb355)

17 months agostand: Change disk_fmtdev to take a struct devdesc *
Warner Losh [Thu, 11 Aug 2022 15:04:50 +0000 (09:04 -0600)]
stand: Change disk_fmtdev to take a struct devdesc *

We do a number of games with ploymorphism for different types struct
*devdesc. Adjust one place that this affects to take the address of the
base class (most others have void * at the moment). This is more type
safe than a bare void *.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35914

(cherry picked from commit c32dde3166922f55927764464d13f1bc9640f5f6)

17 months agostand: Move i386_devdesc to a union
Warner Losh [Thu, 11 Aug 2022 15:04:08 +0000 (09:04 -0600)]
stand: Move i386_devdesc to a union

Rather than have the magic, hand-crafted fields that have to align with
fields in other structures at the end of i386_devdesc, make it into
anonymous union and adjust the code accordingly. This is safer and
similar to what CAM does.

Sponsored by: Netflix
Reviewed by: kevans, tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35965

(cherry picked from commit f197c0bf3e075286ccea32cd12023f3317474c5a)

17 months agostand: Remove unnecessary include
Warner Losh [Thu, 11 Aug 2022 14:59:48 +0000 (08:59 -0600)]
stand: Remove unnecessary include

stdbool.h is implied by stand.h, so remove it.

Sponsored by: Netflix

(cherry picked from commit bec11d96318bc8647f28b580829eeb7ba9d05768)

17 months agostand: impose 510,000 byte limit for /boot/loader and /boot/pxeldr
Warner Losh [Thu, 11 Aug 2022 03:19:01 +0000 (21:19 -0600)]
stand: impose 510,000 byte limit for /boot/loader and /boot/pxeldr

The BIOS method of booting imposes an absolute limit of 640k for the
size of the program being run due to btx. In practice, this means that
programs larger than about 500kiB will fail in odd ways as the stack /
heap will overflow.

Pick 510,000 as the cutoff line semi-arbitrarily. loader_lua is now
almost too big and we want to break the build when it crosses this
threshold. In my experience, below 500,000 always works, above 520,000
always seems to fail with things getting bad somewhere between 512,000
to 515,000. 510,000 is as close to the line as I think we can go, though
experience may dictate we need to lower this in the future.

This is at-best a stop-breakage until we have a better way to subset the
boot loader for BIOS booting to allow better, more fined-tuned
/boot/loaders for the many different environments they have to run
in. This likely means we'll have a graphical loader than understands a
few filesystmes for installation, and a non-graphical loader that
understands the most filesystems possible for everything else in the
future. Our build infrastructure needs some work before we can do that,
however.

At this late date, it likely isn't worth the efforts to move parts of
the loader into high memory. There's a number of assumptions about where
the stack is, where buffers reside, etc that are fulfilled when it lives
in the first 640k that would need bounce buffers and/or other counter
measures if we were to split it up. All BIOS calls are done in 16-bit
mode with SEG:OFF addresses, requiring them to be in the first 640k of
RAM. And nearly all machines in the last decade can boot with UEFI
(though there's some exceptions, so it isn't worth killing outright
yet).

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

(cherry picked from commit 39fdad34e220c52a433e78f20c8c39412429014e)

17 months agostand: i386/amd64: Always use elf format for /boot/loader and pxeldr
Warner Losh [Thu, 11 Aug 2022 03:18:32 +0000 (21:18 -0600)]
stand: i386/amd64: Always use elf format for /boot/loader and pxeldr

The first level boot blocks have understood how to load ELF code since
1999. Switch /boot/loader and /boot/pxeldr over to being ELF format so
that in-tree tools can examine them more closely. In addition, one
could, in theory, now have a 'lo-mem' and a 'hi-mem' segment (though a
lot of work would need to be done with bounce buffers, btx, code segment
marking, etc for an arrangement like that to work).

As far as I can tell, this is the last a.out binary in the tree. There
are several raw binaries left, but everything else is ELF.

Reviewed by: emaste, kevans
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36130

(cherry picked from commit e2295b9117233d8248fe919c6b28ef1d44a8950d)

17 months agostand: Reduce number of files that need -I${LDRSRC}
Warner Losh [Wed, 3 Aug 2022 17:16:17 +0000 (11:16 -0600)]
stand: Reduce number of files that need -I${LDRSRC}

geliboot.c and geliboot_crypto.c don't need anything from stand/common,
so remove them from the list of things to add it.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35921

(cherry picked from commit f863970a82f430a2b10b9799585008fe89eab00a)

17 months agostand: Remove unneeded include from geli
Warner Losh [Wed, 3 Aug 2022 17:13:34 +0000 (11:13 -0600)]
stand: Remove unneeded include from geli

bootstrap.h isn't needed at all by geil, so remove it.

Sponsored by: Netflix
Reviewed by: tsoome (earlier version)
Differential Revision: https://reviews.freebsd.org/D35920

(cherry picked from commit 4333168b1dc0f9285e90ccba26e21348e51fe889)

17 months agostand: use snprintf here
Warner Losh [Wed, 3 Aug 2022 16:50:14 +0000 (10:50 -0600)]
stand: use snprintf here

This code was written prior to snprintf being in the then libstand (now
libsa). Since we have it, use it for extra safety. The code already
tries to be safe, but since we have snprintf as well, the added layer of
protection will suffice. The current code reserves 16 bytes (plus a NUL)
at the end for worst case of inet_ntoa, which is still a little
pessimal, but safe from overflow.

Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D35102

(cherry picked from commit a23c26b2fe38f7ad63e71e1f32795b4800213585)

17 months agostand: Add a helper 'universe' target
Warner Losh [Sat, 30 Jul 2022 11:01:47 +0000 (05:01 -0600)]
stand: Add a helper 'universe' target

Add a shortcut for invokging ${SRCTOP}/tools/boot/universe.sh by
creating a 'universe' target in src/stand. This will make it easier to
test out all the different combinations of boot loaders that we build.

Sponsored by: Netflix

(cherry picked from commit 206203f5301b1bda1ceabcb7ecb7c0eee3e6b07a)

17 months agostand: Move quit command to common commands
Warner Losh [Sat, 30 Jul 2022 10:43:21 +0000 (04:43 -0600)]
stand: Move quit command to common commands

Since both EFI and the future kboot will benefit from a 'quit' command,
move it from efi/loader/main.c to common/commands.c. In EFI this command
exits back to the boot loader (which will cause the next BootXXXX in the
BootOrder list to be attempted). In kboot, this will exit back to
whatever called loader.kboot. In uboot this will cause a reset (which
will restart uboot, not quite a simple exit, but will look similar)
and in OFW it will execute OF_exit which should return to the
openfirmware prompt.

Sponsored by: Netflix

[[ tweaked because mips is still in stable/13 leading to conflict ]]

(cherry picked from commit 2101541ff1222788901d9503001add9f288a4c40)

17 months agokboot: Make console raw when we start
Warner Losh [Tue, 26 Jul 2022 23:39:45 +0000 (17:39 -0600)]
kboot: Make console raw when we start

Put the console into raw mode on startup. This allows the menus to work
as expected. Boot is now interruptable.

Note: Likely should restore the terminal settings on most exists.  It's
not clear the best way to do this, and most shells have an auto stty
sane anyway, so note it for future improvement.

Sponsored by: Netflix

(cherry picked from commit 9579540144880e0a612ec2fdfc66de46c08d28d6)

17 months agokboot: implement stripped down termios
Warner Losh [Tue, 26 Jul 2022 23:31:23 +0000 (17:31 -0600)]
kboot: implement stripped down termios

Implement a stripped down termios, obtained from various files in musl
and HOST_ or host_ prepended to most things and a few unavoidable style
tweaks. Only implements the bits of termios we need for the boot loader:
put the terminal into raw mode, restore terminal settings and speed
stuff.

Sponsored by: Netflix

(cherry picked from commit 963037786f76a414e91e45d4fbef5e35fc1abc84)

17 months agokboot: Implement host_ioctl
Warner Losh [Tue, 26 Jul 2022 23:30:30 +0000 (17:30 -0600)]
kboot: Implement host_ioctl

Sponsored by: Netflix

(cherry picked from commit 54e6e0deb4853dae7e97e7d5659c05e95bebac32)

17 months agokboot: Add host_exit and use it to implement exit()
Warner Losh [Thu, 28 Jul 2022 21:18:08 +0000 (15:18 -0600)]
kboot: Add host_exit and use it to implement exit()

Clients of libsa are expected to implement exit(). The current exit just
loops forever. It is better to really exit: when running as init that
will reboot the system. When not running as init, other programs can
recover (not that we support running as init, but when we do in the
future, this is still the rigtht thing).

Sponsored by: Netflix

(cherry picked from commit f56d7a73be6688299c7ec97fac6d505c657aa55c)

17 months agokboot: aarch64 support
Warner Losh [Mon, 11 Jul 2022 23:49:11 +0000 (17:49 -0600)]
kboot: aarch64 support

Add support for aarch64. exec.c and ldscript are copied from the EFI
version with #ifdefs for the differences. Once complete, I'll refactor
them. host_syscall.S implements a generic system call. tramp.S is a
first attempt to create a tramoline that we can use to jump to the
aarch64 kernel. Add aarch64-specific startup and stat files as well.
exec.c tweaked slightly to avoid bringing in bi_load(), which will come
in later. Includes tweaks to stat due to name differences between names
on different Linux architectures.

Sponsored by: Netflix

(cherry picked from commit 75cbdbc9832e72a59bdcb1c307a7a4ea77e29fce)

17 months agokboot: Move conf.c up to top level
Warner Losh [Thu, 28 Jul 2022 20:53:25 +0000 (14:53 -0600)]
kboot: Move conf.c up to top level

conf.c is the same now between powerpc64 and amd64, so move it up to
kboot. Move powerpc file formats defines to ppc64_elf_freebsd.c

Sponsored by: Netflix

(cherry picked from commit a0c075229f19ce1a10836042907e2bd89907aa0b)

17 months agokboot: Remove RELOC defines, it's unused
Warner Losh [Thu, 28 Jul 2022 05:11:12 +0000 (23:11 -0600)]
kboot: Remove RELOC defines, it's unused

This was copied from powerpc/ofw and has never been used. We also don't
care about -DAIM. It's only relevant for in-kernel structures, which we
don't use in this userland program.

Sponsored by: Netflix

(cherry picked from commit 309a263fe6484658827ca28a922fad70a2b42499)

17 months agokboot: Convert from getdents to getdents64
Warner Losh [Thu, 28 Jul 2022 04:24:50 +0000 (22:24 -0600)]
kboot: Convert from getdents to getdents64

Linux 2.4 introduced getdents64. Switch to using it because aarch64
doesn't have getdents as that syscall was obsoleted before that port was
created.

Sponsored by: Netflix

(cherry picked from commit 3a1b966ae0c1b9f334e1e3a7ad8b4bf8e845f3c5)

17 months agokboot: Do a style(9) pass on kbootfdt.c
Warner Losh [Thu, 28 Jul 2022 04:07:52 +0000 (22:07 -0600)]
kboot: Do a style(9) pass on kbootfdt.c

Mostly just properly indent.

Sponsored by: Netflix

(cherry picked from commit 065cbc77076ec8d38385406deefa8331bc2432f5)

17 months agostand: tftp.c doesn't need bootinfo.h
Warner Losh [Tue, 26 Jul 2022 03:45:35 +0000 (21:45 -0600)]
stand: tftp.c doesn't need bootinfo.h

tftp.c includes bootinfo.h, but doesn't need it. Remove it, and remove
the -Istand/common from CFALGS since that's the only reason we had it.

Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D35928

(cherry picked from commit 60cb4f9a8e258e917634d23fb1d589eef38e579c)

17 months agostand: Make sure nobody has a NULL pointer for dv_cleanup
Warner Losh [Wed, 27 Jul 2022 14:46:21 +0000 (08:46 -0600)]
stand: Make sure nobody has a NULL pointer for dv_cleanup

dv_cleanup is specified almost everywhere. Use nullsys instead of NULL
to indicate 'do nothing'. Also, be consistent in trailing commas that
were missing before.

Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D35913

(cherry picked from commit e98f952c82907ec39cebb4e66efd92691c835e05)

17 months agostand: Small comment correction
Warner Losh [Wed, 27 Jul 2022 14:46:12 +0000 (08:46 -0600)]
stand: Small comment correction

While in theory, once upon a time, dv_type was arch specific, that's
never been the case in FreeBSD (and certaintly isn't in the surviving
drivers). Remove that notation.

Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D35911

(cherry picked from commit 079f02e8c035f12779a57f10b274253a701267e5)

17 months agostand: Create DEV_NAMLEN for the length of a device name
Warner Losh [Wed, 27 Jul 2022 14:45:59 +0000 (08:45 -0600)]
stand: Create DEV_NAMLEN for the length of a device name

Rather than hard coding 8 for the device name length, create a #define for it.

Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D35910

(cherry picked from commit 4932a6e41d1fc3fe474358501d5933e783066bdc)

17 months agostand: Spell License correctly
Warner Losh [Tue, 26 Jul 2022 22:29:56 +0000 (16:29 -0600)]
stand: Spell License correctly

An e got dropped and then cut and pasted into far too many places.

Sponsored by: Netflix
Noticed by: freqlabs on irc

(cherry picked from commit d2c0ec8d19da6531676af82461e7a8247228f8f4)

17 months agostand: Fix set but unused warning
Warner Losh [Tue, 26 Jul 2022 04:48:31 +0000 (22:48 -0600)]
stand: Fix set but unused warning

Make interp_identifier global to avoid a set but not used warning. For a
global, llvm can't optimize it out (yet?)

Sponsored by: Netflix

(cherry picked from commit f4d71d0c1a9976c047758e065adb2c1498cd9765)

17 months agostand/disk: Trivial formatting nit
Warner Losh [Mon, 25 Jul 2022 13:32:15 +0000 (07:32 -0600)]
stand/disk: Trivial formatting nit

style(9) wants a space here.

Sponsored by: Netflix

(cherry picked from commit 865a58d2fc89616a0ab2f88016da43e980dcac1d)

17 months agostand: Use c99 structure initialization for userboot's host_fsops
Warner Losh [Sun, 24 Jul 2022 21:51:50 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for userboot's host_fsops

Sponsored by: Netflix

(cherry picked from commit b3f43ee0317ad241fd35cd8a0e087fd2b158ca1f)

17 months agostand: Use c99 structure initialization for gzipfs_fsops
Warner Losh [Sun, 24 Jul 2022 21:51:47 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for gzipfs_fsops

Sponsored by: Netflix

(cherry picked from commit b7625c2c2cf7e559acc08f7cbbb53f5cb3b8ab94)

17 months agostand: Use c99 structure initialization for splitfs_fsops
Warner Losh [Sun, 24 Jul 2022 21:51:44 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for splitfs_fsops

Sponsored by: Netflix

(cherry picked from commit 9450d9c4e5f94421237a5f58f47afee8c065e60f)

17 months agostand: Use c99 structure initialization for pkgfs_fsops
Warner Losh [Sun, 24 Jul 2022 21:51:42 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for pkgfs_fsops

Sponsored by: Netflix

(cherry picked from commit e7d045aa2b270d2026ad6c15639673ea6d01c7b4)

17 months agostand: Use c99 structure initialization for nfs_fsops
Warner Losh [Sun, 24 Jul 2022 21:51:39 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for nfs_fsops

Sponsored by: Netflix

(cherry picked from commit 90a7e556a42263ea10ca931621f168bc3f07a5ff)

17 months agostand: Use c99 structure initialization for bzipfs_fsops
Warner Losh [Sun, 24 Jul 2022 21:51:36 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for bzipfs_fsops

Sponsored by: Netflix

(cherry picked from commit 0ad8a113b7066494c509f5c89267c2a4116788c5)

17 months agostand: Use c99 structure initialization for ext2fs_fsops
Warner Losh [Sun, 24 Jul 2022 21:51:34 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for ext2fs_fsops

Sponsored by: Netflix

(cherry picked from commit 12a41918a276c042886cd2741b1f79fc402cd752)

17 months agostand: Use c99 structure initialization for network device
Warner Losh [Sun, 24 Jul 2022 21:51:32 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for network device

Use c99 structure init for devsw.

Sponsored by: Netflix

(cherry picked from commit c4f4a6c983fdadfc343344152cfc571a00a1e07a)

17 months agostand: Use c99 structure initialization for fwohci device
Warner Losh [Sun, 24 Jul 2022 21:51:29 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for fwohci device

Use c99 structure init for devsw.

Sponsored by: Netflix

(cherry picked from commit bf855d1bf252bdf31a405cef65021d63846765ab)

17 months agostand: Use c99 structure initialization for userboot block device
Warner Losh [Sun, 24 Jul 2022 21:51:27 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for userboot block device

Use c99 structure init for devsw.

Sponsored by: Netflix

(cherry picked from commit 4c460aaf8342ec80216dd0e7f876903d75790c2f)

17 months agostand: Use c99 structure initialization for uboot block device
Warner Losh [Sun, 24 Jul 2022 21:51:24 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for uboot block device

Use c99 structure init for devsw.

Sponsored by: Netflix

(cherry picked from commit 1e3d1c86bc86197c1ac7f82b28e13985df58fcf4)

17 months agostand: Use c99 structure initialization for ofw's block device
Warner Losh [Sun, 24 Jul 2022 21:51:21 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for ofw's block device

Use c99 structure init for devsw.

Sponsored by: Netflix

(cherry picked from commit e72a01f1325f50326f02209d75203b97d6bfca88)

17 months agostand: Use c99 structure initialization for kboot's hostdisk device
Warner Losh [Sun, 24 Jul 2022 21:51:19 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for kboot's hostdisk device

Use c99 structure init for devsw.

Sponsored by: Netflix

(cherry picked from commit fc5d0d51aafc1a954a5e9cfa69cd8cdf91824e21)

17 months agostand: Use c99 structure initialization for md device
Warner Losh [Sun, 24 Jul 2022 21:51:15 +0000 (15:51 -0600)]
stand: Use c99 structure initialization for md device

Use c99 structure init for devsw.

Sponsored by: Netflix

(cherry picked from commit 143452f7609fc232ba9ae625a1f87d12449ff55b)

17 months agokboot: Pull in constants from Linux's mmap.h api
Warner Losh [Tue, 28 Jun 2022 16:43:42 +0000 (10:43 -0600)]
kboot: Pull in constants from Linux's mmap.h api

Define the usual #defines for mmap(2) (with HOST_ prepended) and use
them instead of hard coding constants.

Sponsored by: Netflix

(cherry picked from commit 01c58e7e4fd830b736c2fdcee4965e135f6e6685)

17 months agokboot: Properly cap number of segments loaded for kexec
Warner Losh [Wed, 29 Jun 2022 22:31:23 +0000 (16:31 -0600)]
kboot: Properly cap number of segments loaded for kexec

Linux has an arbitrary limit of 16 segments. Make sure we don't load too
many.

Sponsored by: Netflix

(cherry picked from commit 2870493f1f55d5c00e5593f336dc05805863db7f)

17 months agokboot: Refinements to host_kexec_load
Warner Losh [Tue, 28 Jun 2022 16:40:04 +0000 (10:40 -0600)]
kboot: Refinements to host_kexec_load

Move kexec_segments to host_syscall.h and pre-pend host_ to it.  Correct
args to host_exec_load.

Sponsored by: Netflix

(cherry picked from commit ffb0d016df7e5526e4b8fd74a1f0617c81478328)

17 months agokboot: Use #defines for magic reboot constants
Warner Losh [Tue, 28 Jun 2022 14:44:16 +0000 (08:44 -0600)]
kboot: Use #defines for magic reboot constants

Sponsored by: Netflix

(cherry picked from commit 8fa9263f67eb78c8ded9bd3d94c9c841cd0b6ba3)

17 months agokboot: Implement mount(2)
Warner Losh [Thu, 30 Jun 2022 18:16:46 +0000 (12:16 -0600)]
kboot: Implement mount(2)

Create a wrapper for the mount system call. To ensure a sane early boot
environment and to gather data we need for kexec, we may need to mount
some special filesystems.

Sponsored by: Netflix

(cherry picked from commit 8138a766b068a17ad8f13ddcb850f356c04d9074)

17 months agokboot: Implement mkdir(2)
Warner Losh [Thu, 30 Jun 2022 18:09:26 +0000 (12:09 -0600)]
kboot: Implement mkdir(2)

mkdir() may be needed early in boot to create missing
directories. Provide a syscall wrapper for it.

Sponsored by: Netflix

(cherry picked from commit a99d47bcaaf61eb869f5f04fa51fe38b19504ac4)

17 months agokboot: Implement dup(2)
Warner Losh [Thu, 30 Jun 2022 18:25:49 +0000 (12:25 -0600)]
kboot: Implement dup(2)

Early in boot, we need to create the normal stdin/out/err env for the
boot loader to run in. To do that, we need to open the console and
duplicate the file descriptors which requires dup(2). Implement a
wrapper as host_dup.

Sponsored by: Netflix

(cherry picked from commit bc84de741dfd3b81cc7d332f8e6f0d84afe4eee1)

17 months agokboot: Implement symlink(2)
Warner Losh [Thu, 30 Jun 2022 18:22:33 +0000 (12:22 -0600)]
kboot: Implement symlink(2)

Linux's /dev/fd is implemented inside of /proc/self/fd, so we may need
to create a symlink to it early in boot. "/dev/fd" and "/dev/std*" might
not be strictly required for the boot loader, but should be present for
maximum flexibility.

Sponsored by: Netflix

(cherry picked from commit a4ed0eb1aa64d10feaf1e64de39eb07be43a5204)

17 months agokboot: Implement getpid(2)
Warner Losh [Thu, 30 Jun 2022 18:12:51 +0000 (12:12 -0600)]
kboot: Implement getpid(2)

Add host_getpid() so we can know if we're running as init(8) or not.  If
we are, we may chose to do early system setup / sanity operations.

Sponsored by: Netflix

(cherry picked from commit 764780294f1df220174c1eb2208c0774d685d594)

17 months agokboot: Implement munmap(2)
Warner Losh [Mon, 27 Jun 2022 23:49:21 +0000 (17:49 -0600)]
kboot: Implement munmap(2)

Define host_munmap so we can use it in the x86 code to find things for
the BIOS/CMS boot path and unmap after we find it.

Sponsored by: Netflix

(cherry picked from commit 76949f503f008b28865bd0fd026a550a3cb48619)

17 months agokboot: Implement stat(2) and fstat(2) system calls
Warner Losh [Fri, 15 Jul 2022 05:19:18 +0000 (23:19 -0600)]
kboot: Implement stat(2) and fstat(2) system calls

Implement stat(2) and fstat(2) in terms of newfstatat and newfstat
system calls respectively (assume we have a compat #define when
there's no newfstat and just a regular fstat and do so for ppc).

Snag struct kstat (the Linux kernel stat(2), et al interface) from musl
and attribute properly.

Sponsored by: Netflix

(cherry picked from commit a647d4a4d15df856d590c39c19d3973ec2e18825)

17 months agokboot: Add HOST_O_ constants for open, etc
Warner Losh [Fri, 1 Jul 2022 17:57:02 +0000 (11:57 -0600)]
kboot: Add HOST_O_ constants for open, etc

Add the common O_ constants for the open, fcntl, etc system calls. They
are different than FreeBSD's. While they can differ based on
architecture, they are constant for architectures we care about, and
those architectures use the 'generic' version so future architectures
will also work.

Sponsored by: Netflix

(cherry picked from commit ae366d5106844c26ecec54b6926c13064a224aa9)

17 months agokboot: Enhance kboot_getdev to cope with NULLs
Warner Losh [Fri, 15 Jul 2022 13:32:16 +0000 (07:32 -0600)]
kboot: Enhance kboot_getdev to cope with NULLs

Fallback to currdev when NULL is passed in when 'rootdev' is NULL. Other
getdevs do this. Additional features are needed here still, though.

Sponsored by: Netflix

(cherry picked from commit bf35f00522676d6e456b19168908cfa890ae0782)

17 months agokboot: Reimplement older system calls in terms of newer ones
Warner Losh [Thu, 7 Jul 2022 22:58:27 +0000 (16:58 -0600)]
kboot: Reimplement older system calls in terms of newer ones

aarch64 doesn't have open, just openat, etc. Cope.

Sponsored by: Netflix

(cherry picked from commit edc23ddf9cf35d7ea9baf72d14449e04508d2314)

17 months agokboot: Rework _start
Warner Losh [Thu, 14 Jul 2022 03:41:17 +0000 (21:41 -0600)]
kboot: Rework _start

Split _start into _start and _start_c (inspired by musl and the powerpc
impl is copied from there). This allows us to actually get the command
line arguments on all the platforms. We have a very simplified startup
that supports only static linking.

Sponsored by: Netflix

(cherry picked from commit f5ed1b0f84bf06839f0947981ebdb3646c3c433a)

17 months agostand: Remove extra efi.h include
Warner Losh [Thu, 7 Jul 2022 22:58:01 +0000 (16:58 -0600)]
stand: Remove extra efi.h include

There's nothing EFI specific about this file, so remove including efi.h.

Sponsored by: Netflix

(cherry picked from commit c1bbe711040c4e2ea515ca0a81313faec76c0050)

17 months agoloader.efi: faults could try to print out call trace
Toomas Soome [Wed, 8 Jun 2022 12:23:05 +0000 (15:23 +0300)]
loader.efi: faults could try to print out call trace

with grab_faults, we can try to print out the trace of function calls.
Without symbol table, we can not translate addresses to function names,
but even addresses can help to track the bugs.

For loader functions, print out absolute address, so it could be
searched from objdump -d output.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D35433

(cherry picked from commit f4ca0fdbe69db4ab8147406e753d869d77485c2c)

17 months agostand: Fix inclusion of sys/blake3.h
Warner Losh [Fri, 8 Jul 2022 23:34:53 +0000 (17:34 -0600)]
stand: Fix inclusion of sys/blake3.h

sys/blake3.h is not safe to include in a standalone environment. It
assumes, unwisely, that there's only kernel or userland. The userland
choice is bad due to imperfections in how we handle stdlib.h in this
environment (we wind up including the host's stdlib.h, it expects a
standard FreeBSD setup which the gymnastics we've done to create a
OpenSolaris/Illumos-like environment interfere with). Thankfully, in
this case we can just pretend to be the kernel for a little bit by
defining _KERNEL and the undefing it after we exit.

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

(cherry picked from commit b0a337d501927d12098891131341a7736a9125ee)

17 months agostand: Work around upstream issues in the standalone environment
Warner Losh [Fri, 8 Jul 2022 23:34:46 +0000 (17:34 -0600)]
stand: Work around upstream issues in the standalone environment

There's a number of issues with including zfs_context.h from a
standalone environment. First, sys/uio_imp.h isn't at all safe for this
environment, so define its guard #defines so that its contents are
skipped. Next, there's a problem including string.h to get the mem*
routines, so just define them here. ZFS_MODULE_PARAM_ARGS isn't defined
properly. I had wanted to define it when I was upstreaming changes to
include/os/freebsd/spl/sys/zfs_context.h, but they ran into resistance
so I'm defining that here now (it is also defined in zstd_shim.c, but
that will disappear once the issues it works around are
cleared). Finally, sys/sysmacros.h has to be included now before
sys/atomic.h, but upstream includes it after so include it here so that
the guards make the out-of-order includes in upstream irrelevant.

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

(cherry picked from commit faf25f48d601ae39f5752602f3020e2e92605625)

17 months agostand: For ZFS build, add new directory
Warner Losh [Fri, 8 Jul 2022 23:34:23 +0000 (17:34 -0600)]
stand: For ZFS build, add new directory

OpenZFS is based on having a number of layers of include files that
define things and include the next layer. Insert a later at the start
for files in libsa/zfs/spl so we can override issues with upstream
OpenZFS while we work to get the issues corrected upstream.

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

(cherry picked from commit 87d3aa53973fdfe1fa2ea64a8da9e29f4142d5af)

17 months agostand: Add comment about CFLAGS pollution
Warner Losh [Fri, 8 Jul 2022 16:34:44 +0000 (10:34 -0600)]
stand: Add comment about CFLAGS pollution

Add a note that veriexec / bearssl builds will pollute the CFLAGS in a
way that's somewhat hard to fix, so I'm just noting it for now.

Sponsored by: Netflix

(cherry picked from commit 37dabb06e23a2435eab0a0b37d87258d92d0fd50)

17 months agostand: constrain zlib/gzip CFLAGS better
Warner Losh [Fri, 8 Jul 2022 16:29:25 +0000 (10:29 -0600)]
stand: constrain zlib/gzip CFLAGS better

Define ZLIB_CFLAGS and use it only for the sources that are in ZLIB or
that include it.

Sponsored by: Netflix

(cherry picked from commit 84bf2bbbecc369cea6095bed7a738674b27f8d13)

17 months agostand: Confine BZIP defines to bzip files
Warner Losh [Fri, 8 Jul 2022 16:19:39 +0000 (10:19 -0600)]
stand: Confine BZIP defines to bzip files

Sponsored by: Netflix

(cherry picked from commit 59a4cfe03cf7a916a3d855f63fa8b6955f1d4136)

17 months agostand: geli CFLAGS tightening
Warner Losh [Fri, 8 Jul 2022 16:02:17 +0000 (10:02 -0600)]
stand: geli CFLAGS tightening

Only add -DWEAK_REFS to sha256.c and sha512.c instead of
everything. Remove redundant include that's not needed.
Minor formatting tweak.

Sponsored by: Netflix

(cherry picked from commit eaf7aabddcde9bf9eecffb41ba6569de0f5fa645)

stand geli: Restore include path to LDRSRC.

Various GELI sources need bootstrap.h and disk.h. In theory they
shouldn't need anything outside of libsa, but disk.h and bootstrap.h are
currently required.

This fixes the build with MK_LOADER_ZFS=no.

Obtained from: CheriBSD
Fixes: eaf7aabddcde stand: geli CFLAGS tightening
Sponsored by: DARPA
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D35861

(cherry picked from commit bb7ddd077c2528b37399304d7a9bf70b25c42b47)

17 months agostand: Don't reuse ZFSSRC
Warner Losh [Fri, 8 Jul 2022 15:03:45 +0000 (09:03 -0600)]
stand: Don't reuse ZFSSRC

ZFSSRC is the top level directory where the ZFS sources come from. Don't
reuse it for a list of ZFS sources. Instead, use ZFS_SRC

Sponsored by: Netflix

(cherry picked from commit f424b167a317b37ba7626e11002ca00dcc03f661)

17 months agoamd64/efi: Remove setting hints for rsdp
Warner Losh [Sat, 2 Jul 2022 14:01:09 +0000 (08:01 -0600)]
amd64/efi: Remove setting hints for rsdp

Given that hints set this way don't work when a static kenv is compiled
into the kernel. acpi.rsdp has been set for this for the past 6 years,
and all kernels in that time have used it in preference to the hints. As
such, we no longer hints.*, so remove them.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D35634

(cherry picked from commit 2753bbe71b5adce61a1bfb9535bc33735c35887c)

17 months agoloader: Set preferred kenv for acpi.rsdp on arm64
Warner Losh [Sat, 2 Jul 2022 14:00:40 +0000 (08:00 -0600)]
loader: Set preferred kenv for acpi.rsdp on arm64

Several years ago, x86 moved from using hints to communicate this
information to using the simpler acpi.rsdp variables. If one compiles
static hints into the kernel, then these hints are ignored. We can
remove this when we branch FreeBSD 15. Thought about BURN_BRIDGES
here, but it's too messy.

Sponsored by: Netflix
Reviewed by: andrew, jhb
Differential Revision: https://reviews.freebsd.org/D35632

(cherry picked from commit 37a3df3d6162b8f408b7d8a669245716771c309b)

17 months agoRemove "All Rights Reserved" from Foundation copyrights
Ed Maste [Thu, 30 Jun 2022 14:47:59 +0000 (10:47 -0400)]
Remove "All Rights Reserved" from Foundation copyrights

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit a765ac11c50bb20a64905e365b05b010533f26d3)

17 months agokboot: rename kexec_load to host_kexec_load
Warner Losh [Mon, 13 Jun 2022 17:46:48 +0000 (11:46 -0600)]
kboot: rename kexec_load to host_kexec_load

And make it match the system call more closely by passing in the proper
args.

Sponsored by: Netflix

(cherry picked from commit d8f3ef8f544e0c22c09cfa4f7b51ccac2666b59f)

17 months agokboot: sort system calls
Warner Losh [Mon, 13 Jun 2022 17:39:55 +0000 (11:39 -0600)]
kboot: sort system calls

Sort the system calls. No functional change intended.

Sponsored by: Netflix

(cherry picked from commit 201c1d0d25ee5ac50092a7334b7ebfa238ce2c0f)

17 months agokboot: use SYS_kexec_load insteaed of __NR_kexec_load
Warner Losh [Mon, 13 Jun 2022 17:33:24 +0000 (11:33 -0600)]
kboot: use SYS_kexec_load insteaed of __NR_kexec_load

Make this regular with the rest of the system calls.

Sponsored by: Netflix

(cherry picked from commit 43ad112b936c5516e0a9b968930a6d3387e7d86b)

17 months agokboot: Sort system calls alphabetically
Warner Losh [Mon, 13 Jun 2022 17:28:31 +0000 (11:28 -0600)]
kboot: Sort system calls alphabetically

No functional change: sort the system calls alphbetically to make it
easier to add new ones.

Sponsored by: Netflix

(cherry picked from commit ce3e4a3a96d951b4fcf231e8680935c01f1cc3e6)