UEFI specification does not guarantee that all memory would be executable and there exist some UEFI implementations imposing stricter memory management policies and restricting execution of memory where trampoline code generated by relocator is placed. That causes page fault during boot.
Explicitly set memory attributes using DXE services for memory region possibly occupied with trampoline code and data. This patch works in the same way as the following patch for the Linux kernel [1]. Later the use of DXE services can be replaced with UEFI_MEMORY_ATTRIBUTE protocol, when it will become ready [2]. [1] https://lkml.org/lkml/2022/3/3/532 [2] https://bugzilla.tianocore.org/show_bug.cgi?id=3519 Baskov Evgeniy(3): efi: explicitly set memory attributes for memory relocator: allocate trampoline in lower 640k efi: provide definitions of DXE services table grub-core/kern/efi/efi.c | 11 + grub-core/kern/efi/mm.c | 67 ++++++++++++ grub-core/lib/i386/relocator.c | 5 grub-core/lib/relocator.c | 1 grub-core/lib/x86_64/efi/relocator.c | 6 - grub-core/loader/i386/bsd.c | 2 include/grub/efi/api.h | 149 +++++++++++++++++++++++++++ include/grub/efi/efi.h | 3 include/grub/i386/relocator.h | 3 9 files changed, 238 insertions(+), 9 deletions(-) _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel