]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
17 months agokboot: copy EFI's bootinfo.c and adjust
Warner Losh [Tue, 6 Dec 2022 18:00:08 +0000 (11:00 -0700)]
kboot: copy EFI's bootinfo.c and adjust

Copy EFI's bootinfo.c and make minor adjustments for kboot's needs. Do
not connect this to the build just yet until other pieces are in place.

Sponsored by: Netflix

(cherry picked from commit 288626083b6064a777ecfe1f64af06d658ef804c)

17 months agokboot: Mark the EFI specific parts of bootinfo.c
Warner Losh [Tue, 6 Dec 2022 17:55:58 +0000 (10:55 -0700)]
kboot: Mark the EFI specific parts of bootinfo.c

bootinfo.c is about to be shared with kboot since they create
substantially similar environments / metadata tagging / etc. Tag this
with #ifdef EFI for the moment until the proper abstracting out can
happen.

Sponsored by: Netflix

(cherry picked from commit b11aebff4d4a301bfeac516b5be45080c8a11142)

17 months agostand/zlib: Document the upstream issue behind NO_DEPRECATED_NON_PROTOTYPE
Warner Losh [Mon, 5 Dec 2022 23:55:04 +0000 (16:55 -0700)]
stand/zlib: Document the upstream issue behind NO_DEPRECATED_NON_PROTOTYPE

The zlib project has issue https://github.com/madler/zlib/issues/633 to
document its continued use of old K&R-style function definitions.

Suggested by: delphij@
Sponsored by: Netflix

(cherry picked from commit 6b574b3ba99af4ae81d4c619057e737e67523907)

17 months agostand: update prototypes for md_load and md_load64
Warner Losh [Mon, 5 Dec 2022 17:40:15 +0000 (10:40 -0700)]
stand: update prototypes for md_load and md_load64

These are declared as extern in a number of files (some with the wrong
return type). Centralize this in modinfo.h and remove a few extra stray
declarations as well that are no longer used. No functional change.

Note: I've not tried to cope with the bi_load() functions which are the
same logical thing. These will be handled separately.

Sponsored by: Netflix

(cherry picked from commit 335615c4cad79765b46048bfa782120fd9cadb95)

17 months agokboot: Add md_addr to metadata
Warner Losh [Sun, 4 Dec 2022 20:52:22 +0000 (13:52 -0700)]
kboot: Add md_addr to metadata

Save the address of where the metadata is loaded.

Sponsored by: Netflix

(cherry picked from commit 9f7269677c5e70283a16887e1e4b4a1ed95a96fb)

17 months agokboot: Use #define for DT_DIR
Warner Losh [Sun, 4 Dec 2022 20:25:54 +0000 (13:25 -0700)]
kboot: Use #define for DT_DIR

Sponsored by: Netflix

(cherry picked from commit 0ea00e71a2734caeb166287873b697d917e5a92d)

17 months agokboot: powerpc64 has no newfstat system call
Warner Losh [Sun, 4 Dec 2022 20:20:04 +0000 (13:20 -0700)]
kboot: powerpc64 has no newfstat system call

Powerpc doesn't have a newfstat system call. It does have a fstat call,
which we define properly if SYS_newfstat isn't defined.

Sponsored by: Netflix

(cherry picked from commit 8483b3add8e706e6e54e8508e268c623f77031d1)

17 months agokboot: Add aarch64 termios
Warner Losh [Sun, 4 Dec 2022 20:16:32 +0000 (13:16 -0700)]
kboot: Add aarch64 termios

Aarch64 has the generic termios interface, so use termios_gen.h

Sponsored by: Netflix

(cherry picked from commit 58091659cf0805c8b5b977686313d06aeb400446)

17 months agokboot: Add missing license to termios
Warner Losh [Sun, 4 Dec 2022 20:12:09 +0000 (13:12 -0700)]
kboot: Add missing license to termios

I neglected to include the proper license markings on these
files. Remedy that now.

Sponsored by: Netflix

(cherry picked from commit 1fc8e9b833347e1376fa486ff1b0b756acdbfaf6)

17 months agostand: aarch64 has different nlinks than amd64
Warner Losh [Sun, 4 Dec 2022 05:46:21 +0000 (22:46 -0700)]
stand: aarch64 has different nlinks than amd64

Some typedefs are system dependent, so move them into stat_arch.h where
they are used.  On amd64, nlinks is a int64_t, while on aarch64 it's an
int (or int32_t).

Sponsored by: Netflix

(cherry picked from commit 929c6216b1668b9a8bc7d9d9edfd528ef74c69f8)

17 months agokboot: powerpc ldscript catchup
Warner Losh [Sun, 4 Dec 2022 04:41:05 +0000 (21:41 -0700)]
kboot: powerpc ldscript catchup

Catch up with the latest ldscript for powerpc. Make it match others in
the tree.

Sponsored by: Netflix

(cherry picked from commit e3b74ec119a7d98a0f340674e28923707b7166b4)

17 months agostand/efi: Break stlye rules a little for easier sharing
Warner Losh [Sun, 4 Dec 2022 00:23:25 +0000 (17:23 -0700)]
stand/efi: Break stlye rules a little for easier sharing

