summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_wrap.c
Commit message (Collapse)AuthorAgeFilesLines
* [build] Mark core files as permitted for UEFI Secure BootMichael Brown2026-01-141-0/+1
| | | | | | | | | | | | Mark all files used in a standard build of bin-x86_64-efi/snponly.efi as permitted for UEFI Secure Boot. These files represent the core functionality of iPXE that is guaranteed to have been included in every binary that was previously subject to a security review and signed by Microsoft. It is therefore legitimate to assume that at least these files have already been reviewed to the required standard multiple times. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Wrap a selection of runtime services callsMichael Brown2025-11-131-7/+248
| | | | | | | Allow DEBUG=efi_wrap to trace various runtime services calls as well as the existing boot services calls. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Switch back to VA_START() etc macros for EFIAPI functionsMichael Brown2025-11-111-12/+12
| | | | | | | | | | | | | | | | | | Commit 670810b ("[efi] Use standard va_args macros instead of VA_START() etc") fixed a 32-bit RISC-V build error, but broke the functionality of the InstallMultipleProtocolInterfaces() and UninstallMultipleProtocolInterfaces() wrapper functions. GCC does not automatically check the ABI of the current function when using the __builtin_va_start() and related macros, and it is therefore necessary for code to use __builtin_ms_va_start() etc from within functions marked as EFIAPI. Since commit 9016f2e ("[efi] Skip including the EDK2 ProcessorBind.h header for 32-bit RISC-V") has now fixed the original 32-bit RISC-V build error, we can switch back to using the EDK2 VA_START() etc macros to obtain the correct behaviour. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Provide efi_tpl_name() for transcribing TPLs in debug messagesMichael Brown2025-07-141-28/+7Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Allow use of typed pointers for efi_open() et alMichael Brown2025-03-241-9/+6Star
| | | | | | | | | Provide wrapper macros to allow efi_open() and related functions to accept a pointer to any pointer type as the "interface" argument, in order to allow a substantial amount of type adjustment boilerplate to be removed. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Use efi_open() for all ephemeral protocol opensMichael Brown2025-03-241-11/+2Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Allow wrapping the global boot services table in situMichael Brown2025-03-201-63/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | When DEBUG=efi_wrap is enabled, we construct a patched copy of the boot services table and patch the global system table to point to this copy. This ensures that any subsequently loaded EFI binaries will call our wrappers. Previously loaded EFI binaries will typically have cached the boot services table pointer (in the gBS variable used by EDK2 code), and therefore will not pick up the updated pointer and so will not call our wrappers. In most cases, this is what we want to happen: we are interested in tracing the calls issued by the newly loaded binary and we do not want to be distracted by the high volume of boot services calls issued by existing UEFI drivers. In some circumstances (such as when a badly behaved OEM driver is causing the system to lock up during the ExitBootServices() call), it can be very useful to be able to patch the global boot services table in situ, so that we can trace calls issued by existing drivers. Restructure the wrapping code to allow wrapping to be enabled or disabled at any time, and to allow for patching the global boot services table in situ. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Fix debug wrappers for CloseEvent() and CheckEvent()Michael Brown2025-03-191-2/+2
| | | | | | | | | | | The debug wrappers for CloseEvent() and CheckEvent() are currently both calling SignalEvent() instead (presumably due to copy-paste errors). Astonishingly, this has generally not prevented a successful boot in the (very rare) case that DEBUG=efi_wrap is enabled. Fix the wrappers to call the intended functions. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Prescroll the display after a failed wrapped ExitBootServices() callMichael Brown2025-03-181-0/+44
| | | | | | | | | | | | | | | | On some systems (observed with an HP Elitebook 840 G10), writing console output that happens to cause the display to scroll will modify the system memory map. This causes builds with DEBUG=efi_wrap to typically fail to boot, since the debug output from the wrapped ExitBootServices() call itself is sufficient to change the memory map and therefore cause ExitBootServices() to fail due to an invalid memory map key. Work around these UEFI firmware bugs by prescrolling the display after a failed ExitBootServices() attempt, in order to minimise the chance that further scrolling will happen during the subsequent attempt. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Use standard va_args macros instead of VA_START() etcMichael Brown2024-09-151-12/+12
| | | | | | | | | | The EDK2 header macros VA_START(), VA_ARG() etc produce build errors on some CPU architectures (notably on 32-bit RISC-V, which is not yet supported by EDK2). Fix by using the standard variable argument list macros. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Modify global system table when wrapping a loaded imageMichael Brown2021-11-211-43/+56
| | | | | | | | | | | | | | | | | | | The EFI loaded image protocol allows an image to be provided with a custom system table, and we currently use this mechanism to wrap any boot services calls made by the loaded image in order to provide strace-like debugging via DEBUG=efi_wrap. The ExitBootServices() call will modify the global system table, leaving the loaded image using a system table that is no longer current. When DEBUG=efi_wrap is used, this generally results in the machine locking up at the point that the loaded operating system calls ExitBootServices(). Fix by modifying the global EFI system table to point to our wrapper functions, instead of providing a custom system table via the loaded image protocol. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Do not attempt to use console output after ExitBootServices()Michael Brown2021-11-211-3/+6
| | | | | | | | | A successful call to ExitBootServices() will result in the EFI console becoming unusable. Ensure that the EFI wrapper produces a complete line of debug output before calling the wrapped ExitBootServices() method, and attempt subsequent debug output only if the call fails. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Allow DEBUG=efi_wrap to be used independently of a loaded imageMichael Brown2020-10-011-25/+34
| | | | | | | | | | Allow temporary debugging code to call efi_wrap_systab() to obtain a pointer to the wrapper EFI system table. This can then be used to e.g. forcibly overwrite the boot services table pointer used by an already loaded and running UEFI driver, in order to trace calls made by that driver. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Show memory map returned by wrapped calls to GetMemoryMapMichael Brown2020-09-221-2/+20
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add debug wrappers for all boot services functions of interestMichael Brown2020-09-191-0/+602
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Improve efi_wrap debuggingMichael Brown2015-08-271-12/+318
| | | | | | | Add debug wrappers for more boot services functions, and print symbolic values rather than raw numbers where possible. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Remove raw EFI_HANDLE values from debug messagesMichael Brown2015-08-271-27/+22Star
| | | | | | | | | The raw EFI_HANDLE value is almost never useful to know, and simply adds noise to the already verbose debug messages. Improve the legibility of debug messages by using only the name generated by efi_handle_name(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-021-1/+5
| | | | | | | Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Wrap any images loaded by our wrapped imageMichael Brown2014-08-291-21/+67
| | | | | | | | | | | | Propagate our modified EFI system table to any images loaded by the image that we wrap, thereby allowing us to observe boot services calls made by all subsequent EFI images. Also show details of intercepted ExitBootServices() calls. When wrapping is used, exiting boot services will almost certainly fail, but this at least allows us to see when it happens. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Show details of intercepted LoadImage() callsMichael Brown2014-08-271-0/+30
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Use efi_handle_name() instead of efi_handle_devpath_text()Michael Brown2014-07-311-8/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Show more diagnostic information when building with DEBUG=efi_wrapMichael Brown2014-07-261-3/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Allow for interception of boot services calls by loaded imageMichael Brown2014-07-161-0/+237
When building with DEBUG=efi_wrap, print details of calls made by the loaded image to selected boot services functions. Signed-off-by: Michael Brown <mcb30@ipxe.org>