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
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
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
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
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
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
The existing logic doesn't seem to make much sense, as we won't filter
on the type if st_shndx != SHN_UNDEF. In practice, this breaks booting
12.3 kernels on newer loaders, as they do have a `kernphys` symbol of
the wrong type (NOTYPE, rather than OBJECT) -- we end up deriving the
wrong value for copy_staging.
It's unclear if this version makes any more sense, but it seems to match
what rtld's matched_symbol() does. Loader doesn't need to care about
STT_FUNC w/ UND shndx, because we won't encounter those; in kmods,
undefined (kernel) functions are NOTYPE.
Reported by: Christian McDonald <cmcdonald netgate com>
Reviewed by: imp, kib, tsoome
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D36975
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
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
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
Notable upstream pull request merges:
#13725 Fix BLAKE3 tuneable and module loading on Linux and FreeBSD
#13756 FreeBSD: Organize sysctls
#13773 FreeBSD: add kqfilter support for zvol cdev
#13781 Importing from cachefile can trip assertion
#13794 Apply arc_shrink_shift to ARC above arc_c_min
#13798 Improve too large physical ashift handling
#13799 Revert "Avoid panic with recordsize > 128k, raw sending and
no large_blocks"
#13802 Add zfs.sync.snapshot_rename
#13831 zfs_enter rework
#13855 zfs recv hangs if max recordsize is less than received
recordsize
Obtained from: OpenZFS
OpenZFS commit: c629f0bf62e351355716f9870d6c2e377584b016
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
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
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
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
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
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
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
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
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
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
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
disk_blocks assumes BIOSDISK_SECSIZE, but the media may not be using
it. In particular, bioscd on Parallels presents a 2K sector size, so
we end up with a short disk_blocks and subsequent validation fails when
trying to read /boot/lua.
PR: 233098
Reviewed by: imp, tsoome
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36490
This corrects an issue introduced in b4cb3fe0e39a3, where a freshly
allocated `DOS_FS` structure would not be initialized properly before
use in `dos_open`.
In case of FAT32 file systems, this would leave `fs->dirents`
uninitialized and - depending on its content and due to checks in
`parsebs` - prevent mounting the file system successfully.
This particularily impacted the EFI loader, as it was sometimes not
able to read files from a FAT32-formatted EFI partition, including
LoaderEnv (`/efi/freebsd/loader.env`).
Accepted by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36482
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
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
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
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
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
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
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
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
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