Break the style rules a little to allow easier sharing between efi and
kboot. This will allow the ifdefs to be fewer in number.

Sponsored by: Netflix

(cherry picked from commit aed1e5d332f9d26cdd8477bc336279217d53ecb8)

17 months agostand/efi: Better include order for sharing
Warner Losh [Sun, 4 Dec 2022 00:23:22 +0000 (17:23 -0700)]
stand/efi: Better include order for sharing

Have a better include order so this can more easily be shared between
EFI and kboot. Fewer ifdefs and the same (enough) include order as
before.

Sponsored by: Netflix

(cherry picked from commit 3f2c1eb5b84317bae98420c1346304b604436727)

17 months agostand/efi: Remove redundant parenthesis
Warner Losh [Sun, 4 Dec 2022 00:23:20 +0000 (17:23 -0700)]
stand/efi: Remove redundant parenthesis

Style: Remove redundant parens.

Sponsored by: Netflix

(cherry picked from commit 3df86732afed7cea51934d613f8aa43b87787cc1)

17 months agostand/efi: Document the copy size trick
Warner Losh [Sun, 4 Dec 2022 00:23:16 +0000 (17:23 -0700)]
stand/efi: Document the copy size trick

We call bi_copymodules twice: once with 0 and once with the size of the
arena. We do this to find the size, it turns out. Document this.

Sponsored by: Netflix

(cherry picked from commit 67e39a0d1bdb24967591721bf7c995d61e0e1c2d)

17 months agokboot: Enable fewer things by default
Warner Losh [Sat, 3 Dec 2022 19:48:23 +0000 (12:48 -0700)]
kboot: Enable fewer things by default

We don't need NFS / network support by default, nor do we need gzip
support. Remove them for now.

Sponsored by: Netflix

(cherry picked from commit cc623784c11df05b3019b282691b6abdd63d9a71)

17 months agokboot: Make dosfs support conditional
Warner Losh [Sat, 3 Dec 2022 19:48:19 +0000 (12:48 -0700)]
kboot: Make dosfs support conditional

Sponsored by: Netflix

(cherry picked from commit 4f6c506c6f44db2ac149a22c1048d526055b37e3)

17 months agokboot: Add readme
Warner Losh [Sat, 3 Dec 2022 19:48:16 +0000 (12:48 -0700)]
kboot: Add readme

Document how to test kboot and how to build a initrd.

Sponsored by: Netflix

(cherry picked from commit 59cbe840cffcd5513e1d3b8736fb6c0d10945ab2)

17 months agokboot: Move archsw init earlier
Warner Losh [Sat, 3 Dec 2022 19:48:11 +0000 (12:48 -0700)]
kboot: Move archsw init earlier

Do archsw init first thing.

Sponsored by: Netflix

(cherry picked from commit a2fbc8859361c7bac7823c0a1978c78df11bc81d)

17 months agokboot: Use unsigned long long.
Warner Losh [Fri, 2 Dec 2022 19:41:01 +0000 (12:41 -0700)]
kboot: Use unsigned long long.

For the 64-bit platforms, this is a nop. Currently kboot only supports
64-bit platforms, though. If we support 32-bit in the future, this will
become important.

Noticed by: rpokala
Sponsored by: Netflix

(cherry picked from commit da5d0a1dbc2838eae7033254705c684d7a013fce)

17 months agokboot: Enhance hostdisk
Warner Losh [Fri, 2 Dec 2022 18:28:08 +0000 (11:28 -0700)]
kboot: Enhance hostdisk

Added missing functionality to allow us to boot off of things like
/dev/nvme0n1p2 successfully. And to list all available devices and
partitions with 'lsdev'.

Sponsored by: Netflix

(cherry picked from commit 7685e8d97a22ae4b58243d6ef67569ea5bcbc988)

17 months agokboot: amd64 use /sys/firmware/memmap to find free memory
Warner Losh [Fri, 2 Dec 2022 18:10:42 +0000 (11:10 -0700)]
kboot: amd64 use /sys/firmware/memmap to find free memory

Use the system's firmware memory map to find a good place to put the
kernel that won't stomp on anything else. While this uses obstensibly MI
interfaces to get this data, arm64 doesn't have this, nor does
powerpc64, so place it here.

Sponsored by: Netflix

(cherry picked from commit c51e1d7c0a79a4fe2774d526ad0393cd2edd3f6c)

17 months agokboot: move to using devparse
Warner Losh [Fri, 2 Dec 2022 18:10:06 +0000 (11:10 -0700)]
kboot: move to using devparse

We can use devparse directly now. No need to invent a kboot_parsedev
that just does what devparse does now that we've refactored.

Sponsored by: Netflix

(cherry picked from commit 6f8e9f22739aa7f5fe997741e9f50a66385c9e0c)

17 months agokboot: Create routines to read Linux tiny files
Warner Losh [Fri, 2 Dec 2022 18:05:58 +0000 (11:05 -0700)]
kboot: Create routines to read Linux tiny files

Most of the files in /sys/ and /proc/ are small with one value. Create
two routines to help us read the file and decode that value.

Sponsored by: Netflix

(cherry picked from commit 7e1a2e46aa9a2f834c33b5c50de0437ac19d7b41)

