| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
For greppability, use C99 initializers for the struct file_format.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
When looking for the boot_params symbol we need to get the UEFI memory
map, use host: prefix. The short-circuit we have for this only works
when we have a filesystem. During the earliest parts of boot, we can
sometimes not have this yet, so making this explicit allows these
environments to function.
It's always in the host path. Print better
error messages, and add newlines in two palces.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
| |
ZFSSRC is abiguous on its surface and too clos to ZFSTOP, so rename it
to SAZFSSRC.
Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D53901
|
| |
|
|
|
|
|
|
|
| |
devsw"
This reverts commit dfafdbdfc3e9db8b878283bcbef35f5d8d37dae8. There's no
author, and also problems with it. I'll redo it.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
| |
This change is required for https://reviews.freebsd.org/D49355, so that
we can check if d_dev is uninitialized by checking if it's NULL.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D49705
|
| |
|
|
|
|
|
|
|
|
|
| |
When reading the smbios on Linux we try to access it via /dev/mem. On
some systems we can't do this as /dev/mem is locked down. To handle
this try reading the sysfs file first, and if that fails fall back to
/dev/mem.
Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D51413
|
| |
|
|
|
|
| |
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1705
Closes: https://github.com/freebsd/freebsd-src/pull/1705
|
| |
|
|
|
|
|
|
|
| |
Create a command that just quits out of the loader. Useful for
debugging.
Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D50589
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
arch_loadaddr() is inconsistently used. In fact, I removed it entirely
from kboot because its interface wasn't wide enough (though I broke
powerpc kboot several years ago, and this commit might fix that). For
now, modify uboot to put it into copyin like all the other loaders
do. This might break arm ubldr.
In its place, use the new md_align() and any replacement will be called
from there, or via some explicit init() function.
These changes allow me to load a amd64 kernel via UEFI with all the
modules aligned to 16k.
Sponsored by: Netflix
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D50587
|
| |
|
|
|
|
| |
We don't need/use it.
Sponsored by: Netflix
|
| |
|
|
|
|
|
| |
No need to initialize this at runtime. This trades .bss space + code in
.text for just .data and is net smaller.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In an ideal world, we'd get systbl and efi memory map from
/sys/firmware/efi somewhere. They are currently not published,
but may be in the future.
The systab comes from the first call to the EFI entry point and there's
no way to find it otherwise.
Memmap is obtained from BootServices which is long gone. And besides,
it's modified for the runtime entries for the call to
SetVirtualAddresses call in runtime services. Even though that's in
runtime services, it can be called only once.
kexec tools + Pandora (the kexec boot loader embedded in the Linux
kenrel) don't need this because pandora copyies this structure over when
the new kernel is a bzImage. Our current trampoline doesn't do that, so
we have to get it from the current kernel. Even so, we have to pass the
PAs for the memory map to the trampoline which copies this over (in part
so we can boot an modified kernel, otherwise we could put this into an
alternative entry point, but those are hard to manage).
So, we can sig out the PA of the memory map via this method, but some
care is needed. For the initial round, it suffices. However, Linux on
x86 does some odd things with EFI_RUNTIME that need to be preserved (so
this is a temporary measure until we get the /sys/firmware/efi code
working). The Linux kernel keeps this memory around, but it's not clear
how long. It stops referencing it after it converts it to the BIOS e820
memory map array it uses elsewhere. It seems to be OK to use since our
use case is an immediate boot to FreeBSD, not a boot after Linux runs a
while and had a chance to (maybe) overwrite this data.
Migrating to a proper interface that publishes the modified EFI
map in /sys/firmware/efi/memmap is in the future.
Update the trampoline to copy this data before jumping into the kernel.
We use the simple laucnhing interface instead of the bzImage interface
that kexec_file() uses, so there's no last-second chance to use the
boot params data.
Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D49869
|
| |
|
|
|
|
|
|
|
|
| |
Since the linux kernel doesn't expose enough of the EFI details to
userland via /sys/firmware/efi, write a routine to extract data from the
kernel directly by parsing /proc/kproc and /proc/kallsyms.
Sponsored by: Netflix
Reviewed by: kevans, jhibbits
Differential Revision: https://reviews.freebsd.org/D49868
|
| |
|
|
|
|
|
|
|
| |
For the EFI case, we just need to call efi_bi_loadsmap in bi_loadsmap.
If we need to do BIOS again, we'll revisit.
Sponsored by: Netflix
Reviewed by: kevans, jhibbits
Differential Revision: https://reviews.freebsd.org/D49867
|
| |
|
|
|
|
|
|
|
| |
Use the segs framework to find a place to land the kernel, with the same
super ugly defaults as aarch64.
Sponsored by: Netflix
Reviewed by: kevans, jhibbits
Differential Revision: https://reviews.freebsd.org/D49866
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use populate_avail_from_iomem and efi_read_from_sysfs from the
refactored work rather than replicating them (imperfectly) here.
Note: memmap might need to be revisited. EFI memory maps are complex on
x86 and we might need to reconstruct it from /sys/firmware/memmap as
well as using that for the BIOS case, should we ever want to support
that again (hardware makes no sense, but many VM hosting services use
that). For now, we're going all in on EFI, though, and will revisit what
to do about BIOS later. The zfsboot project suggests BIOS support isn't
really that hard (but is a distraction atm).
Sponsored by: Netflix
Reviewed by: kevans, jhibbits
Differential Revision: https://reviews.freebsd.org/D49864
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move efi_read_from_pa, efi_set_systbl and efi_bi_loadsmap into efi.c
Move prototype for populate_avail_from_efi as well, though that arrived
previously.
Move efi memory map variables into efi.c.
Add efi_read_from_sysfs, but if 0 it out. We'll want to use it if we can
get the proposed /sys/firmware/efi/memmap data published in the same
format and the code works, it's just that the current
/sys/firmware/efi/runtime-memmap isn't complete enough to use.
Sponsored by: Netflix
Reviewed by: kevans, jhibbits
Differential Revision: https://reviews.freebsd.org/D49863
|
| |
|
|
|
|
|
|
|
|
|
|
| |
If we can get an efi memory map, populate_avail_from_efi will create an
avail array. We only use the regiions marked as 'free' to find a place
for the kernel to land. The other regions are also eligible, but usually
too small to materially affect where we'd put the kernel (not to worry,
the kernel will use that memory).
Sponsored by: Netflix
Reviewed by: kevans, jhibbits
Differential Revision: https://reviews.freebsd.org/D49862
|
| |
|
|
|
|
|
|
|
| |
AMD64 kernels have an extra 2MB of padding that we need to account
for. So make the padding proper on a per-architecture basis.
Sponsored by: Netflix
Reviewed by: kevans, jhibbits
Differential Revision: https://reviews.freebsd.org/D49861
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The location of argc argument is a fine limit for the extent of the
stack traceback. We could save the location of return address for the
call to _start_c, but we'd have to move that into MD assembler. While
not hard, it wouldn't improve the traces we can get. And the math to
find it is architecture dependent (though the same for both arm64 and
amd64).
Sponsored by: Netflix
Reviewed by: kevans, andrew, jhibbits
Differential Revision: https://reviews.freebsd.org/D49858
|
| |
|
|
|
|
|
|
| |
Deleting trailing newline.
Sponsored by: Netflix
Reviewed by: kevans, andrew, emaste, jhibbits
Differential Revision: https://reviews.freebsd.org/D49857
|
| |
|
|
|
|
|
|
|
| |
The type that's exposed from sysfs' memory map is 32-bit and so is the
data-type of memory description.
Sponsored by: Netflix
Reviewed by: kevans, andrew, jhibbits
Differential Revision: https://reviews.freebsd.org/D49856
|
| |
|
|
|
|
|
|
|
|
|
| |
Add '.section .note.GNU-stack,"",%progbits' to all assembler. Newer
versions of clang complain when this isn't present because executable
stacks are going away in the future. We don't need an executable stack
anyway.
Sponsored by: Netflix
Reviewed by: kevans, andrew, emaste, jhibbits
Differential Revision: https://reviews.freebsd.org/D49855
|
| |
|
|
|
|
|
|
| |
Also, remove trailing NULL entry that's no longer needed.
Sponsored by: Netflix
Reviewed by: kevans, jhibbits
Differential Revision: https://reviews.freebsd.org/D49854
|
| |
|
|
|
|
|
|
| |
We can call init_avail() multiple times. Each time, we want to toss
whatever garbage may have already been there from a prior failed attempt
to find a good memory map.
Sponsored by: Netflix
|
| |
|
|
|
|
|
| |
Start to move the common efi routines into libkboot by moving the efi
memory map walking and implementing a printing routine around it.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The boot loader pads efi_map_header to start the array of
efi_memory_descriptor entries on the 16-byte-aligned boundary after the
header. Since the header isn't naturally 16-byte aligned, we need to do
this.
We should have used the actual UEFI EFI_MEMORY_ATTRIBUTES_TABLE which
used uint32_t's to pass all this data to the kernel (they never needed
to be 64-bit quantities or size_t's even) since these entries and the
total size of the table is small. However, this ship long since sailed
since we've used these structures for a decade and there's little to be
gained by changing them. The table header we pass to the kernel from the
loader has similar names, but the seamntics of the fields are different.
Sponsored by: Netflix
|
| |
|
|
|
|
| |
Set errno for bad actions in tsetattr to catch bad actions.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
| |
These are needed for the next round of EFI support for amd64 (partially
shared with aarch64, but only partially because the Linux host interfaces
are different to get the same info).
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
| |
This code is really generic segment processing and should live here. It
also interfaces primarily with Linux APIs, so it's also appropriate for
this if we have a version of that runs as a FreeBSD binary using FreeBSD
system calls and APIs, though that's in the future somehow...
Sponsored by: Netflix
|
| |
|
|
|
|
| |
Use SRCS+= to allow for better ifdefs
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
| |
Note that the behavior here is consistent with BIOS and EFI boot.
Reviewed by: imp, markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49293
|
| |
|
|
|
|
|
|
| |
These are often needed for copying to the staging area or just general
page table calculations on amd64.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1446
|
| |
|
|
|
|
|
| |
On amd64, we need this to setup the page tables.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1446
|
| |
|
|
|
| |
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1446
|
| |
|
|
|
|
|
|
| |
For kboot, we still have to declare it manually since we don't always
include loader_efi.h
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1446
|
| |
|
|
|
|
|
| |
But comment out FDT stuff for amd64 built inside kboot. This also
restricts a bit the powerpc platforms we build on to powerpc64.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Each incompatible change we make, we bump the major version. We've not
done the bump in a while, so sync everybody to 3.0. Anything older than
3.0 will be given a warning that their boot loader is too old. We check
only the major version, though, so minor versions can still be bumped
for individual loaders (though I honestly doubt we'll ever need to do
that again).
Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D45888
|
| |
|
|
|
|
|
|
|
|
| |
We long ago changed newvers.sh to make these comments bogus. Remove
them since every single one of them is broken after the $FreeBSD$
removal.
Sponsored by: Netflix
Reviewed by: kevans, jhb
Differential Revision: https://reviews.freebsd.org/D45879
|
| |
|
|
|
|
|
| |
This is a residual of the $FreeBSD$ removal.
MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
| |
ld.bfd doesn't understand elf64-aarch64 but does have
elf64-littleaarch64. Switch to this so we can link kboot with it.
While here switch to the single format version. We are unlikely to
support booting from a big-endian Linux.
Reviewed by: imp, emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D45258
|
| |
|
|
| |
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move the initialization of hostfs_root to be a bit sooner. While it
doesn't matter for the default case, we may want to use hostfs files
sooner.
Also, while we're here, remove kboot.conf. It duplicates the command
line and has proven difficult to use. It will be replaced by an early
script that can influence the state of the boot loader before we select
a device to boot from (including strongly suggesting which one to boot
from).
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move the console probing to as early as possible. There's no real
support for anything but hostcons, and setting it up early will show
other error messages.
ACPI and SMBIOS probing can be done just after we have the console, so
move it there. This allows other parts of the early code to use info
from that, as well as overriding and env vars set by these things on the
command line (smbios data may be wrong during initial development phases
as the automated way to populate per-board data may not be established,
etc).
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
| |
If we are able to open /sys/firmware/fdt, but aren't able to read it,
fall back to /proc/device-tree. Remove comment that's not really true,
it turns out.
Sponsored by: Netflix
|
| |
|
|
|
|
|
| |
Rather than checking against the (incorrect) -511, use the
is_linux_error() function to check to see if host_mmap failed.
Sponsored by: Netflix
|
| |
|
|
|
|
|
|
|
| |
If we can read the UEFI memory map, go ahead and print the memory map.
While the kernel prints this with bootverbose, having it at this stage
is useful for debugging other problems.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44287
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The host_* syscalls are all raw Linux system calls, not the POSIX
wrappers that glibc / musl create. So we have to ranage change the
return value of host_llseek correctly to use the negative value hack
that all Linux system calls use.
This fixes a false positive error detection when we do something like
lseek(fd, 0xf1234567, ...); This returns 0xf1234567, which is a negative
value which used to trigger the error path. Instead, we check using the
is_linux_error() and store the return value in a long. Translate that
errno to a host errno and set the global errno to that and return
-1. lseek can't otherwise return a negative number, since it's the
offset after seeking into the file, which by definition is positive.
This kept the 'read the UEFI memory map out of physical memory' from
working on aarch64 (whose boot loader falls back to reading it since
there are restrictive kernel options that can also prevent it), since
the physical address the memory map was at on my platform was like
0xfa008018.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44286
|
| |
|
|
|
|
|
|
|
|
| |
offset is signed. Copy it to the unsigned res before shifting. This
avoids any possible undefined behavior for right shifting signed
numbers. No functional change intended (and the code generated is the
nearly same for aarch64).
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44285
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Linux has the convention of returning -ERRNO to flag errors from its
system calls. Sometimes other negative values are returned that are
success... However, only values -1 to -4096 (inclusive) are really
errors. The rest are either truncated values that only look negative (so
use long instead of int), or are things like addresses or legal unsigned
file offsets or similar that are successful returns. Filter out the
latter.
Sponsored by: Netflix
|