summaryrefslogtreecommitdiff
path: root/boot/bootmeth_efi.c
AgeCommit message (Collapse)AuthorFilesLines
2023-08-03bootstd: Init the size before reading the devicetreeSimon Glass1-1/+5
The implementation in distro_efi_try_bootflow_files() does not pass a valid size to bootmeth_common_read_file(), so this can fail if the uninted value happens to be too small. Fix this. This was reported by someone but I cannot now find the email. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-03bootstd: Avoid allocating memory for the EFI fileSimon Glass1-17/+33
The current bootflow-iteration algorithm reads the bootflow file into an allocated memory buffer so it can be examined. This works well in most cases. However, while the common case is that the first bootflow is immediately booted, it is also possible just to scan for available bootflows, perhaps selecting one to boot later. Even with the common case, EFI bootflows can be quite large. It doesn't make sense to read it into an allocated buffer when we have kernel_addr_t providing a suitable address for it. Even if we do have plenty of malloc() space available, it is a violation of U-Boot's lazy-init principle to read the bootflow before it is needed. So overall it seems better to make a change. Adjust the logic to read just the size of the EFI file at first. Later, when the bootflow is booted, read the rest of the file into the designated kernel buffer. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Da Xue <da@libre.computer> Reported-by: Vincent Stehlé <vincent.stehle@arm.com>
2023-08-03bootstd: Use a function to detect network in EFI bootmethSimon Glass1-4/+16
This checks for a network-based bootflow in two places, one of which is less than ideal. Move the correct test into a function and use it in both places. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-05-13bootstd: Tidy up reporting of errorsSimon Glass1-1/+1
In a few cases the error handling is not quite right. Make sure we return the actual error in distro_efi_read_bootflow_file() rather than -EINVAL. Return -IO when a file cannot be read. Also show the error name if available. This does not change operation, but does make it easier to diagnose problems. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26bootstd: Use blk uclass device numbers to set efi bootdevMathew McBride1-1/+2
When loading a file from a block device, efiload_read_file was using the seq_num of the device (e.g "35" of virtio_blk#35) instead of the block device id (e.g what you get from running the corresponding device scan command, like "virtio 0") This cause EFI booting from these devices to fail as an invalid device number is passed to blk_get_device_part_str: Scanning bootdev 'virtio-blk#35.bootdev': distro_efi_read_bootflow_file start (efi,fname=<NULL>) distro_efi_read_bootflow_file start (efi,fname=<NULL>) setting bootdev virtio, 35, efi/boot/bootaa64.efi, 00000000beef9a40, 170800 efi_dp_from_name calling blk_get_device_part_str dev=virtio devnr=35 path=efi/boot/bootaa64.efi blk_get_device_part_str (virtio,35) blk_get_device_by_str (virtio, 35) ** Bad device specification virtio 35 ** Using default device tree: dtb/qemu-arm.dtb No device tree available 0 efi ready virtio 1 virtio-blk#35.bootdev.par efi/boot/bootaa64.efi ** Booting bootflow 'virtio-blk#35.bootdev.part_1' with efi blk_get_device_part_str (virtio,0:1) blk_get_device_by_str (virtio, 0) No UEFI binary known at beef9a40 (image buf=00000000beef9a40,addr=0000000000000000) Boot failed (err=-22) Signed-off-by: Mathew McBride <matt@traverse.com.au> Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26bootstd: Support booting EFI where multiple options existSimon Glass1-7/+19
The current EFI implementation has a strange quirk where it watches loaded files and uses the last-loaded file to determine the device that is being booted from. This is confusing with bootstd, where multiple options may exist. Even loading a device tree will cause it to go wrong. There is no API for passing this information, since the only entry into booting an EFI image is the 'bootefi' command. To work around this, call efi_set_bootdev() for EFI images, if possible, just before booting. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26bootstd: Tweak bootflow logic for device treeSimon Glass1-11/+11
We should only store the FDT filename if we were able to determine one. Adjust the logic for this. This corrects the case where no FDT is needed to boot, such as with EFI using ACPI. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08bootstd: Replicate the dtb-filename quirks of distrobootSimon Glass1-9/+61
For EFI, the distro boot scripts search in three different directories for the .dtb file. The SOC-based filename fallback is supported only for 32-bit ARM. Adjust the code to mirror this behaviour. Also some boards can use a prior-stage FDT if one is not found in the normal way. Support this and show a message in that case. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Mark Kettenis <kettenis@openbsd.org>
2023-01-24bootstd: Treat DHCP and PXE as bootdev labelsSimon Glass1-0/+4
These are associated with the ethernet boot device but do not match its uclass name, so handle them as special cases. Provide a way to pass flags through with the bootdev so that we know how to process it. The flags are checked by the bootmeths, to ensure that only the selected bootmeth is used. While these both use the network device, they work quite differently. It is common to run only one of these, or to run PXE before DHCP. Provide bootflow flags to control which methods are used. Check these in the two bootmeths so that only the chosen one is used. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24bootstd: Support reading the device tree with EFISimon Glass1-6/+99
With EFI booting the device tree is required but is not actually specified in any way. The normal method is to use a fdtfile environment variable to get the filename, then look for that file on the media. Implement this in the bootmeth. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24bootstd: Allow reading an EFI file from the networkSimon Glass1-8/+109
At present this bootmeth only supports reading from a filesystem. Add support for reading from a network also, using DHCP with autoload. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24bootstd: Rename bootdev checkersSimon Glass1-1/+1
These functions return 0 if the check passes, so the names are somewhat confusing. Rename them. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-04-25bootstd: Add an implementation of EFI bootSimon Glass1-0/+188
Add a bootmeth driver which handles EFI boot, using EFI_LOADER. In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc. For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without CONFIG_CMDLINE being enabled. There was much discussion about whether this is needed, but it seems that it is, at least for now. Signed-off-by: Simon Glass <sjg@chromium.org>