aboutsummaryrefslogtreecommitdiff
path: root/sys/boot/efi
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix armv6 buildWarner Losh2017-09-071-0/+7
| | | | | | | | | | | We need to extend the -Wno-format hack to yet another Makefile to cope with %S meaning (CHAR16 *) not (wchar_t *) in the context of the EFI boot loaders. Sponsored by: Netflix Notes: svn path=/head/; revision=323261
* ucs2lenWarner Losh2017-09-073-12/+13
| | | | | | | | | | | | | Rename boot1's wcslen to ucs2len, which we can't use in userland because wchar in userland is unsigned, not short. Move it into efichar.c. Also spell '* 2' as '* sizeof(efi_char)' and add 1 for the trailing NUL to transition the FreeBSD boot env vars to being NUL terminated on the same line... Sponsored by: Netflix Notes: svn path=/head/; revision=323258
* Fix loader bug causing too many pages allocation when bootloader is U-BootMarcin Wojtas2017-09-051-0/+7
| | | | | | | | | | | | | | | | | | | | | FreeBSD loader expects to have mmsz variable set by bootloader. U-Boot behaviour is that if buffer size is not big enough to keep whole memory map, assign the smallest correct buffer size to sz and return error. In other words U-Boot assumes that nobody will need mmsz value when buffer is not filled with memory map, which is not true, so calculated pages value was too big to allocate. Solution: Simply assign default value to mmsz. Submitted by: Patryk Duda <pdk@semihalf.com> Obtained from: Semihalf Sponsored by: Semihalf Differential Revision: https://reviews.freebsd.org/D12194 Notes: svn path=/head/; revision=323174
* Revert r322941: Eliminate redundant device matching functionsWarner Losh2017-09-021-1/+48
| | | | | | | | | | | Turns out, they are subtly different. I'll refactor anew in the future if it's worth it then. Sponsored by: Netflix Reported by: Tomoaki AOKI-san Notes: svn path=/head/; revision=323131
* Save where we're booted fromWarner Losh2017-08-312-1/+34
| | | | | | | | | | | | | | | | Record the file path for boot1.efi as the UEFI environemnt variable FreeBSDBootVarGUID:Boot1Path. Record the device this came from as FreeBSDBootVarGUID:Boot1Dev. While later stages of the boot may be able to guess these values by retrieving UEFIGlobal:BootCurrent and groveling through the correct UEFIGlobal:BootXXXX, this provides certanty in the face of behavior from any part of the boot loader chain that might "guess" what to do next. These env variables are volatile and will disappear on reboot. Sponsored by: Netflix Notes: svn path=/head/; revision=323065
* Exit rather than panic for most errors.Warner Losh2017-08-311-24/+26
| | | | | | | | | | | | | | | | In the FreeBSD UEFI boot protocol, boot1.efi exits back to UEFI if it can't boot the image for most reasons (so that further items in the EFI boot manger list can be tried). Rename panic to efi_panic, make it static and give it an extra status argument. Exit back to UEFI with that status argument so the next loader can be tried. Use malloc/free exclusively instead of mixing malloc/free and AllocatePool/FreePool. The code is smaller. Sponsored by: Netflix Notes: svn path=/head/; revision=323064
* boot1.efi: print more info about where boot1.efi is loaded fromWarner Losh2017-08-311-18/+22
| | | | | | | | | | | Print the device that boot1.efi was loaded from. Print the path as well (since it isn't included in DeviceHandle). Move block where we do this earlier so all the block handle code is now together. Sponsored by: Netflix Notes: svn path=/head/; revision=323063
* Make efichar.c routines available to libefi.Warner Losh2017-08-312-1/+7
| | | | | | | | | Make efichar.c routines available to libefi as well as libefivar. Define LIBEFI when building so we can conditionally include stand.h vs the normal userland stuff. Notes: svn path=/head/; revision=323062
* Eliminate redunant device path matching.Warner Losh2017-08-271-48/+1
| | | | | | | | | | | Use efi_devpath_match instead of device_paths_match. They are functionally the same. Remove device_paths_match from boot1.c and call efi_devpath_match instead. Sponsored by: Netflix Notes: svn path=/head/; revision=322941
* Use efi_devpath_str for debug path info.Warner Losh2017-08-264-184/+29
| | | | | | | | | | | | | | | | | | | | | | | Kill our own hand-rolled (and somewhat flawed) devpath_str in favor of the recently added efi_devpath_str in libefi. This gives us much better names at the expense of not being able to debug on EFI 1.2 machines (since the UEFI protocol efi_devpath_str depends on was added in UEFI 2.0). However, this isn't the first thing that requires newer than EFI 1.2, so it's quite possible that this doesn't change the universe of machines we can EFI boot from. This will now give us the full UEFI path, even for devices we don't yet know about. More importantly, it gives us the full HD(...) part of the path, which is sufficient by itself to locate disks that follow the rules (dd one disk (but not partition) to another still needs the rest of the path to disambiguate, but that isn't following the rules that require every GPT table to have globally unique GUIDs for every partion). This also has the side effect of shrinking boot1.efi by ~3k. Sponsored by: Netflix Notes: svn path=/head/; revision=322939
* Link in libefi for boot1Warner Losh2017-08-264-13/+8
| | | | | | | | | | | Add libefi to the list of libraries we'll link in. Move EFI table definitions back to libefi so we don't have drift between the two efi_main routines. Sponsored by: Netflix Notes: svn path=/head/; revision=322938
* No need for MK_ZFS around these: they are by their nature only activeWarner Losh2017-08-261-2/+0
| | | | | | | | | when MK_ZFS is true. Sponsored by: Netflix Notes: svn path=/head/; revision=322933
* Use the loader.efi conventions for the various EFI tables.Warner Losh2017-08-264-36/+35
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=322932
* Cleanup efi_main return typeWarner Losh2017-08-264-7/+6
| | | | | | | | | | Make the return type of efi_main uniform. Declare the Exit() function as not returning. Move efi_main's declaration to the proper header. Sponsored by: Netflix Notes: svn path=/head/; revision=322931
* Move efi_main into efi/loaderWarner Losh2017-08-265-152/+191
| | | | | | | | | | | | | Move the efi_main routine out of libefi into sys/boot/efi/loader. Since boot1 has its own efi_main routine, this effectively prevents boot1 from linking with libefi. By moving it out, we can share code better (though though some refactoring with boot1's efi_main and loader.efi's efi_main is definitely in order). Sponsored by: Netflix Notes: svn path=/head/; revision=322930
* Make spinconsole platform independent and hook it up into EFI loader onMaxim Sobolev2017-08-253-4/+8
| | | | | | | | | | i386 and amd64. Not enabled on ARMs, those are lacking timer routines. MFC after: 2 moths Sponsored by: Sippy Software, Inc. Notes: svn path=/head/; revision=322896
* Define proposed GUID for FreeBSD boot loader variables.Warner Losh2017-08-161-0/+6
| | | | Notes: svn path=/head/; revision=322593
* Remove unused defines.Warner Losh2017-08-161-6/+0
| | | | Notes: svn path=/head/; revision=322592
* loader.efi: repace XXX with real comments in trap.cToomas Soome2017-08-151-2/+12
| | | | | | | | | | There are two missing comments marked as XXX in trap.c, fix this. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D12035 Notes: svn path=/head/; revision=322542
* libefi/time.c cstyle cleanupToomas Soome2017-08-051-165/+178
| | | | | | | | | | | | libefi/time.c is mix of different styles, this update does cleanup. Also fix 0 versus NULL, and zero the tv structure for case we get error from UEFI firmware. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D11861 Notes: svn path=/head/; revision=322074
* Move EFI fmtdev functionality to libefiWarner Losh2017-08-045-8/+6
| | | | | | | | | | | This patch moves code necessary for the fmtdev functionality from loader to libefi, allowing other applications to make use of it Submitted by: Eric McCorkle Differential Revision: https://reviews.freebsd.org/D11862 Notes: svn path=/head/; revision=322056
* Add EFI utility functions to libefiWarner Losh2017-08-043-39/+139
| | | | | | | | | | | This patch adds additional EFI utility functions to convert errno values to EFI_STATUS errors, as well as EFI times to UNIX times. Submitted by: Eric McCorkle Differential Revision: https://reviews.freebsd.org/D11858 Notes: svn path=/head/; revision=322040
* Move EFI ZFS functions to libefiWarner Losh2017-08-044-51/+174
| | | | | | | | | | | This patch moves some EFI ZFS functions from loader to libefi, allowing them to be used by anything that links against libefi. Submitted by: Eric McCorkle Differential Revision: https://reviews.freebsd.org/D11855 Notes: svn path=/head/; revision=322039
* Add definitions and utilities for EFI driversWarner Losh2017-08-045-1/+253
| | | | | | | | | | | This patch adds definitions and utility code for creating EFI drivers using the EFI_DRIVER_BINDING_PROTOCOL. Submitted by: Eric McCorkle Differential Revision: https://reviews.freebsd.org/D11852 Notes: svn path=/head/; revision=322038
* Always set the receive mask in loader.efi. Some UEFI implementations setAndrew Turner2017-07-271-9/+8
| | | | | | | | | | | | | | | | this to be too restrictive. We need to have both broadcast and unicast enabled for loader to work. Set them in all cases to ensure this is true. This allows the Cavium ThunderX 2s in the netperf cluster to netboot using a USB NIC. PR: 221001 Reviewed by: emaste, tsoome Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D11732 Notes: svn path=/head/; revision=321621
* Fix printf format warning in zfs_module.cDimitry Andric2017-07-201-2/+2
| | | | | | | | | | | | | | | | | | Clang 5.0.0 got better warnings about print format strings using %zd, and this leads to the following -Werror warning on e.g. arm: sys/boot/efi/boot1/zfs_module.c:186:18: error: format specifies type 'ssize_t' (aka 'int') but the argument has type 'off_t' (aka 'long long') [-Werror,-Wformat] "(%lu)\n", st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status)); ^~~~~~~~~~ Fix this by casting off_t arguments to intmax_t, and using %jd instead. Reviewed by: tsoome MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D11678 Notes: svn path=/head/; revision=321305
* Integer underflow in efipart_realstrategy when I/O starts after end of diskAllan Jude2017-07-011-1/+10
| | | | | | | | | | | | | | | | | This fixes an integer underflow in efipart_realstrategy, which causes crashes when an I/O operation's start point is after the end of the disk. This can happen when trying to detect filesystems on very small disks. This can occur if a BIOS freebsd-boot partition exists on a system when the EFI loader is being used. PR: 219000 Submitted by: Eric McCorkle <eric@metricspace.net> Reviewed by: cem (previous version), tsoome (previous version) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D10559 Notes: svn path=/head/; revision=320553
* Link EFI/uboot loaders with -znotextEd Maste2017-07-012-2/+2
| | | | | | | | | | | | | | | By default LLD links with relocations disallowed against readonly sections (e.g., .text), but the 32-bit ARM EFI & uboot boot bits require such relocations. -znotext is either ignored as an unknown -z option (in-tree lld 2.17.50) or is already the default (GNU ld or GNU gold from ports) so we can just add it unconditionally to allow building with LLD. This is similar to the change in r320179 for the kernel link. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=320547
* As with arm64 mark the EFI PE header as allocated on arm. This is neededAndrew Turner2017-06-291-1/+1
| | | | | | | | | for lld to link laoder.efi and boot1.efi. Reported by: emaste Notes: svn path=/head/; revision=320482
* loader.efi: Disable smbios for armEmmanuel Vadot2017-06-241-0/+4
| | | | | | | | | | The smbios code does a lot of unaligned access, since we don't really care about smbios info on ARM (not all board expose information and those who does don't expose useful ones) disable smbios for this arch (at least for now). Notes: svn path=/head/; revision=320304
* Make structure padding explicit in EFI_MEMORY_DESCRIPTOREd Maste2017-06-221-0/+1
| | | | | | | | | | | | | The EFI memory descriptor 64-bit aligns PhysicalStart on both 32- and 64-bit platforms. Make the padding explicit for i386 EFI. Submitted by: Siva Mahadevan <smahadevan@freebsdfoundation.org> MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D11301 Notes: svn path=/head/; revision=320234
* Utilize SYSROOT from r320119 in places where DESTDIR may be wanting WORLDTMP.Bryan Drewery2017-06-191-6/+0
| | | | | | | | | | | | | | Since buildenv exports SYSROOT all of these uses will now look in WORLDTMP by default. sys/boot/efi/loader/Makefile A LIBSTAND hack is no longer required for buildenv. MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=320122
* Add chain loader support for loaderToomas Soome2017-06-161-0/+94
| | | | | | | | | | | | | | | | | | Implement simple chain loader in loader; this update does add chain command, taking device or file as argument to load and start new boot loader. In case of BIOS, the chain will read the boot block to address 0000:7c00 and jumps on it. In case of UEFI, the chain command is to be used with efi application, typically stored in EFI System Partition. The update also does add simple menu entry, if the variable chain_disk is set. The value of the variable chain_disk is used as argument for chain loading. Relnotes: yes Differential Revision: https://reviews.freebsd.org/D5992 Notes: svn path=/head/; revision=320011
* Set the right variable when overriding the default console speed.Mark Johnston2017-05-111-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=318193
* loader: network read reworkToomas Soome2017-05-063-42/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current read from network is working from up to down - we have some protocol needing the data from the network, so we build the buffer space for that protocol, add the extra space for headers and pass this buffer down to be filled by nif get call in hope, we have guessed the incoming packet size right. Amazingly enough this approach mostly does work, but not always... So, this update does work from down to up - we allocate buffer (based on MTU or frame size info), fill it up, and pass on for upper layers. The obvious problem is that when we should free the buffer - if at all. In the current implementation the upper layer will free the packet on error or when the packet is no longer needed. While working on the issue, the additional issue did pop up - the bios implementation does not have generic get/put interface but is using pxe udpsend/udpreceive instead. So the udp calls are gone and undi interface is implemented instead. Which in turn means slight other changes as we do not need to have duplicated pxe implementation and can just use dev_net. To align packet content, the actual read from nic is using shifted buffer by ETHER_ALIGN (2). Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10232 Notes: svn path=/head/; revision=317887
* loader.efi: ResetSystem does not use data with EFI_SUCCESSToomas Soome2017-05-011-2/+1
| | | | | | | | | | | | | | | | | | The current reboot command in efi/loader/main.c is passing extra data with ResetSystem, however, UEFI spec 2.6, page 265 does state: "ResetData is only valid if ResetStatus is something other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific where a minimum amount of ResetData is always required." Therefore we should use DataSize 0 and ResetData NULL - those are two last arguments for the call. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D10562 Notes: svn path=/head/; revision=317652
* loader: F_READ/F_WRITE should be checked against masked flagToomas Soome2017-04-181-1/+1
| | | | | | | | | | | | | | | | | | The work to make it possible to avoid bcache via using F_NORA modifier did miss the fact that not all loader platforms are using the bcache, and so it is possible the modifier is not cleared, as bcache strategy function is not used. For fix, we make sure the checks are dont with masked flag. This patch does fix boot for platforms which do not use bcache. Reported by: emaste Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D10422 Notes: svn path=/head/; revision=317097
* loader.efi: only fetch zfs pool guid for the actual boot deviceToomas Soome2017-04-111-21/+9
| | | | | | | | | | | | | | | With the zfs probe cleanup, the mistake did slip in the probe code; instead of reading the pool GUID for the actual boot device (partition), we read GUID for first found pool from the boot disk. This will break the case when there are both zfs pool and ufs on the boot disk, and the ufs is used for boot, not zfs. Reviewed by: smh Differential Revision: https://reviews.freebsd.org/D10359 Notes: svn path=/head/; revision=316704
* Silence GCC warning by initializing the local variable.Alexander Kabaev2017-04-071-0/+1
| | | | | | | | | GCC 6.3 is unable to trace all code paths that lead to this variable being left uninitialized and correlate that to function return values. Notes: svn path=/head/; revision=316628
* Do not use -msoft-float with intention of disabling FP on aarch64Alexander Kabaev2017-04-075-5/+11
| | | | | | | | | | | GNU GCC does does recognise it as a valid option and we already use -mgeneral-regs-only that has the desired effect. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D10306 Notes: svn path=/head/; revision=316625
* loader: zfs reader should check all labelsToomas Soome2017-04-062-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | The current zfs reader is only checking first label from each device, however, we do have 4 labels on device and we should check all 4 to be protected against disk failures and incomplete label updates. The difficulty is about the fact that 2 label copies are in front of the pool data, and 2 are at the end, which means, we have to know the size of the pool data area. Since we have now the mechanism from common/disk.c to use the partition information, it does help us in this task; however, there are still some corner cases. Namely, if the pool is created without partition, directly on the disk, and firmware will give us the wrong size for the disk, we only can check the first two label copies. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D10203 Notes: svn path=/head/; revision=316585
* Restore EFI boot environment functionality broken in r313333Allan Jude2017-04-031-0/+1
| | | | | | | | Reported by: Graham Perrin, JT Pennington <q5sys@bsdnow.tv> Sponsored by: ScaleEngine Inc. Notes: svn path=/head/; revision=316436
* loader: simplify efi_zfs_probe and avoid double probing for zfs.Toomas Soome2017-03-301-43/+22
| | | | | | | | | | | | | | | | | The current efi_zfs_probe() is overcomplicated and can be made simpler. Still we need to pick up the device handle for our boot disk first, because the ESP does not have to be the first partition on the disk. Once we do have the handle for boot disk, we probe that disk with pointer for pool GUID. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D10198 Notes: svn path=/head/; revision=316280
* loader: efipart should check disk size from partition tableToomas Soome2017-03-301-9/+28
| | | | | | | | | | | | | | | | | | | | | | While testing 32bit UEFI OVMF (which has bug about how the disk size is presented), I did witness the errors from blkio->ReadBlocks(). It became apparent we can not entirely trust UEFI interfaces either, so additional checks are needed. So we use disk_ioctl(DIOCGMEDIASIZE) for disks, with fallback of Media->LastBlock for other media. In addition, we need to check if there is media present. + small fixes for error printout, and avoiding multiple blk * 512. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D10197 Notes: svn path=/head/; revision=316279
* self_reloc.c: Pass -Wno-error=maybe-uninitialized to gcc versions greater ↵Enji Cooper2017-03-282-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | than 4.2.1 self_reloc.c doesn't initialize `rel` in all cases in the C code, however, the value might be initialized properly on the stack in the assembly code. For right now (because this doesn't seem to be breaking anything and my initializing the stack value could break something since it's called from assembly code) disable the warning for self_reloc.c. More investigation should be done to determine the appropriate response to this warning (either intialize the value or find a smarter way to deal with the warning). A long MFC timeout is being set for this change to allow a better solution for the issue to be developed in that time period. MFC after: 2 months Reported by: Jenkins (FreeBSD-head-amd64-gcc job) Tested with: amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316119
* Use `-Wno-missing-declarations` with CWARNFLAGS for skein.cEnji Cooper2017-03-281-0/+4
| | | | | | | | | | | | | `-Wno-missing-variable-declarations` is a clang-specific flag, so gcc (not 4.2.1, in particular 6.3.0 in my case) dies when it's passed the flag. X-MFC with: r304321 Reported by: amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316110
* Don't hardcode input files for stage 1/2 bootloaders; use .ALLSRC insteadEnji Cooper2017-03-281-2/+2
| | | | | | | | | | | | This is a better pattern to follow when creating the bootloaders and doing the relevant space checks to make sure that the sizes aren't exceeded (and thus, copy-pasting is a bit less error prone). MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316109
* Remove redundant declarationsEnji Cooper2017-03-282-3/+0
| | | | | | | | | | | They're already defined in libstand.h MFC after: 1 week Reported by: amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316103
* Mark the EFI PE header as allocated. While ld.bfd doesn't seem to careAndrew Turner2017-03-171-1/+1
| | | | | | | | | about not having this flag ld.lld fails to link without it. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=315452
* loader: remove open_disk cacheToomas Soome2017-03-161-4/+2
| | | | | | | | | | | | | | | | | | As we provide the disk size verification and correction via disk_ioctl and disk state provided by disk_open(), we can not share the partition state in disk_devdesc structure. Also the sharing does make a lot of sense with ufs, as only one partition is open at any given time, but zfs pools do keep the disk devices open. To make sure we do get the correct information about the open device, just remove the cache. Reviewed by: allanjude, smh Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D9757 Notes: svn path=/head/; revision=315408