17 months agostand/ofw: Refactor ofw parsedev
Warner Losh [Wed, 30 Nov 2022 22:10:23 +0000 (15:10 -0700)]
stand/ofw: Refactor ofw parsedev

Both ofw_disk and ofw_net use the same parsedev routine, except for the
string passed in to match the ofw device node's type. Create a routine
to do that and connect these two users up to that.

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

(cherry picked from commit f9ce8da86434867e1e7172fb56a5504f91c98ce4)

17 months agostand/ofw: Use devparse
Warner Losh [Wed, 30 Nov 2022 22:10:18 +0000 (15:10 -0700)]
stand/ofw: Use devparse

Retire the custom parsedev routine and use the standard devparse.

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

(cherry picked from commit 854001759e59172a2760d3a77f37a287f92053b3)

17 months agoofw/disk: Add parsedev support
Warner Losh [Wed, 30 Nov 2022 22:10:11 +0000 (15:10 -0700)]
ofw/disk: Add parsedev support

Add a parsedev support for OpenFirmware disks. We must look at
characteristics of the OFW node to know if we match this device (so
supply a match routine) or not. Add a parsing routine to allocate
devdesc for OpenFirmware disks as well.

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

(cherry picked from commit 88a8c68298dbc86370d9a7eff06314da398829cb)

17 months agostand/ofw: Subclass devnet to cope with ofw's unique needs
Warner Losh [Wed, 30 Nov 2022 22:10:05 +0000 (15:10 -0700)]
stand/ofw: Subclass devnet to cope with ofw's unique needs

We need to match devices in a slightly special way: We have to look up
the path and see if the device is a 'network' device in order to use it.

Sponsored by: Netflix
Tested by: grehan@ (with tweaks to my original patch)
Differential Revision: https://reviews.freebsd.org/D37557

(cherry picked from commit b8ff248f6595067ef9a31d5d4cec5fb9b9052fc3)

17 months agostand/ofw: Add ofw_path_to_handle
Warner Losh [Wed, 30 Nov 2022 22:10:00 +0000 (15:10 -0700)]
stand/ofw: Add ofw_path_to_handle

ofw_path_to_handle converts a path string to a phandle_t. It searches
down the path for the first device whose type matches the passed-in
string.

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

(cherry picked from commit ed3cc2f24829e6c5827f142cfcd9729331a1106c)

17 months agostand: Implement ofw disk print routine
Warner Losh [Wed, 30 Nov 2022 22:09:56 +0000 (15:09 -0700)]
stand: Implement ofw disk print routine

Have lsdev show openfirmware devices.

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

(cherry picked from commit 40d340acb9316db5771fe777e279776b903336d4)

17 months agostand: Add dv_match
Warner Losh [Wed, 30 Nov 2022 22:09:51 +0000 (15:09 -0700)]
stand: Add dv_match

On OpenFirmware, and possibly kboot, we use full path names for the
objects that are the 'device'. kboot uses a hack of knowing that all
disk device nodes start with '/dev', but this generalizes it for
OpenFirmware where both 'block' and 'network' devices live in the same
namespace and one must ask the OF node its type to know if this device
type matches.

For drivers that don't specify, the current convention of using
strncmp() is retained. This is done only in devparse(), but everything
uses it directly (or will soon).

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

(cherry picked from commit a07cef5a738642ae0a39fa513945d9f867a5e2f1)

17 months agostand: parsedev API change: devspec now points to start of full device name
Warner Losh [Wed, 30 Nov 2022 22:09:36 +0000 (15:09 -0700)]
stand: parsedev API change: devspec now points to start of full device name

To support more flexible device matching, we now pass in the full
devspec to the parsedev routines. For everything execpt uboot, this is
just a drop in (since everything except uboot and openfirmware always
uses disk...: and/or zfs:, but openfirmware isn't really affected).

uboot we kludge around it by subtracting 4 from where the rest of the
device name starts. This is unforunate, and can compute the address one
before the string. But we never dereference that address. uboot needs
more work, and this is an acceptable UB until that other work happens.

OFW doesn't really use the parsedev routines these days (since none of
the supported device uses this... yet). It too needs more work, but it
needs device matching support first.

Sponsored by: Netflix
Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D37553

(cherry picked from commit 33bbe5ddcbbce03b6395a4948927643107b55c06)

17 months agostand: create devinit
Warner Losh [Wed, 30 Nov 2022 22:09:29 +0000 (15:09 -0700)]
stand: create devinit

devinit() marches through all the devices, calling the inint routines if
any exist. Replace all the identical copies of this code.

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

(cherry picked from commit 66012c8fc4f92b80a61405dc7e206617e9f08920)

17 months agostand/ofw: ofw_disk isn't really a disk
Warner Losh [Wed, 30 Nov 2022 22:09:23 +0000 (15:09 -0700)]
stand/ofw: ofw_disk isn't really a disk

The rest of the code in the tree assumes that a DEVT_DISK uses a
disk_devdesc to represent the device. However ofw_disk diesn't, so we
can't use disk_fmtdev, nor disk_parsedev. ofw needs to have a
dv_match-like routine to use devpasrse, though, since we have two
drivers (net and block) that claim the same sort of devices (eg
/path/to/ofw-dev) based on the device-type property. In the interim, we
can't use devmatch and ofw_disk's and the default net driver's parsing
is offloaded ofw_parsedev.

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

