[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 3/4] mkimage: arm64-efi: Align header to page granularity
From: |
Alexander Graf |
Subject: |
[PATCH v3 3/4] mkimage: arm64-efi: Align header to page granularity |
Date: |
Mon, 14 Jan 2019 16:27:17 +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
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
[PATCH v3 1/4] mkimage: Simplify header size logic, Alexander Graf, 2019/01/14
[PATCH v3 4/4] mkimage: Align efi sections on 4k boundary, Alexander Graf, 2019/01/14
[PATCH v3 2/4] mkimage: Use EFI32_HEADER_SIZE define in arm-efi case, Alexander Graf, 2019/01/14