opnsense-src/stand
Warner Losh d7e6ab7a97 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
2025-04-17 15:56:47 -06:00
..
arm64 Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
common loader: Remove unneeded includes 2025-04-17 15:56:45 -06:00
defaults loader: Add loader_menu 2025-04-17 10:18:48 +02:00
efi loader/efi: strip trailing whitespace 2025-04-11 16:02:58 -06:00
fdt Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
ficl stand: Remove dangling mips references 2024-02-28 07:09:41 -07:00
ficl32 Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
fonts Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
forth loader: set boot_safe when safe mode is selected 2024-12-13 22:31:28 -06:00
i386 i386/loader: force 4k linker max page size 2025-03-19 12:56:34 -07:00
images Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
kboot kboot: Add support for UEFI booting amd64 2025-04-17 15:56:47 -06:00
kshim stand/kshim: Replace devclass_equal with calls to strcmp 2025-01-10 23:03:32 -05:00
liblua Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
liblua32 Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libofw Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libsa loader: Add the CPU identification string to the data which is visible 2025-04-10 21:01:55 -07:00
libsa32 Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
lua loader: Add loader_menu 2025-04-17 10:18:48 +02:00
man loader: set boot_safe when safe mode is selected 2024-12-13 22:31:28 -06:00
powerpc ports/filesystems: Fix fallout 2025-01-27 15:03:10 -05:00
uboot stand: use globals for the kernel and module types 2025-01-24 14:29:39 -07:00
usb stand/usb: Quiet warnings so this builds again 2025-01-10 23:03:32 -05:00
userboot stand: use globals for the kernel and module types 2025-01-24 14:29:39 -07:00
defs.mk Add option to clear caller-used registers on function return. 2025-01-22 19:33:23 +01:00
fdt.mk stand: Rename LIBFDT to LIBSAFDT 2023-11-07 09:57:32 -05:00
ficl.mk Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
loader.mk loader/loader.mk: add docs for LOADER_*_SUPPORT variables 2024-10-24 20:26:26 -06:00
lua.mk Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile loader: Don't need the arch list 2024-11-12 22:01:24 -07:00
Makefile.amd64 Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
Makefile.inc Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
veriexec.mk libsecureboot do not report expected unverified files 2024-02-12 14:35:01 -08:00