In order to enforce NX semantics on non-code pages, UEFI firmware may require that all code is EFI_PAGE_SIZE (4k) aligned. A similar change has recently been applied to edk2 to accomodate for the same fact:
https://lists.01.org/pipermail/edk2-devel/2018-December/033708.html This patch adapts grub to also implement the same alignment guarantees and thus ensures we can boot even when strict permission checks are in place. Signed-off-by: Alexander Graf <ag...@suse.de> --- v1 -> v2: - Mention only NX requirement in patch description - Use GRUB_EFI_PAGE_SIZE v2 -> v3: - Apply alignment to all architectures --- util/mkimage.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/mkimage.c b/util/mkimage.c index a670db456..6b372cba5 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -39,6 +39,7 @@ #include <string.h> #include <stdlib.h> #include <assert.h> +#include <grub/efi/memory.h> #include <grub/efi/pe32.h> #include <grub/uboot/image.h> #include <grub/arm/reloc.h> @@ -66,14 +67,14 @@ + sizeof (struct grub_pe32_coff_header) \ + sizeof (struct grub_pe32_optional_header) \ + 4 * sizeof (struct grub_pe32_section_table), \ - GRUB_PE32_SECTION_ALIGNMENT) + GRUB_EFI_PAGE_SIZE) #define EFI64_HEADER_SIZE ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE \ + GRUB_PE32_SIGNATURE_SIZE \ + sizeof (struct grub_pe32_coff_header) \ + sizeof (struct grub_pe64_optional_header) \ + 4 * sizeof (struct grub_pe32_section_table), \ - GRUB_PE32_SECTION_ALIGNMENT) + GRUB_EFI_PAGE_SIZE) static const struct grub_install_image_target_desc image_targets[] = { -- 2.12.3 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel