aboutsummaryrefslogtreecommitdiff
path: root/stand/efi/loader
Commit message (Collapse)AuthorAgeFilesLines
* amd64 loader: Use efiserialio for Hyper-V booted systemsWei Hu5 days4-7/+54
| | | | | | | | | | | | | | | | | | | | | | | 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)
* Support SMBIOS v3 for 64-bit entry systemsJohn-Mark Gurney2023-02-221-1/+2
| | | | | | | | | | | | 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
* Skip EFI framebuffer information if there is noneSimon J. Gerraty2023-02-061-9/+12
| | | | | | | Avoid several lines of useless info if there is no EFI framebuffer Reviewed by: stevek, imp Differential Revision: https://reviews.freebsd.org/D38393
* loader.efi: include help.fdt for FDT-enabled loaderMitchell Horne2023-02-031-0/+1
|
* loader: always install help filesMitchell Horne2023-02-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* stand: share bootinfo.c between EFI and KBOOTWarner Losh2023-02-031-2/+4
| | | | | | | | | | | | | | | 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
* efiserialio: use port settings (sio->Mode) for initial setupToomas Soome2023-02-031-16/+22
| | | | | | | | | | 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
* stand: create common set_currdevWarner Losh2023-01-111-14/+0
| | | | | | | | | | | | 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
* stand: Create common gen_setcurrdev and replace codeWarner Losh2023-01-111-2/+2
| | | | | | | | | | 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
* stand/efi: Better variable nameWarner Losh2023-01-091-4/+4
| | | | | | | | 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
* loader.efi: make sure kernel image is executableRobert Clausecker2023-01-051-4/+4
| | | | | | | | | | | | | | 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
* stand/efi: remove unused local varaiblesWarner Losh2022-12-071-2/+1
| | | | | | Remove some unused local variables. No functional change. Sponsored by: Netflix
* kboot: Mark the EFI specific parts of bootinfo.cWarner Losh2022-12-071-0/+16
| | | | | | | | | 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
* stand: update prototypes for md_load and md_load64Warner Losh2022-12-051-1/+0
| | | | | | | | | | | 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
* stand/efi: Break stlye rules a little for easier sharingWarner Losh2022-12-041-2/+3
| | | | | | | Break the style rules a little to allow easier sharing between efi and kboot. This will allow the ifdefs to be fewer in number. Sponsored by: Netflix
* stand/efi: Better include order for sharingWarner Losh2022-12-041-1/+1
| | | | | | | | 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
* stand/efi: Remove redundant parenthesisWarner Losh2022-12-041-1/+1
| | | | | | Style: Remove redundant parens. Sponsored by: Netflix
* stand/efi: Document the copy size trickWarner Losh2022-12-041-1/+1
| | | | | | | 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
* stand: create devinitWarner Losh2022-11-301-3/+1
| | | | | | | | 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
* stand/efi: Simpler constructWarner Losh2022-10-241-7/+1
| | | | | | | Use 'sizeof(long) == 8' for a compile time constant that can be used as an initializer rather than #ifdefs. Sponsored by: Netflix
* stand/efi: Call md_copymodules based on __LP64__ to fix 32-bit armWarner Losh2022-10-231-2/+8
| | | | | | | | | | | | | 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
* stand: collapse all copies of *copyenv into md_copyenvWarner Losh2022-09-161-40/+1
| | | | | | | | 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
* stand: Move md_copymodules into modinfo.c and reduce copiesWarner Losh2022-09-161-37/+2
| | | | | | | | | | 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
* stand: Create common/modinfo.hWarner Losh2022-09-161-60/+6
| | | | | | | | | | 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
* stand: Create MOD_ALIGN macro and use it everywhereWarner Losh2022-09-161-4/+5
| | | | | | | | 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
* stand/efi: Clean the proper filesGuido van Rooij2022-09-151-1/+1
| | | | | | Need to clean the specific loader we build, not the generic loader.efi Reviewed by: imp
* stand: Parse all arguments passed by UEFIMichael Gmelin2022-09-061-1/+1
| | | | | | Approved by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D36457
* stand: Remove a double word in a source code commentGordon Bergling2022-09-041-1/+1
| | | | | | - s/the the/the/ MFC after: 3 days
* stand: More sensible defaults when ConOut is missingWarner Losh2022-08-274-2/+37
| | | | | | | | | | | | | | | | | 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
* stand: Use bool for stage_offset_setWarner Losh2022-08-211-4/+4
| | | | | | stage_offset_set is a boolean, convert it to a bool. Sponsored by: Netflix
* stand: efi_fmtdev can be reduced to devformatWarner Losh2022-08-112-3/+3
| | | | | | | | 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
* stand: Move quit command to common commandsWarner Losh2022-07-301-9/+0
| | | | | | | | | | | | | 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
* loader.efi: faults could try to print out call traceToomas Soome2022-07-142-0/+40
| | | | | | | | | | | | 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
* amd64/efi: Remove setting hints for rsdpWarner Losh2022-07-021-12/+0
| | | | | | | | | | | 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
* loader: Set preferred kenv for acpi.rsdp on arm64Warner Losh2022-07-021-0/+15
| | | | | | | | | | | | 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
* Remove "All Rights Reserved" from Foundation copyrightsEd Maste2022-06-307-7/+0
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* loader.efi: fix panic() after BS offToomas Soome2022-06-191-2/+6
| | | | | | | | | | panic() is using multiple services - attempting to read keyboard, accessing time functions and finally, exiting the loader. Protect all the accessed listed above. Note, when BS are off, we really can not just exit the loader, we only can reboot. MFC after: 1 week
* Set mm before passing it to the UEFI firmwareAndrew Turner2022-05-211-0/+1
| | | | | | | | | | | | | | | | When reading the UEFI memory map we pass in a pointer to the memory to hold the map. Unfortunately it wasn't initialised before the first use so clang decided it was undefined behaviour so the entire loop was removed. This leads to everything in bi_load after this to also be removed as dead code. The next function after bi_load in the binary is efi_copy_init. The above caused us to enter efi_copy_init with a return address of the start of the function. Because of this it would enter an infinite loop of calling the function, allocating memory, then returning to the start of the function. PR: 264021
* Add support for getting early entropy from UEFIColin Percival2022-02-171-0/+42
| | | | | | | | | | | | | | | | | | UEFI provides a protocol for accessing randomness. This is a good way to gather early entropy, especially when there's no driver for the RNG on the platform (as is the case on the Marvell Armada8k (MACCHIATObin) for now). If the entropy_efi_seed option is enabled in loader.conf (default: YES) obtain 2048 bytes of entropy from UEFI and pass is to the kernel as a "module" of name "efi_rng_seed" and type "boot_entropy_platform"; if present, ingest it into the kernel RNG. Submitted by: Greg V Reviewed by: markm, kevans Approved by: csprng (markm) MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D20780
* stand/efi: Pass --no-dynamic-linker to ld.bfd >= 2.34.John Baldwin2022-02-021-0/+3
| | | | | | | | | | ld.bfd in binutils 2.34+ now reports an error in more cases for custom ldscripts that do not place PHDRs in a LOAD segment. However, EFI binaries are not dynamic binaries which need PHDRs, so pass --no-dynamic-linker to disable this check. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D34124
* loader.efi: to preserve heap space, use AllocatePages() for shadow_fbToomas Soome2021-12-221-2/+11
| | | | | | | | | shadow FB size could be rather large and depends on resolution, instead of using heap, allocate dedicated space outside of heap. Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D33600 MFC after: 2 weeks
* Don't sync the I/D caches when they are coherentAndrew Turner2021-12-201-1/+1
| | | | | | | | | | | | In the arm64 loader we need to syncronise the I and D caches. On some newer CPUs the I and D caches are coherent so we don't need to perform these operations. While here remove the arguments to cpu_inval_icache as they are unneeded. Reported by: cperciva Tested by: cperciva Sponsored by: Innovate UK
* loader.efi: Do not use as frame buffer BLT-only GOPs.Alexander Motin2021-12-161-4/+16
| | | | | | | | | | | | Kernel needs physical frame buffer address and size, which Block Transfer-only Graphics Output Protocol instances do not have. Some recent ASUS boards like PRIME Z690M-PLUS D4 and PRIME H570-Plus report two GOPs, out of which the second one support ConOut protocol, that made it preferable, but is BLT-only, that made console unusable. Discussed with: tsoome (previous version) MFC after: 1 week
* loader: framebuffer should only be written intoToomas Soome2021-12-111-0/+3
| | | | | | | | Reading from Write Combining memory can be very-very slow. Try to use shadow buffer to avoid such reads. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D33305
* loader: abstract boot services exiting to libefi functionWarner Losh2021-11-211-4/+2
| | | | | | | | | Move direct call of ExitBootServices to efi_exit_boot_services. This function sets boot_services_active to false so callers don't have to do it everywhere (though currently only loader/bootinfo.c is affected). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32226
* loader: Do not force comconsole for arm and arm64Emmanuel Vadot2021-11-161-1/+1
| | | | | | | | | This makes GOP not probed on some situation (AMD Card on PCIe slot with EDK2 as we have a SERIAL_IO_PROTOCOL compatible uart). Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D32992 Sponsored by: Beckhoff Automation GmbH & Co. KG
* loader: lsefi: Print more informationEmmanuel Vadot2021-11-161-1/+25
| | | | | | | | | | | Printing the EFI_HANDLE pointer isn't very useful. If the handle have a IMAGE_DEVICE_PATH or a DEVICE_PATH protocol print it. This makes it easier to see which devices are present and what protocol they expose. Reviewed by: imp, tsoome Differential Revision: https://reviews.freebsd.org/D32991 Sponsored by: Beckhoff Automation GmbH & Co. KG
* efi: switch boot_services_gone to boot_services_activeWarner Losh2021-11-042-6/+2
| | | | | | | | | | | Turn the presence or absence of boot services into a positive bool (and change its type to bool). Move declaration to efi.h in the global variables section. Sponsored by: Netflix Reviewed by: tsoome, kib Differential Revision: https://reviews.freebsd.org/D31814
* loader.efi: remove extra extern STWarner Losh2021-09-301-2/+0
| | | | | | | | The definition for 'ST' is in efilib.h, so we don't need extern ST here. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D32225
* efi loader: Call tslog_init from efi_mainColin Percival2021-09-252-2/+4
| | | | | | | We were calling tslog_init from main; no reason to wait that long. Fixes: f49381ccb6bc efi/loader: Call tslog_init Sponsored by: https://www.patreon.com/cperciva