(cherry picked from commit daaf594e8469b1fb4fb7861c2f7129f4d61c6d4d)

17 months agozfs: Remove devicename_stubs
Warner Losh [Wed, 30 Nov 2022 22:09:18 +0000 (15:09 -0700)]
zfs: Remove devicename_stubs

We no longer need the zfs stubs since we're no longer referencing these
functions outside of zfs.c.

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

(cherry picked from commit bb9f61da17f66352a344e14c4d32fda83126827b)

17 months agostand: make zfs_parsedev static
Warner Losh [Wed, 30 Nov 2022 22:09:14 +0000 (15:09 -0700)]
stand: make zfs_parsedev static

It's now unreferenced outside of zfs.c.

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

(cherry picked from commit 90412431fe1bf5f4a10b68c7938b0fc9f11dc4a2)

17 months agostand/ofw: Access the parsing routine more directly
Warner Losh [Wed, 30 Nov 2022 22:09:09 +0000 (15:09 -0700)]
stand/ofw: Access the parsing routine more directly

We don't need to check if something is a ZFS device. Instead, if the
found device has a parse routine, call it. Otherwise, just copy the
path.

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

(cherry picked from commit d16083815caf32dd117487c709b33669cef4af6f)

17 months agostand/userboot: Move to using common devparse()
Warner Losh [Wed, 30 Nov 2022 22:09:05 +0000 (15:09 -0700)]
stand/userboot: Move to using common devparse()

We no longer need to have to hand-code this for each boot loader since
devparse() handles them all with dv_parsedev().

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

(cherry picked from commit 910de60a7e43c593b5126b2f1ee468c089c8116e)

17 months agostand/i386: Move to using common devparse()
Warner Losh [Wed, 30 Nov 2022 22:09:00 +0000 (15:09 -0700)]
stand/i386: Move to using common devparse()

We no longer need to have to hand-code this for each boot loader since
devparse() handles them all with dv_parsedev().

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

(cherry picked from commit 641a0617e8d060c3c5fb997cee9e2b7fb40d9306)

17 months agostand/efi: Move to using common devparse()
Warner Losh [Wed, 30 Nov 2022 22:08:55 +0000 (15:08 -0700)]
stand/efi: Move to using common devparse()

We no longer need to have to hand-code this for each boot loader since
devparse() handles them all with dv_parsedev().

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

(cherry picked from commit 77378d79f165b59296a0133eb910af55c8b2b600)

17 months agostand: For all disk drivers, connect dv_parsedev to disk_parsedev
Warner Losh [Wed, 30 Nov 2022 22:08:51 +0000 (15:08 -0700)]
stand: For all disk drivers, connect dv_parsedev to disk_parsedev

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

(cherry picked from commit 8337ab69ba8e065e5cfde8f09859ec1d0d47e892)

17 months agostand/zfs: Connect dv_parsedev to zfs_parsedev
Warner Losh [Wed, 30 Nov 2022 22:08:47 +0000 (15:08 -0700)]
stand/zfs: Connect dv_parsedev to zfs_parsedev

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

(cherry picked from commit ca0654bad68d521066497e708cfb56f5f3f5d1fa)

17 months agostand: Introduce devparse to parse device / path strings
Warner Losh [Wed, 30 Nov 2022 22:08:42 +0000 (15:08 -0700)]
stand: Introduce devparse to parse device / path strings

devparse is now the preferred interface to use to parse device
strings or device:/path strings. It parses the passed in string,
mallocs the device's particular devdesc string and returns the
'remainder' of the device:/path for further processing.

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

(cherry picked from commit 781ca0afcd6c64ac3fbaf2a19b1880734cdfe947)

17 months agostand: Introduce new dv_parsedev routine
Warner Losh [Wed, 30 Nov 2022 22:08:36 +0000 (15:08 -0700)]
stand: Introduce new dv_parsedev routine

Allow device classes to define a parsing routine. Most device classes
already have these routines, but there's much duplication in their
use. Define an interface for a common routine to parse an individual
device. By convetion, files have the form "[device:]/path/to/file"
where device is optional (filled in to be the value of currdev)
and it starts with the dv_name field of the device, with the rest
of the name up to the device (typically a unit number, but disks
add partition inforation, and other devices may do artibtrary
otehr things).

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

(cherry picked from commit a0aad69f9556221283b8f6ddcd332329b50463e4)

17 months agostand: Change zfs_parsedev() API
Warner Losh [Wed, 30 Nov 2022 22:08:22 +0000 (15:08 -0700)]
stand: Change zfs_parsedev() API

Change the first argument to zfs_parsedev() to be a pointer to a struct
devdesc *. This now gets filled in with a malloc'd structure that's
returned to the caller that the caller is repsonsible for freeing. Most
nplaces in the tree passed in a malloc'd pointer anyway, and this moves
knowledge of zfs_devdesc more firmly into the zfs.c code.

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

(cherry picked from commit ba11bc368e612e7c5bbc195830a280f8af73ce18)

