grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 2/2] mkimage: arm64-efi: Align first section to page


From: Alexander Graf
Subject: [PATCH v2 2/2] mkimage: arm64-efi: Align first section to page
Date: Sun, 23 Dec 2018 03:52:07 +0100

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 <address@hidden>

---

v1 -> v2:

  - Mention only NX requirement in patch description
  - Use GRUB_EFI_PAGE_SIZE
---
 util/mkimage.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util/mkimage.c b/util/mkimage.c
index 88b991764..de93c5a13 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>
@@ -623,7 +624,7 @@ static const struct grub_install_image_target_desc 
image_targets[] =
       .decompressor_uncompressed_size = TARGET_NO_FIELD,
       .decompressor_uncompressed_addr = TARGET_NO_FIELD,
       .section_align = GRUB_PE32_SECTION_ALIGNMENT,
-      .vaddr_offset = EFI64_HEADER_SIZE,
+      .vaddr_offset = GRUB_EFI_PAGE_SIZE,
       .pe_target = GRUB_PE32_MACHINE_ARM64,
       .elf_target = EM_AARCH64,
     },
-- 
2.12.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]