summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_block.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into openslxSimon Rettberg2023-04-041-3/+1Star
|\
| * [efi] Add efi_path_terminate() utility functionMichael Brown2023-01-231-3/+1Star
| | | | | | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* | Local UEFI disk boot supportSimon Rettberg2021-10-051-1/+7
|/ | | | | By Aaron Young: https://lists.ipxe.org/pipermail/ipxe-devel/2019-February/006504.html
* [efi] Skip interface uninstallation during shutdownMichael Brown2020-12-171-4/+5
| | | | | | | | | | | | | | | | | | | | | | iPXE seems to be almost alone in the UEFI world in attempting to shut down cleanly, free resources, and leave hardware in a well-defined reset state before handing over to the booted operating system. The UEFI driver model does allow for graceful shutdown via uninstallation of protocol interfaces. However, virtually no other UEFI drivers do this, and the external code paths that react to uninstallation are consequently poorly tested. This leads to a proliferation of bugs found in UEFI implementations in the wild, as described in commits such as 1295b4a ("[efi] Allow initialisation via SNP interface even while claimed") or b6e2ea0 ("[efi] Veto the HP XhciDxe Driver"). Try to avoid triggering such bugs by unconditionally skipping the protocol interface uninstallation during UEFI boot services shutdown, leaving the interfaces present but nullified and deliberately leaking the containing memory. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Nullify interfaces unconditionally on error and shutdown pathsMichael Brown2020-12-171-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Nullify interfaces and leak memory on uninstallation failureMichael Brown2020-10-261-10/+42
| | | | | | | | | | | | | | | The UEFI specification allows uninstallation of a protocol interface to fail. There is no sensible way for code to react to this, since uninstallation is likely to be taking place on a code path that cannot itself fail (e.g. a code path that is itself a failure path). Where the protocol structure exists within a dynamically allocated block of memory, this leads to possible use-after-free bugs. Work around this unfortunate design choice by nullifying the protocol (i.e. overwriting the method pointers with no-ops) and leaking the memory containing the protocol structure. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Allow block devices to provide their own EFI device pathsMichael Brown2020-10-231-63/+25Star
| | | | | | | Use the device path constructed via efi_describe() for the installed EFI_BLOCK_IO_PROTOCOL device handle. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Show block device ACPI table contents only at DBGLVL_EXTRAMichael Brown2020-10-201-3/+3
| | | | | | | The ACPI table contents are typically large and are likely to cause any preceding error messages to scroll off-screen. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Split device path functions out to efi_path.cMichael Brown2020-10-161-4/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Always enable recursion when calling ConnectController()Michael Brown2020-10-021-1/+1
| | | | | | | | There appears to be no reason for avoiding recursion when calling ConnectController(), and recursion provides the least surprising behaviour. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Work around UEFI specification bug in LoadImage for SAN bootMichael Brown2020-06-051-0/+3
| | | | | | | | As described in the previous commit, work around a UEFI specification bug that necessitates calling UnloadImage if the return value from LoadImage is EFI_SECURITY_VIOLATION. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Release SNP devices before starting SAN boot imageMichael Brown2018-03-261-0/+4
| | | | | | | | Release SNP devices to allow the SAN booted image to use our EFI_SIMPLE_NETWORK_PROTOCOL instance, and to ensure that the image is started at TPL_APPLICATION. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Provide sandev_read() and sandev_write() as global symbolsMichael Brown2017-04-261-9/+8Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Allow use of a non-default EFI SAN boot filenameMichael Brown2017-04-121-6/+16
| | | | | | | | | | | | | | | | | | | | | | | Some older operating systems (e.g. RHEL6) use a non-default filename on the root disk and rely on setting an EFI variable to point to the bootloader. This does not work when performing a SAN boot on a machine where the EFI variable is not present. Fix by allowing a non-default filename to be specified via the "sanboot --filename" option or the "san-filename" setting. For example: sanboot --filename \efi\redhat\grub.efi \ iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6 or option ipxe.san-filename code 188 = string; option ipxe.san-filename "\\efi\\redhat\\grub.efi"; option root-path "iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6"; Originally-implemented-by: Vishvananda Ishaya Abrams <vish.ishaya@oracle.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Describe all SAN devices via ACPI tablesMichael Brown2017-03-281-64/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Describe all SAN devices via ACPI tables such as the iBFT. For tables that can describe only a single device (i.e. the aBFT and sBFT), one table is installed per device. For multi-device tables (i.e. the iBFT), all devices are described in a single table. An underlying SAN device connection may be closed at the time that we need to construct an ACPI table. We therefore introduce the concept of an "ACPI descriptor" which enables the SAN boot code to maintain an opaque pointer to the underlying object, and an "ACPI model" which can build tables from a list of such descriptors. This separates the lifecycles of ACPI descriptions from the lifecycles of the block device interfaces, and allows for construction of the ACPI tables even if the block device interface has been closed. For a multipath SAN device, iPXE will wait until sufficient information is available to describe all devices but will not wait for all paths to connect successfully. For example: with a multipath iSCSI boot iPXE will wait until at least one path has become available and name resolution has completed on all other paths. We do this since the iBFT has to include IP addresses rather than DNS names. We will commence booting without waiting for the inactive paths to either become available or close; this avoids unnecessary boot delays. Note that the Linux kernel will refuse to accept an iBFT with more than two NIC or target structures. We therefore describe only the NICs that are actually required in order to reach the described targets. Any iBFT with at most two targets is therefore guaranteed to describe at most two NICs. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Add basic multipath supportMichael Brown2017-03-261-6/+19
| | | | | | | | | | | Add basic support for multipath block devices. The "sanboot" and "sanhook" commands now accept a list of SAN URIs. We open all URIs concurrently. The first connection to become available for issuing block device commands is marked as the active path and used for all subsequent commands; all other connections are then closed. Whenever the active path fails, we reopen all URIs and repeat the process. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Provide ACPI table description for SAN devicesMichael Brown2017-03-131-0/+69
| | | | | | | | | Provide a basic proof of concept ACPI table description (e.g. iBFT for iSCSI) for SAN devices in a UEFI environment, using a control flow that is functionally identical to that used in a BIOS environment. Originally-implemented-by: Vishvananda Ishaya Abrams <vish.ishaya@oracle.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Refactor to use centralised SAN device abstractionMichael Brown2017-03-071-650/+161Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Centralise "san-drive" settingMichael Brown2017-03-071-1/+0Star
| | | | | | | | | | | | The concept of the SAN drive number is meaningful only in a BIOS environment, where it represents the INT13 drive number (0x80 for the first hard disk). We retain this concept in a UEFI environment to allow for a simple way for iPXE commands to refer to SAN drives. Centralise the concept of the default drive number, since it is shared between all supported environments. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add basic EFI SAN booting capabilityMichael Brown2016-11-171-0/+1062
Signed-off-by: Michael Brown <mcb30@ipxe.org>