17 months agostand: Change disk_parsedev() API
Warner Losh [Wed, 30 Nov 2022 22:08:15 +0000 (15:08 -0700)]
stand: Change disk_parsedev() API

Change the first argument to disk_parsedev() to be a pointer to a struct
devdesc *. This now gets filled in with a malloc'd structure that's
returned to the caller that the caller is repsonsible for freeing. Most
places in the tree passed in a malloc'd pointer anyway, and this moves
knowledge of disk_devdesc more firmly into the disk.[ch] code.

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

(cherry picked from commit 17276525fa1a28028f7ca423f365d5081cbe9a97)

17 months agostand/zlib: Zlib still uses K&R function definitions
Warner Losh [Wed, 30 Nov 2022 18:08:24 +0000 (11:08 -0700)]
stand/zlib: Zlib still uses K&R function definitions

So add ${NO_WDEPRECATED_NON_PROTOTYPE} to the CFLAGS of those
files. This can be removed when we import a zlib that's free of this
anachronism.

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

(cherry picked from commit 983a18021decd68fbcf5d14ccd60c3d66dac1c6a)

17 months agoofw_net: Use c99 initializers
Warner Losh [Tue, 29 Nov 2022 21:47:02 +0000 (14:47 -0700)]
ofw_net: Use c99 initializers

Update to use c99 initializers, although there's no plans to change
anything that this would make easier...

Sponsored by: Netflix
Reviewed by: zlei
Differential Revision: https://reviews.freebsd.org/D37442

(cherry picked from commit 4c4563e32dfce0652953fcbd160a9dfdda050cc4)

17 months agostand/ofw: Use strpbrk instead of two strchrs
Warner Losh [Tue, 29 Nov 2022 20:02:40 +0000 (13:02 -0700)]
stand/ofw: Use strpbrk instead of two strchrs

No need to call strchr twice, when one call to strpbrk will do the
job.. Test booted with qemu-powerpc + mac99 successfully.
Minor style(9) tweaks as well.

Sponsored by: Netflix

(cherry picked from commit b60164c9f4d823b3e9fbcb733f92d181c704f415)

17 months agoofw: Remove old K&R function declaration
Warner Losh [Sun, 27 Nov 2022 20:34:33 +0000 (13:34 -0700)]
ofw: Remove old K&R function declaration

We don't need to forward declar strchr anymore.

Sponsored by: Netflix

(cherry picked from commit 9f7156560905f5da0b42dce3e5fb64f77e9f70aa)

17 months agoofw: Cast function pointer to proper type
Warner Losh [Sun, 27 Nov 2022 20:23:28 +0000 (13:23 -0700)]
ofw: Cast function pointer to proper type

clang 15 insists that we call entry() via a function prototype. Rather
than copping out and using (...), cast it to the same prototype that's
used elsewhere (with tweaks to pointers to make them fit into that
prototype). No functional change.

Sponsored by: Netflix

(cherry picked from commit fea231d21b299535302b41ac2e841f8abf1787fc)

17 months agolibsa: Add missing GNU-stack annotations to _setjmp.S.
John Baldwin [Tue, 22 Nov 2022 16:36:40 +0000 (08:36 -0800)]
libsa: Add missing GNU-stack annotations to _setjmp.S.

ld.bfd marks the stack as executable for the crt objects due to the
missing annotations which raises a fatal warning starting with version
2.39.

(cherry picked from commit 69f6399c3733d717bc3dcefda7fcc031f06cef0d)

17 months agostand: Update comment about devdesc
Warner Losh [Sat, 5 Nov 2022 01:45:27 +0000 (19:45 -0600)]
stand: Update comment about devdesc

How devdesc is used is opaque until much code is read. Give a more
useful description of the theory behind it here.

Sponsored by: Netflix

(cherry picked from commit 269865a8eed240f572472750451484feccaeeeea)

17 months agostand: Remove unused enum
Warner Losh [Fri, 4 Nov 2022 21:28:26 +0000 (15:28 -0600)]
stand: Remove unused enum

enum disk_ioctl is unused.  It's only ever defined. All of the stand
code uses DIOCGSECTORSIZE and DIOCGMEDIASIZE instead, both to query and
to implement ioctl.

Sponsored by: Netflix

(cherry picked from commit c9ee39a3f255b62cbf106f4e5a704bcefdef017b)

17 months agostand: Nuke double-semicolons
Elliott Mitchell [Mon, 16 Aug 2021 22:51:38 +0000 (15:51 -0700)]
stand: Nuke double-semicolons

A distinct number of double-semicolons have ended up in FreeBSD.  Take a
pass at getting rid of many of these harmless typos.

Reviewed by: emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/609
Differential Revision: https://reviews.freebsd.org/D31717

(cherry picked from commit 798ea06f07778f69297bcb9c88738d115bf0369e)

17 months agokboot: Add hostfs
Warner Losh [Thu, 27 Oct 2022 17:37:54 +0000 (11:37 -0600)]
kboot: Add hostfs

Add hostfs for the Linux environment. We can't use the userboot one
that's kinda similar because the Linux system calls we have in kboot are
not quite POSIX compliant (Linux takes care of providing the POSIX
interface in libc), so we have to cope with a number of quirks in that
area.

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

