We have plenty of stack in the EFI case, so use it instead of the
complicated malloc / free dance.
Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D39415
Implement ZFS bootonce protocol. We pass zfs-bootonce=t to the next boot
stage as a command line argument. Unlike zfsboot -> loader handoff in
the BIOS case, we don't use the OS_BOOTONCE_USED. This would require
modifications to loader.efi which would only server to make it more
complicated. Instead, use the command line parsing interface for the
boot1.efi -> loader.efi to pass in the zfs-bootonce kenv that will be
needed by rc.d/zfsbe to activate the BE if boot progresses that far.
Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D39412
Sometimes filesystem modules need to pass details of the state of the
filesystem to later stages of a boot. Provide a generic method to do
so. We'll add them after any env variables set in our config files.
Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D39407
This commentary was carried over from the x86 version of the same code,
but has actually been inaccurate for a while now. As of FreeBSD 12.x,
all environments are used unless they disable each other. See
39d44f7f15 ("kern_environment: use any provided environments [...]")
for details.
Reviewed by: imp
Differentiala Revision: https://reviews.freebsd.org/D35695
- Mark the file as an executable in the COFF header.
- Provide separate .text and .data sections.
- Provide sane file and section alignment values. These values are the
defaults defined in the PE specification.
- Set appropriate characteristics for each of .text and .data.
This is required for the MS devkit to load our UEFI image.
Obtained from: OpenBSD via allanjude
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D37765
The hang basically bricks a physical box and it can be recovered
only if you are able to boot from alternate media. This isn't a
perfect fix, but throw it in before loader experts decide on
proper one.
Submitted by: whu
Fixes: 927358dd98
UEFI provides ConIn/ConOut handles for consoles that it supports,
which include the text-video and serial ports. When the serial port
is available, use the UEFI driver instead of direct io-port accesses
to avoid conflicts between the firmware and direct hardware access, as
happens on Hyper-V (Azure) setups.
This change enables efiserialio to be built for efi-amd64 and has
higher order priority vs comconsole, and only uses efiserialio
if the hypervisor is Hyper-V. When efiserialio successfully
probes, it will set efi_comconsole_avail=true which will prevent
comconsole from probing in this setup.
Tested on Hyper-V, ESXi and Azure VMs.
PR: 264267
Reviewed by: kevans, whu
Tested by: whu
Obtained from: Rubicon Communications, LLC (Netgate)
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC (Netgate)
Summary:
Under QEMU on arm64 systems, the smbios table is above 4GB
requiring a 64-bit address to access.
Reviewers: manu
Subscribers: imp, bcran, dab
Differential Revision: https://reviews.freebsd.org/D38721
Address two issues with current help file logic:
The existing condition prevents the common help file from being
installed when there are no additional help files defined. This results
in no loader.help on EFI platforms, for example.
Second, due to the fact that we build and install multiple loader types,
each successive install will clobber the previous loader.help. The
result is that we could lose type-specific commands, or possibly list
them in loaders that do not have such commands.
Instead, give each loader type a uniquely named help file. The EFI
loader will look for /boot/loader.help.efi, userboot will look for
/boot/loader.help.userboot, etc. The interpreter variant has no effect
on which help file is loaded.
This leaves the old /boot/loader.help unused.
Some credit for the final approach goes to Mathieu <sigsys@gmail.com>
for their version of the fix in https://reviews.freebsd.org/D22951.
PR: 267134
Reported by: Daniel O'Connor <darius@dons.net.au>
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28591
Connect efi's bootinfo.c to the kboot build, and adjust to use
the kboot specific routines.
The getrootmount() call is independent of EFI. Remove ifdefs so it's
called for kboot too.
The differences between the kboot and efi bootinfo.c files are now tiny.
This could use some more refactoring, but this is a working checkpoint.
Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D38350
Use serial port setup done by system firmware.
ARM64 Hyper-V does hung if we attempt to override the defaults,
therefore we should default to use settings from firmware.
Tested by: schakrabarti@microsoft.com
PR: 266248
MFC after: 1 week
Pull together the nearly identical copies of set_currdev in i386,
userboot and efi. Other boot loaders have variances that might be fine
to use the common routine, or not. Since they are harder to test for me,
and ofw and uboot do handle these setting differently, leave them be for
now.
Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38005
Replace 4 identical copies of *_setcurrdev with gen_setcurrdev to avoid
having to create a 5th copy. uboot_setcurrdev is actually different and
needs to remain separate (even though it's quite similar).
Sponsored by: Netflix
Reviewed by: fuz@fuz.su, kevans
Differential Revision: https://reviews.freebsd.org/D38003
sanity_check_currdev returns true if it found a kernel or a sane loader
config file. A better name for this would be 'bootable' rather than 'rv'
which connotes in other places an errno value or similar.
Sponsored by: Netflix
Pass in 'true' if you'd like to search this device's partitions or
'false' if you should just search the device. EFI and (in the future)
kboot have discrete partitions that aren't accessed via the full disk
device. Weird things happen if you try to search in these cases.
Sponsored by: Netflix
The Windows Dev Kit 2023 (Volterra) has an UEFI implementation that maps
EfiLoaderData pages as non-executable. Map the kernel as EfiLoaderCode
to ensure that it can be executed.
With this change and another in review, FreeBSD boots to the mountroot
prompt if hw.pac.enable = 0 is set in loader.conf(5).
Reviewed by: andrew, imp, tsoome
Sponsored by: Berliner Linux User Group e.V.
Sponsored by: spline / FU-Berlin
Differential Revision: https://reviews.freebsd.org/D37931
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
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
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
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
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
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
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
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
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: 5d1531d9d4
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37095
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
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
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
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
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
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
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
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
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
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