aboutsummaryrefslogtreecommitdiff
path: root/stand/efi/loader
Commit message (Collapse)AuthorAgeFilesLines
* stand/efi: add modulep to kernel metadataRoger Pau Monné2021-02-161-3/+6
| | | | | | | | | | | | | | This mirrors the functionality of the BIOS amd64 bi_load function, that stashes the absolute address of the module metadata. This is required for booting as a Xen dom0 that does relocate the modulep and the loaded modules, and thus requires adjusting the offset. No functional change introduced, further patches will make use of this functionality for Xen dom0 loading. Sponsored by: Citrix Systems R&D Reviewed by: imp Differential revision: https://reviews.freebsd.org/D28496
* stand/efi: allow not exiting boot servicesRoger Pau Monné2021-02-166-14/+20
| | | | | | | | | | | | | | | | | | Xen requires that UEFI BootServices are enabled in order to boot, so introduce a new parameter to bi_load in order to select whether BS should be exited. No functional change introduced in this patch, as all current users of bi_load request BS to be exited. Further changes will make use of this functionality. Note the memory map is still appended to the kernel metadata, even when it could be modified by further calls to the Boot Services, as it will be used to detect if the kernel has been booted from UEFI. Sponsored by: Citrix Systems R&D Reviewed by: tsoome, imp Differential revision: https://reviews.freebsd.org/D28495
* loader.efi: There are systems without ConOut, also use ConOutDevToomas Soome2021-02-041-0/+2
| | | | | | | | Conout does contian the default output device name. ConOutDev does contain all possible output device names, so we can use it as fallback, when there is no ConOut. PR: 253253
* loader: create built in font from bold font faceToomas Soome2021-01-231-1/+1
| | | | | We did replace full version of default font 8x16v with bold, also use bold version for built in font.
* loader.efi: commands gop, uga and autoresize should use cached dataToomas Soome2021-01-171-30/+17
| | | | | We are setting up pointers for gop or uga protocol in efi_find_framebuffer(), reuse those pointers.
* loader.efi: variable 'hlist' is uninitializedToomas Soome2021-01-171-0/+1
| | | | framebuffer.c:481:65: error: variable 'hlist' is uninitialized
* loader.efi: unused variable 'mode'Toomas Soome2021-01-171-1/+0
| | | | | framebuffer.c:707:8: error: unused variable 'mode' [-Wunused-variable] u_int mode;
* loader.efi: handle multiple gop instancesToomas Soome2021-01-161-1/+36
| | | | | | | | Some systems may provide multiple GOP instances and not all are bound to hardware. The current loader is picking up the first GOP, which may not be usable. Instead we load the GOP handle array, and test every handle to have registered ConOut protocol. If ConOut is present, we can use this GOP handle to open GOP protocol.
* loader.efi: reworked framebuffer setupToomas Soome2021-01-124-21/+70
| | | | | | | | | | | | | | Pass gfx_state to efi_find_framebuffer(), so we can pick between GOP and UGA in efi_find_framebuffer(), also we can then set up struct gen_fb in gfx_state from efifb and isolate efi fb data processing into framebuffer.c. This change does allow us to clean up efi_cons_init() and reduce BS->LocateProtocol() calls. A little downside is that we now need to translate gen_fb back to efifb in bootinfo.c (for passing to kernel), and we need to add few -I options to CFLAGS.
* loader.efi: efifb_mask_from_pixfmt is missing PixelBltOnlyToomas Soome2021-01-111-0/+1
| | | | We are missing way to set RGB masks for BLT only framebuffer.
* loader: implement framebuffer consoleToomas Soome2021-01-024-14/+35
| | | | | | | | | | | | | | | | | | | | | | | Draw console on efi. Add vbe framebuffer for BIOS loader (vbe off, vbe on, vbe list, vbe set xxx). autoload font (/boot/fonts) based on resolution and font size. Add command loadfont (set font by file) and variable screen.font (set font by size). Pass loaded font to kernel. Export variables: screen.height screen.width screen.depth Add gfx primitives to draw the screen and put png image on the screen. Rework menu draw to iterate list of consoles to enamble device specific output. Probably something else I forgot... Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27420
* efi loader: fix typos in a commentEric van Gyzen2021-01-011-4/+4
| | | | | | ...mostly because it's a harmless way to try the shiny new git repo. Sponsored by: Dell EMC Isilon
* Drop EFI_STAGING_SIZE back down to 64MWarner Losh2020-12-171-3/+1
| | | | | | | | | | | vmware can't cope with anything larger than 64MB. Drop this back to 64MB everywhere but arm. PR: 251866 MFC After: 1 week Notes: svn path=/head/; revision=368721
* loader: Ignore the .interp section on RISC-VJessica Clarke2020-12-141-0/+1
| | | | | | | | | | | | | | Without this we risk having the .interp section be placed earlier in the file and mess with section offsets; in particular it has been seen to be placed at the start of the file and cause the PE/COFF header to not be at address 0. This is the same fix as was done for arm64 in r365578. Reviewed by: mhorne, imp Approved by: mhorne, imp Differential Revision: https://reviews.freebsd.org/D27603 Notes: svn path=/head/; revision=368626
* Unobfuscate "KERNLOAD" parameter on amd64. This change lines-up amd64 with theMaxim Sobolev2020-11-251-5/+3
| | | | | | | | | | | | | | | | | i386 and the rest of supported architectures by defining KERNLOAD in the vmparam.h and getting rid of magic constant in the linker script, which albeit documented via comment but isn't programmatically accessible at a compile time. Use KERNLOAD to eliminate another (matching) magic constant 100 lines down inside unremarkable TU "copy.c" 3 levels deep in the EFI loader tree. Reviewed by: markj Approved by: markj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D27355 Notes: svn path=/head/; revision=368041
* Add 'netserver' command to EFI loader.Michal Meloun2020-10-141-0/+35
| | | | | | | | | | | | | | | | | | In some environments is difficult to access bootp/dhcp configuration as "standard user". Add a command that allows to set or display the URI of the network server used as "net:" device. Currently only tftp and nfs protocols are supported. Typical usage pattern is: netserver tftp://192.168.168.1/path_to_obj_dir/arm.armv7/sys/GENERIC/ boot net:kernel Reviewed by: imp, kevans MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D26736 Notes: svn path=/head/; revision=366700
* Use adrp in the arm64 efi loaderAndrew Turner2020-10-131-5/+10
| | | | | | | | | | | | | | | | | On startup the arm64 efi loaders need to know PC-relative addresses. Previously we used the adr instruction to find this address, however this instruction is limited to +/- 1MiB. Switch to adrp to find the 4k page the address is within and an add to set the bottom 12 bits. This lets us address +/- 4GiB which should be large enough for now. Reported by: imp MFC after: 2 weeks Sponsored by: Innovate UK Notes: svn path=/head/; revision=366670
* Link efi programs with -pie rather than -sharedAlex Richardson2020-10-121-1/+1
| | | | | | | | | | | This was causing build failures in CheriBSD where we were passing -pie already by default. Reviewed By: andrew Differential Revision: https://reviews.freebsd.org/D24787 Notes: svn path=/head/; revision=366644
* Fix video on PCI heuristicWarner Losh2020-09-281-2/+4
| | | | | | | | | | | | | | | | | | The video on PCI heuristic was broken. It was supposed to infer a video device when the last element of the path was a PCI DEVICE PATH node. However, the last node in the device path is an END node, so this heuristic never fired. This leads, among other things, to bhyve only producing output in the serial connection once we leave the boot loader. This restores the dual headed boot on bhyve + UEFI (as we did in 11.2), but will favor serial in the absence of other config which may be a change from 11.2. MFC After: 3 days Differential Revision: https://reviews.freebsd.org/D26572 Notes: svn path=/head/; revision=366216
* loader: fix non-zfs buildToomas Soome2020-09-231-0/+2
| | | | | | | | | We can not include zfs headers while building without zfs. Reported by: Oscar Holmlund Notes: svn path=/head/; revision=366087
* loader: zfs should support bootonce an nextbootToomas Soome2020-09-212-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bootonce feature is temporary, one time boot, activated by "bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag. By default, the bootonce setting is reset on attempt to boot and the next boot will use previously active BE. By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will be set permanently active. bootonce dataset name is recorded in boot pool labels, bootenv area. in case of nextboot, the nextboot_enable boolean variable is recorded in freebsd:nvstore nvlist, also stored in boot pool label bootenv area. On boot, the loader will process /boot/nextboot.conf if nextboot_enable is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf processing on next boot. bootonce and nextboot features are usable in both UEFI and BIOS boot. To use bootonce/nextboot features, the boot loader needs to be updated on disk; if loader.efi is stored on ESP, then ESP needs to be updated and for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated (gpart or other tools). At this time, only lua loader is updated. Sponsored by: Netflix, Klara Inc. Differential Revision: https://reviews.freebsd.org/D25512 Notes: svn path=/head/; revision=365938
* Ignore the .interp section in the arm64 EFI loaderAndrew Turner2020-09-101-0/+1
| | | | | | | | | | | | When building the loader an unneeded .interp section may be added. Move this to the unused section region so offsets of used sections don't change. Obtained from: CheriBSD Sponsored by: Innovate UK Notes: svn path=/head/; revision=365578
* Quiet int-to-pointer-cast warnings on i386 with GCC 9.John Baldwin2020-09-041-2/+2
| | | | | | | | Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D26200 Notes: svn path=/head/; revision=365318
* zfs: add an option to the bootloader to rewind the ZFS checkpointMariusz Zaborski2020-08-181-1/+1
| | | | | | | | | | | | | | | | | | The checkpoints are another way of keeping the state of ZFS. During the rewind, the pool has to be exported. This makes checkpoints unusable when using ZFS as root. Add the option to rewind the ZFS checkpoint at the boot time. If checkpoint exists, a new option for rewinding a checkpoint will appear in the bootloader menu. We fully support boot environments. If the rewind option is selected, the boot loader will show a list of boot environments that existed before the checkpoint. Reviewed by: tsoome, allanjude, kevans (ok with high-level overview) Differential Revision: https://reviews.freebsd.org/D24920 Notes: svn path=/head/; revision=364355
* loader: Avoid -Wpointer-to-int cast warnings for Arm and RISC-VJessica Clarke2020-07-262-2/+2
| | | | | | | | | | | | | | | | | On RISC-V, Clang warns with: cast to smaller integer type 'unsigned int' from 'void (*)(void *)' Instead, use %p as the standard format specifier for printing pointers. Whilst Arm's pointer size is the same as unsigned, it's still cleaner to use the right thing there too. Reviewed by: brooks (mentor), emaste Approved by: brooks (mentor), emaste Differential Revision: https://reviews.freebsd.org/D25718 Notes: svn path=/head/; revision=363572
* Revert that!Simon J. Gerraty2020-07-191-5/+0
| | | | Notes: svn path=/head/; revision=363351
* Oops missed Makefile.configSimon J. Gerraty2020-07-191-0/+5
| | | | Notes: svn path=/head/; revision=363350
* RISC-V boot1.efi and loader.efi supportMitchell Horne2020-07-066-3/+362
| | | | | | | | | | | | | | | | | | | | | This implementation doesn't have any major deviations from the other EFI ports. I've copied the boilerplate from arm and arm64. I've tested this with the following boot flows: OpenSBI (M-mode) -> u-boot (S-mode) -> loader.efi -> FreeBSD OpenSBI (M-mode) -> u-boot (S-mode) -> boot1.efi -> loader.efi -> FreeBSD Due to the way that u-boot handles secondary CPUs, OpenSBI >= v0.7 is required, as the HSM extension is needed to bring them up explicitly. Because of this, using BBL as the SBI implementation will not be possible. Additionally, there are a few recent u-boot changes that are required as well, all of which will be present in the upcoming v2020.07 release. Looks good: emaste Differential Revision: https://reviews.freebsd.org/D25135 Notes: svn path=/head/; revision=362973
* loader: create single zfs nextboot implementationToomas Soome2020-06-201-1/+14
| | | | | | | | | | | | | | | | | | | | We should have nextboot feature implemented in libsa zfs code. To get there, I have created zfs_nextboot() implementation based on two sources, our current simple textual string based approach with added structured boot label PAD structure from OpenZFS. Secondly, all nvlist details are moved to separate source file and restructured a bit. This is done to provide base support to add nvlist add/update feature in followup updates. And finally, the zfsboot/gptzfsboot disk access functions are swapped to use libi386 and libsa. Sponsored by: Netflix, Klara Inc. Differential Revision: https://reviews.freebsd.org/D25324 Notes: svn path=/head/; revision=362431
* loader.efi: update console after gfx mode changeToomas Soome2020-06-141-0/+3
| | | | | | | The gfx mode change should be coordinated with console setup. Notes: svn path=/head/; revision=362174
* Fix the efi serial console in the Arm models.Andrew Turner2020-06-101-12/+9
| | | | | | | | | | | | | | | | | On some UEFI implementations the ConsOut EFI variable is not a device path end type so we never move to the next node. Fix this by always incrementing the device path node pointer, with a sanity check that the node length is large enough so no two nodes overlap. While here return failure on malloc failure rather than a NULL pointer dereference. Reviewed by: tsoome, imp (previous version) Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D25202 Notes: svn path=/head/; revision=362008
* Remove tests for obsolete compilers in the build systemEric van Gyzen2020-05-121-4/+0
| | | | | | | | | | | | | | Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree. Assume clang is at least 6, which was in 11.2-RELEASE. Drop conditions for older compilers. Reviewed by: imp (earlier version), emaste, jhb MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D24802 Notes: svn path=/head/; revision=360964
* Stop setting PG_U in bootstrap mappings.Mark Johnston2020-04-241-3/+3
| | | | | | | | | | | | | | These mappings are never visible to userspace as they get replaced when the amd64 pmap is bootstrapped, but there is no need to set PG_U in the first place. Reviewed by: alc, kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24547 Notes: svn path=/head/; revision=360260
* loader: add comconsole implementation on top of SIO protocolToomas Soome2020-03-145-5/+530
| | | | | | | Provide comconsole on top of SIO for arm platforms (x86 does use bios version). Notes: svn path=/head/; revision=358989
* veloader use vectx API for kernel and modulesSimon J. Gerraty2020-03-084-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The vectx API, computes the hash for verifying a file as it is read. This avoids the overhead of reading files twice - once to verify, then again to load. For doing an install via loader, avoiding the need to rewind large files is critical. This API is only used for modules, kernel and mdimage as these are the biggest files read by the loader. The reduction in boot time depends on how expensive the I/O is on any given platform. On a fast VM we see 6% improvement. For install via loader the first file to be verified is likely to be the kernel, so some of the prep work (finding manifest etc) done by verify_file() needs to be factored so it can be reused for vectx_open(). For missing or unrecognized fingerprint entries, we fail in vectx_open() unless verifying is disabled. Otherwise fingerprint check happens in vectx_close() and since this API is only used for files which must be verified (VE_MUST) we panic if we get an incorrect hash. Reviewed by: imp,tsoome MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org//D23827 Notes: svn path=/head/; revision=358744
* Move smbios.c to libsa.Warner Losh2020-02-201-15/+0
| | | | | | | | | | | | | smbios used to be an i386 only kinda weird quirk to the x86 architecture. But UEFI picked it up, dusted it off and now it's many other locations. Make it base technology by moving it to libsa and fixing up the compliation. The code has issues with unaligned access still, but that will be addressed in a followup commit. Differential Revision: https://reviews.freebsd.org/D23660 Notes: svn path=/head/; revision=358136
* Create ptov() function.Warner Losh2020-02-201-1/+5
| | | | | | | | | | | | | Create a ptov() function. It's basically the same as the btx PTOV macro, but works everywhere. smbios needs this to translate addresses, but the translation differs between BIOS booting and EFI booting. Make it a function so one smbios.o can be used everywhere. Provide definitions for it in the two loaders affected. Differential Revision: https://reviews.freebsd.org/D23660 Notes: svn path=/head/; revision=358135
* efiloader: don't execute hooks when setting currdev/loaddevKyle Evans2020-02-121-2/+11
| | | | | | | | | | | | | | | We still need to set the hooks to prevent improper manipulations thereafter at the loader prompt, but as it is we're actively preventing loaddev from being set correctly in some circumstances (ZFS in particular) and doing more work than needed with currdev -- that hook in particular validates it as a correct device, which we can assume isn't needed in this context. Reviewed by: imp, sigsys@gmail.com Submitted/Diagnosed by: sigsys@gmail.com Differential Revision: https://reviews.freebsd.org/D23390 Notes: svn path=/head/; revision=357845
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-3/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* loader.efi: print ImageBase so we know where we areToomas Soome2019-12-061-0/+1
| | | | | | | Output a bit of debugging aid. Notes: svn path=/head/; revision=355441
* Remove comment. We're just going to the next node here.Warner Losh2019-11-281-1/+1
| | | | Notes: svn path=/head/; revision=355167
* Support kernels larger than EFI_STAGING_SIZE in loader.efiAndrew Turner2019-11-271-3/+64
| | | | | | | | | | | | | With a very large kernel or module the staging area may be too small to hold it. When this is the case try to allocate more space before failing in the efi copyin/copyout/readin functions. Reviewed by: imp, tsoome Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22569 Notes: svn path=/head/; revision=355132
* loader.efi: Default to serial if we don't have a ConOut variableEmmanuel Vadot2019-11-081-1/+4
| | | | | | | | | | | | In the EFI implementation in U-Boot no ConOut efi variable is created, this cause loader to fallback to TERM_EMU implementation which is very very very slow (and uses the ConOut device in the system table anyway). The UEFI spec aren't clear as if this variable needs to exists or not. Reviewed by: imp, kevans Notes: svn path=/head/; revision=354559
* loader: fall back to term_emu on efi console with serial backendToomas Soome2019-11-021-1/+1
| | | | | | | | | | | | | | | | | | In case of efi console having serial backend (video + serial or only serial), we need to stick with old emulator till we can draw console. Eventually we would need to get console terminal emulator to be removed from serial console because the serial link already has the terminal. However, we need to implement comconsole on all efi platforms first, then we need the ability to draw console, so we do not have to use SimpleTextOutput protocol (which will write both on video and serial in case of multiplexed ComOut). Differential Revision: https://reviews.freebsd.org/D22161 Notes: svn path=/head/; revision=354249
* We don't support configuring serial PCI cards in EFI. Make this clearer in theWarner Losh2019-11-011-1/+1
| | | | | | | | source rather than obfuscaring it behind NO_PCI (nothing else declares that, so it's not making the ifdefs clearer). Notes: svn path=/head/; revision=354240
* Guard reference to x86_hypervisorSimon J. Gerraty2019-10-241-0/+2
| | | | | | | | | | Obviously we only want x86_hypervisor on x86 Guard reference to x86_hypervisor Obviously we only want x86_hypervisor on x86 Notes: svn path=/head/; revision=354055
* Allow loader.efi to identify non-standard boot setupSimon J. Gerraty2019-10-241-0/+1
| | | | | | | | | | | PATH_BOOTABLE_TOKEN can be set to a non-standard path that identifies a device as bootable. Reviewed by: kevans, bcran Differential Revision: https://reviews.freebsd.org/D22062 Notes: svn path=/head/; revision=354039
* Allow loader.efi to identify non-standard boot setupSimon J. Gerraty2019-10-171-0/+3
| | | | | | | | | | | PATH_BOOTABLE_TOKEN can be set to a non-standard path that identifies a device as bootable. Reviewed by: kevans, bcran Differential Revision: https://reviews.freebsd.org/D22062 Notes: svn path=/head/; revision=353697
* loader: use teken teminal emulator for x86 and uefiToomas Soome2019-09-053-7/+3
| | | | | | | | | | | Replace mini cons25 emulator with teken, this does enable us proper console terminal for loader and will make it possible to implement different back end callbacks to draw to screen. At this time we still only "draw" in text mode. Notes: svn path=/head/; revision=351900
* Reduce size of EFI_STAGING_SIZE to 32 on armTom Jones2019-08-171-0/+2
| | | | | | | | | | | | | | Reduce the size of the EFI_STAGING area we allocate on arm to 32. On arm SBC such as the NanoPi-NEOLTS the staging area allocation will fail on the 256MB model with a staging size of 64. Reviewed by: bcran, manu Approved by: bz (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D21016 Notes: svn path=/head/; revision=351166