(cherry picked from commit 02dba4f75f86f3d5ae5a6a438b5bcfdc667929bb)

17 months agostand/kboot: Make FDT fixup per-arch
Warner Losh [Thu, 27 Oct 2022 17:36:51 +0000 (11:36 -0600)]
stand/kboot: Make FDT fixup per-arch

The fixups needed vary somewhat by architecture, so move the FDT fixup
to be per-arch. Rename the fdt_linux_fixup() routine to be
fdt_arch_fixup() and expect all architecutres to fix things up as
needed.

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

(cherry picked from commit cc9f1b4c35974972c36553d4ca07ac91dc4262a2)

17 months agostand/efi: Simpler construct
Warner Losh [Mon, 24 Oct 2022 18:11:50 +0000 (12:11 -0600)]
stand/efi: Simpler construct

Use 'sizeof(long) == 8' for a compile time constant that can be used as
an initializer rather than #ifdefs.

Sponsored by: Netflix

(cherry picked from commit eca818c872f7ad094f8dac143123e7e8d65f3bcc)

17 months agostand/kboot: hostdisk isn't a DEVT_DISK, use a different value.
Warner Losh [Sat, 22 Oct 2022 15:09:23 +0000 (09:09 -0600)]
stand/kboot: hostdisk isn't a DEVT_DISK, use a different value.

We assume in all the code that a DEVT_DISK uses common/disk.c and/or
common/part.c and we can access a struct disk_devdesc. hostdisk.c
opens raw devices directly, so has no such structures. Define a
kboot-specific DEVT_HOSTDISK and use that instead.

In addition, disk_fmtdev assumes it is working with a struct
disk_devdesc, so write hostdisk_fmtdev as well.

Sponsored by: Netflix

(cherry picked from commit 2cb90a7b2efc41e791c589e17127f63ccf24167c)

17 months agogeli: Move check for DEVT_DISK into geli_probe_and_attach
Warner Losh [Sat, 22 Oct 2022 00:16:56 +0000 (18:16 -0600)]
geli: Move check for DEVT_DISK into geli_probe_and_attach

We only work on DEVT_DISK disks, so move that into the probe to drive
the point home better.

Sponsored by: Netflix

(cherry picked from commit bb3230e40bea68c1a0fc9ba1bee204bc05d7ea78)

17 months agostabd/geli: Bail out if you can't get the disks size
Warner Losh [Fri, 21 Oct 2022 23:39:34 +0000 (17:39 -0600)]
stabd/geli: Bail out if you can't get the disks size

If the DIOCGMEDIASIZE ioctl fails, assume the disk doesn't have geli
encryption. While all disks should implement this, fail safe for disks /
partitions that do not.

Sponsored by: Netflix

(cherry picked from commit 787df454c8175e58131f582c05c169070fb6ca7c)

17 months agokboot: hostdisk add to lsdev output
Warner Losh [Sat, 8 Oct 2022 05:46:20 +0000 (23:46 -0600)]
kboot: hostdisk add to lsdev output

Not entirely sure what to do here, so just list that we're here.

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

(cherry picked from commit 6700f34d126eb4892e24f4c7758e9f570de2fb4e)

17 months agokboot: Move load address stuff to MD code
Warner Losh [Sat, 8 Oct 2022 05:40:56 +0000 (23:40 -0600)]
kboot: Move load address stuff to MD code

The load address computations are highly architecture specific. There
are generic ways that are augmented by specific constraints of specific
way things work on each architecture. Move the current load segment
computations into a MD routine load_addr.

As part of the move, I'm marking kboot_get_kernel_machine_bits as
unused. This arrived in a prior commit, but never seems to have been
connected, suggesting an incomplete merge at the time, or a path not yet
taken.

Create a stub for amd64 that will be filled in with a later commit.

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

(cherry picked from commit beba54e4b8349c5482f92d1abf366cfdc12b2416)

17 months agolibsa/netif.c: Replace #if with #ifdef
Michał Grzelak [Wed, 28 Sep 2022 10:31:25 +0000 (12:31 +0200)]
libsa/netif.c: Replace #if with #ifdef

