path: root/stand/efi/loader/arch
Commit message (Collapse)AuthorAgeFilesLines
* amd64 loader: Use efiserialio for Hyper-V booted systemsWei Hu6 days1-0/+1
| | | | | | | | | | | | | | | | | | | | | | | 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)
* 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
* loader.efi: faults could try to print out call traceToomas Soome2022-07-141-0/+37
| | | | | | | | | | | | 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-303-3/+0
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* 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
* efi loader: TypoMark Johnston2021-09-211-1/+1
| | | | MFC after: 3 days
* amd64 UEFI loader: stop copying staging area to 2M physicalKonstantin Belousov2021-08-081-28/+114
| | | | | | | | | | | | | | | | | | | | | On amd64, add a possibility to activate kernel with staging area in place. Add 'copy_staging' command to control this. For now, by default the old mode of copying kernel to 2M phys is retained. It is going to be changed in several weeks. On amd64, add some slop to the staging area to satisfy both requirements of the kernel startup allocator, and to have space for minor staging data increase after the final size is calculated. Add a new command 'staging_slop' to control its size. Improve staging area resizing, in particular, reallocate it anew if we cannot grow it neither down nor up. Reviewed by: kevans, markj Discussed with: emaste (the delivery plan) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31121
* stand/multiboot2: fix header length checkRoger Pau Monné2021-02-231-1/+1
| | | | | | | | | | | | | Check whether we have reached the end of the buffer using search_size instead of MULTIBOOT_SEARCH, which is the maximum defined by the specification, but the file can be shorter than that. This prevents printing a harmless error message when loading a file that is smaller than MULTIBOOT_SEARCH. Sponsored by: Citrix Systems R&D MFC after: 3 days Fixes: adda2797eb2a ('stand/multiboot2: add support for booting a Xen dom0 in UEFI mode')
* stand/multiboot2: fix error message formatRoger Pau Monné2021-02-231-2/+2
| | | | | | | | Add a missing space in one error message. Sponsored by: Citrix Systems R&D MFC after: 3 days Fixes: adda2797eb2a ('stand/multiboot2: add support for booting a Xen dom0 in UEFI mode')
* stand/multiboot2: add support for booting a Xen dom0 in UEFI modeRoger Pau Monné2021-02-165-0/+1001
| | | | | | | | | | | | | | | | | | | | Add some basic multiboot2 infrastructure to the EFI loader in order to be capable of booting a FreeBSD/Xen dom0 when booted from UEFI. Only a very limited subset of the multiboot2 protocol is implemented in order to support enough to boot into Xen, the implementation doesn't intend to be a full multiboot2 capable implementation. Such multiboot2 functionality is hooked up into the amd64 EFI loader, which is the only architecture that supports Xen dom0 on FreeBSD. The options to boot a FreeBSD/Xen dom0 system are exactly the same as on BIOS, and requires setting the xen_kernel and xen_cmdline options in loader.conf. Sponsored by: Citrix Systems R&D Reviewed by: tsoome, imp Differential revision: https://reviews.freebsd.org/D28497
* stand/efi: allow not exiting boot servicesRoger Pau Monné2021-02-165-10/+13
| | | | | | | | | | | | | | | | | | 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: 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
* 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
* 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
* 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
* RISC-V boot1.efi and loader.efi supportMitchell Horne2020-07-064-0/+354
| | | | | | | | | | | | | | | | | | | | | 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
* 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-142-0/+2
| | | | | | | 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-081-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* loader: use teken teminal emulator for x86 and uefiToomas Soome2019-09-052-2/+2
| | | | | | | | | | | 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
* EFI: don't call printf after ExitBootServices, since it uses Boot ServicesRebecca Cran2019-03-022-7/+15
| | | | | | | | | | | | | | | ExitBootServices terminates all boot services including console access. Attempting to call printf afterwards can result in a crash, depending on the implementation. Move any printf statements to before we call bi_load, and remove any that depend on calling bi_load first. Reviewed by: imp, tsoome Differential Revision: https://reviews.freebsd.org/D19374 Notes: svn path=/head/; revision=344718
* stand: Remove unused i386 EFI MD bitsKyle Evans2019-02-263-146/+0
| | | | | | | | | | | | | | | | | | r328169 removed the copy of bootinfo that would've made this somewhat functional. However, this is irrelevant- earlier work in r292338 was done to exit boot services in the MI bi_load() rather than having N copies of the GetMemoryMap/ExitBootServices dance. i386 never quite caught up to that; ldr_enter was still being called but the prereq for that, ldr_bootinfo, was no longer. As a consequence, this ExitBootServices() was being called with a mapkey=0, clearly bogus, and reportedly breaking the boot in some instances. Reported by: bcran MFC after: 1 week Notes: svn path=/head/; revision=344560
* Ensure we have a large enough stack for the lua loaderAndrew Turner2018-08-271-0/+17
| | | | | | | | | | | | | | | | | | | Lua has a few places where it allocates a large buffer on the stack. This is normally fine, except there are a few places where there can be multiple frames with this buffer. This can cause a stack overflow on some arm64 SoCs. Fix this by allocating our own stack in loader.efi large enough for these objects. The required size has been found by tracing how the stack pointer changes in a virtual machine and found to be no larger than 50kB. A larger stack is allocated to reduce the likelihood of overflow from future changes. Reviewed by: kevans Approved by: re (kib) Differential Revision: https://reviews.freebsd.org/D16886 Notes: svn path=/head/; revision=338337
* Fix casts between 64-bit physical addresses and pointers in EFI.John Baldwin2018-08-181-6/+6
| | | | | | | | | | | | | | | Compiling FreeBSD/i386 with modern GCC triggers warnings for various places that convert 64-bit EFI_ADDRs to pointers and vice versa. - Cast pointers to uintptr_t rather than to uint64_t when assigning to a 64-bit integer. - Cast 64-bit integers to uintptr_t before a cast to a pointer. Reviewed by: kevans MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16586 Notes: svn path=/head/; revision=338022
* Prefer uintXX_t to u_intXX_tWarner Losh2018-03-131-1/+1
| | | | | | | | | A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines. With consistency a great soul has simply nothing to do. -- Ralph Waldo Emerson Notes: svn path=/head/; revision=330864
* Remove extra copy of bootinfo.c. It's a bit rotted copy of the one inWarner Losh2018-01-191-275/+0
| | | | | | | | | efi/loader. Differential Review: https://reviews.freebsd.org/D13986 Notes: svn path=/head/; revision=328169
* stand: Move sections around to fix stand/ build with ld.lld on armv7Kyle Evans2018-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | When building loader bits, lld fails with the following error: "ld: error: section: .dynamic is not contiguous with other relro sections" on both ubldr and EFI loader. Move .dynamic up to make ld.lld happy, adjust .got as necessary for ubldr. Tested on: OrangePi One (ld.lld, ubldr) Tested on: Banana Pi-M3 (ld.lld, ubldr) Tested on: qemu-armv7 (ld.lld, EFI) Tested on: qemu-armv7 (ld.bfd, EFI) Tested on: Raspberry Pi 2 (ld.bfd, ubldr) [manu] Tested on: Banana Pi-M2 (ld.bfd, ubldr) [manu] Reviewed by: andrew, emaste, imp Differential Revision: https://reviews.freebsd.org/D13942 Notes: svn path=/head/; revision=328156
* Move sys/boot to stand. Fix all references to new locationWarner Losh2017-11-1423-0/+2563
Sponsored by: Netflix Notes: svn path=/head/; revision=325834