efi/libstub/arm64: Use 1:1 mapping of RT services if property table exists
Ard Biesheuvel
maintainerPATCH v2 1/1 efi/libstub/arm64: Use 1:1 mapping of RT services if property table exists
The UEFI spec defines (and deprecates) a misguided and shortlived memory protection feature that is based on splitting memory regions covering PE/COFF executables into separate code and data regions, without annotating them as belonging to the same executable image. When the OS assigns the virtual addresses of these regions, it may move them around arbitrarily, without taking into account that the PE/COFF code sections may contain relative references into the data sections, which means the relative placement of these segments has to be preserved or the executable image will be corrupted.
The original workaround on arm64 was to ensure that adjacent regions of the same type were mapped adjacently in the virtual mapping, but this requires sorting of the memory map, which we would prefer to avoid.
Considering that the native physical mapping of the PE/COFF images does not suffer from this issue, let's preserve it at runtime, and install it as the virtual mapping as well.
---
v2: call SetVirtualAddressMap() with 1:1 mapping rather than not calling it at
all if the properties table exists and has the NX PE data attribute set
drivers/firmware/efi/libstub/Makefile | 1 - drivers/firmware/efi/libstub/arm-stub.c | 84 +++++--------------- 2 files changed, 22 insertions(+), 63 deletions(-)
drivers/firmware/efi/libstub/Makefile +0 -1
@@ -43,7 +43,6 @@ lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o \ # include the stub's generic dependencies from lib/ when building for ARM/arm64 arm-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c -arm-deps-$(CONFIG_ARM64) += sort.c $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE $(call if_changed_rule,cc_o_c)
drivers/firmware/efi/libstub/arm-stub.c +22 -62
143 lines not on this page · raw message
Signature · 1 line
2.17.1