]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[efi] Allow wrapping the global boot services table in situ
authorMichael Brown <mcb30@ipxe.org>
Thu, 20 Mar 2025 12:25:26 +0000 (12:25 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 20 Mar 2025 12:35:42 +0000 (12:35 +0000)
commit1a602c92ac865762a96125081fc9173b95aa50a0
tree90e04e9a080b6ee55b6cc298285edbca457d9039
parentf68c8b09e39f1837ea6344f465d62e4b2c62a1c9
[efi] Allow wrapping the global boot services table in situ

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>
src/image/efi_image.c
src/include/ipxe/efi/efi_wrap.h
src/interface/efi/efi_wrap.c