| d7e6ab7a | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: Add support for UEFI booting amd64
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 sys
kboot: Add support for UEFI booting amd64
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
show more ...
|
| f3c0d74e | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: Implement data_from_kernel to read kernel variables
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
kboot: Implement data_from_kernel to read kernel variables
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
show more ...
|
| b7d1c3fd | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot/amd64: Use efi_bi_loadsmap in bi_loadsmap
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
kboot/amd64: Use efi_bi_loadsmap in bi_loadsmap
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
show more ...
|
| 50bc81e7 | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot/amd64: Use segs framework to find kernel location
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:
kboot/amd64: Use segs framework to find kernel location
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
show more ...
|
| 9acf6422 | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot/amd64: Use common routines for memory map parsing
Use populate_avail_from_iomem and efi_read_from_sysfs from the refactored work rather than replicating them (imperfectly) here.
Note: memmap
kboot/amd64: Use common routines for memory map parsing
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
show more ...
|
| 92ad79ec | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: Move common EFI stuff from aarch64 to libkboot
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 pre
kboot: Move common EFI stuff from aarch64 to libkboot
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
show more ...
|
| 988ee1cc | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: Method to populate the avail array from EFI map
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
kboot: Method to populate the avail array from EFI map
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
show more ...
|
| 0c48531b | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: Account for machine specific padding
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 Re
kboot: Account for machine specific padding
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
show more ...
|
| f0f44cdb | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: Save the upper limit of the call stack.
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 _star
kboot: Save the upper limit of the call stack.
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
show more ...
|
| 5fb044c8 | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: format nit
Deleting trailing newline.
Sponsored by: Netflix Reviewed by: kevans, andrew, emaste, jhibbits Differential Revision: https://reviews.freebsd.org/D49857 |
| 14acbf61 | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: Add option to parse 32-bit quantity
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, andre
kboot: Add option to parse 32-bit quantity
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
show more ...
|
| 58c99df2 | 17-Apr-2025 |
Warner Losh <imp@FreeBSD.org> |
kboot: .note.GNU-stack is needed
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 th
kboot: .note.GNU-stack is needed
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
show more ...
|