Follow the convention with *_DEBUG macros in stand/libsa/* and replace
"#if" with "#ifdef".

Reviewed by: kd
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D36740

(cherry picked from commit 7b54d275ef6f74fe6030c85445bd3770d537d408)

17 months agolibsa/arp.c: Change printf format string
Michał Grzelak [Thu, 29 Sep 2022 05:22:47 +0000 (07:22 +0200)]
libsa/arp.c: Change printf format string

Change printf format string to avoid compilation failure when
ARP_DEBUG macro is defined.

Reviewed by: imp
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D36735

(cherry picked from commit c66c6da4f08187deab6a30d4aeb4d6e82088a046)

17 months agolibsa/rarp.c: Change casted type and printf format
Michał Grzelak [Wed, 28 Sep 2022 10:36:53 +0000 (12:36 +0200)]
libsa/rarp.c: Change casted type and printf format

Change the casted type and printf format string to avoid compilation
failure when RARP_DEBUG macro is defined.

Reviewed by: imp
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D36738

(cherry picked from commit ee0d06faa0a5b0e551cac4cfcad68062cb3257c7)

17 months agolibsa/rarp.c: Change printf format string
Michał Grzelak [Wed, 28 Sep 2022 10:34:55 +0000 (12:34 +0200)]
libsa/rarp.c: Change printf format string

Change printf format string to avoid compilation failure when
RARP_DEBUG macro is defined.

Reviewed by: imp
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D36739

(cherry picked from commit 1ed7916188b5a9684414387ff88829b304a858ae)

17 months agostand/elf: Only support swapping headers on powerpc.
Warner Losh [Fri, 16 Sep 2022 15:10:14 +0000 (09:10 -0600)]
stand/elf: Only support swapping headers on powerpc.

Powerpc is currently the only architecture that we support more than one
endian. It's the only one that benefits from this swapping, so restrict
the code to there. This saves about 1k in the i386 BIOS loader.

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

(cherry picked from commit c0ecae78abbe5c925cd05d5e218aa6f038cd03c7)

17 months agostand: Allocate bootinfo rather than have it be static
Warner Losh [Fri, 16 Sep 2022 15:09:41 +0000 (09:09 -0600)]
stand: Allocate bootinfo rather than have it be static

This saves 80 bytes (the new bootinfo structure was 84 bytes, and a
pointer is 4 bytes). The bi_load32 code is the same size.

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

(cherry picked from commit 9758dd3de1cddc8271be8dd6fee69286c5c86535)

stand: Pass in the proper size for bootinfo

Missed one sizeof(bi) -> sizeof(*bi) in 9758dd3de1cdd conversion to
allocating bootinfo.

Noticed by: tijl@
Fixes: 9758dd3de1cdd
Sponsored by: Netflix

(cherry picked from commit 4a676571e382d0188b98134732f421df57a47a87)

17 months agostand: Stop support booting 4.x and earlier kernels
Warner Losh [Fri, 16 Sep 2022 15:09:07 +0000 (09:09 -0600)]
stand: Stop support booting 4.x and earlier kernels

FreeBSD 4.x and earlier used the bi_bios_geom to get the geometry of the
device. Starting in 5.x, with the wdc -> ata rewrite, it was used only
in pc98 kernels to report geometry of the drives. It can be safely
removed as booting kernels this old is no longer supported. This saves
176 bytes in the BIOS loader.

Sponsored by: Netflix
Reviewed by: adrian, emaste
Differential Revision: https://reviews.freebsd.org/D36543

(cherry picked from commit d43bcf62a2182d3f00c11e5145c8912f4468871a)

17 months agostand: Remove dead store to bi_kernelname
Warner Losh [Fri, 16 Sep 2022 15:09:02 +0000 (09:09 -0600)]
stand: Remove dead store to bi_kernelname

We set this value twice: once to 0 and once to the VA that has the name
of the kernel. The first store is redundant. In addition, these two
stores of 0 are also redundant. Since we never set them, they will
always be zero, even if we're called multiple times. This saves 21
bytes on BIOS loader.

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

(cherry picked from commit e895ab3fbdc10fbf944289165c25357cb3f279fe)

17 months agostand: collapse all copies of *copyenv into md_copyenv
Warner Losh [Fri, 16 Sep 2022 15:08:57 +0000 (09:08 -0600)]
stand: collapse all copies of *copyenv into md_copyenv

Use the efi's bi_copyenv to md_copyenv and place it in modinfo.c. Remove
all other nearly identical and efi's has the best error handling.

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

(cherry picked from commit fc352701ff3aeb0af22c0da17c4194cf1f8ad5d0)

17 months agostand: Move MOD_xxx macros from modinfo.h to .c
Warner Losh [Fri, 16 Sep 2022 15:08:52 +0000 (09:08 -0600)]
stand: Move MOD_xxx macros from modinfo.h to .c

Now that MOD_xxx macros are modinfo.c, they don't need to be in
modinfo.h.

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

(cherry picked from commit 2e6ed47a4609ff03a9308a173c64900485172c22)

17 months agostand: Move md_copymodules into modinfo.c and reduce copies
Warner Losh [Fri, 16 Sep 2022 15:08:47 +0000 (09:08 -0600)]
stand: Move md_copymodules into modinfo.c and reduce copies

md_copymodules, bi_copymdoules, bi_copymodules32 (x2) and
bi_copymodules64 (x2) are all the same routine... Replace them all with
md_copymodules. This saves about 800 bytes on i386 BIOS loader, which is
a nice bonus.

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

(cherry picked from commit 5d1531d9d4e7d1b1b706ab23ac3f864416e87522)

stand: fix mismerge

Remove stray line from mismerge of 5d1531d9d4e7. This is no longer
needed.

Fixes: 5d1531d9d4e7
Sponsored by: Netflix

(cherry picked from commit dd2b9c2967767b19bcbc33de0e487405c612f59f)

stand/efi: Call md_copymodules based on __LP64__ to fix 32-bit arm

When I refactored everything, I neglected to pass in the proper is64
value on 32-bit platforms. This corrects that. This prevented armv7 and
armv6 platforms from booting due to misaligned data in the kernel.  The
only platform we support 32-bit booting in armv[67], which I apparently
neglected to test before commiting my refactoring.

Tested by: skibo
Fixes: 5d1531d9d4e7d
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37095

(cherry picked from commit e0c3f66b4d5f0282e9c7c4803c4cd26b5a388a38)

17 months agostand: Create common/modinfo.h
Warner Losh [Fri, 16 Sep 2022 15:08:42 +0000 (09:08 -0600)]
stand: Create common/modinfo.h

Move all the MOD_xxx macros to this header. Each user of this interface
is currently required to define MOD_ALIGNMENT(l). modinfo was selected
because it sits inbetween modules and metadata and will make it easier
to migrate to new, shared intefaces.

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

(cherry picked from commit bca9c87b6104219af35ae5ea4a6af098a1631bca)

17 months agostand: Create MOD_ALIGN macro and use it everywhere
Warner Losh [Fri, 16 Sep 2022 15:08:37 +0000 (09:08 -0600)]
stand: Create MOD_ALIGN macro and use it everywhere

To further reduce the differences between the different MOD_xxx macros,
use MOD_ALIGN to do the proper alignment for the given use.

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

(cherry picked from commit 8b19d28d68a396b0263e3c13a559a31f70eb3b1d)

17 months agostand: use archsw.arch_copyin instead of direct call
Warner Losh [Fri, 16 Sep 2022 15:08:32 +0000 (09:08 -0600)]
stand: use archsw.arch_copyin instead of direct call

This replaces the CALLBACK(copyin, ...) with a call to
archsw.arch_copyin which points to a function that does the
callback. More diff reduction for the multiple copies of these routines
in the tree.

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

(cherry picked from commit 4c670b53a0007739a0fc84ea4bc24a5895953aae)

17 months agostand: use archsw.arch_copyin instead of i386_copyin
Warner Losh [Fri, 16 Sep 2022 15:08:23 +0000 (09:08 -0600)]
stand: use archsw.arch_copyin instead of i386_copyin

Since archsw.arch_copyin is always i386_copyin, this will be a nop in
terms of functionality. This is a diff reduction against other copies of
the code that differ only by what copyin routine they call.

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

(cherry picked from commit a705c72f214293a7aae5f83235a82f126f73e109)

17 months agostand/efi: Clean the proper files
Guido van Rooij [Thu, 15 Sep 2022 15:10:20 +0000 (09:10 -0600)]
stand/efi: Clean the proper files

Need to clean the specific loader we build, not the generic loader.efi

Reviewed by: imp

(cherry picked from commit 0f97a0d425cf0c7fa3966e64b4f88e67a2ee2982)

17 months agostand: Add driver interface docs
Warner Losh [Fri, 9 Sep 2022 23:22:09 +0000 (17:22 -0600)]
stand: Add driver interface docs

Add some rather bare-bones driver interface docs.

Sponsored by: Netflix
Suggestions by: rpokala
Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D35912

(cherry picked from commit 45ad955714f8442a4485510de819755370a76af3)

17 months agoloader.efi(8): document slop control, amd64 nocopy, and amd64 fault commands
Konstantin Belousov [Sun, 4 Sep 2022 07:36:35 +0000 (10:36 +0300)]
loader.efi(8): document slop control, amd64 nocopy, and amd64 fault commands

Reviewed by: imp
Discussed with: gbe (man pages)
English wording help by: rpokala
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D36435

(cherry picked from commit 85c8c0b77d164f00e7e6e1e94544c82041d43223)

17 months agoRevert "stand: Grammar fix for a source code comment"
Gordon Bergling [Mon, 5 Sep 2022 13:40:55 +0000 (15:40 +0200)]
Revert "stand: Grammar fix for a source code comment"

This reverts commit 7d91d6b83e74edf278dde375e6049aca833cbebd.

The orginal comment is more natural.

Reported by:jrtc27

(cherry picked from commit 3c6db09bf45fd48e5e3c207f138ae1914dbeed0c)

17 months agostand/kboot: Add note about why we use MACHINE_ARCH here
Warner Losh [Sun, 4 Sep 2022 15:31:51 +0000 (09:31 -0600)]
stand/kboot: Add note about why we use MACHINE_ARCH here

Normally in the boot loader, we key off of MACHINE since that specifies
the kernel and the loader is very tuned to each type of MACHINE in
general. In this case, however, we're producing a Linux binary, with
Linux system calls encoded in it. These align better along the
MACHINE_ARCH axis of FreeBSD. For PowerPC the system calls are radically
different for each of our MACHINE_ARCHes, with only powerpc64 and
powerpc64le sharing the same numbers and memory layout. The same was
true about mips when it was in the tree. 32-bit arm uses the same
layout, however, for both armv6 and armv7 ports: that can be easily
shared in the unlikely event we support that in the future.

Sponsored by: Netflix

(cherry picked from commit cc7b630cec8320ad979af6b29cb67027f6a95456)

17 months agostand: Grammar fix for a source code comment
Gordon Bergling [Sun, 4 Sep 2022 15:26:48 +0000 (17:26 +0200)]
stand: Grammar fix for a source code comment

- s/that that/that this/

MFC after: 3 days

(cherry picked from commit 7d91d6b83e74edf278dde375e6049aca833cbebd)

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)