Commit 50aec403 authored by Colin Watson's avatar Colin Watson

Set arm64-efi code offset to EFI_PAGE_SIZE

Closes: #919012
parents 946df7ed 73b07367
# see git-dpm(1) from git-dpm package
0e3e215f58cbacbd623a19c5283da412d729cc65
0e3e215f58cbacbd623a19c5283da412d729cc65
73b07367fbcdaeae0ebdad3101726e0274e1943f
73b07367fbcdaeae0ebdad3101726e0274e1943f
59aeb1cfaa3d5bfd7bbeeee0f0d37f6d9eed51fe
59aeb1cfaa3d5bfd7bbeeee0f0d37f6d9eed51fe
grub2_2.02+dfsg1.orig.tar.xz
......
grub2 (2.02+dfsg1-11) UNRELEASED; urgency=medium
* Apply patches from Alexander Graf to set arm64-efi code offset to
EFI_PAGE_SIZE (closes: #919012).
-- Colin Watson <cjwatson@debian.org> Sat, 12 Jan 2019 10:44:52 +0000
grub2 (2.02+dfsg1-10) unstable; urgency=medium
* Apply patch from Heinrich Schuchardt (mentioned in #916695 though
......
From 73b07367fbcdaeae0ebdad3101726e0274e1943f Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Sun, 23 Dec 2018 03:52:07 +0100
Subject: mkimage: arm64-efi: Align first section to page
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 <agraf@suse.de>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Origin: other, https://lists.gnu.org/archive/html/grub-devel/2018-12/msg00055.html
Bug-Debian: https://bugs.debian.org/919012
Last-Update: 2019-01-12
Patch-Name: mkimage-arm64-efi-align-first-section-to-page.patch
---
util/mkimage.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/util/mkimage.c b/util/mkimage.c
index 412e85f26..ab23bbf6e 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>
@@ -584,7 +585,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,
},
From f2b469a2eb0114805d3294c48d2cb4a73db43f92 Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Sun, 23 Dec 2018 03:52:06 +0100
Subject: mkimage: Simplify header size logic
For EFI images, we always have the following layout:
[PE header]
[padding]
[first section (which also is the entry point)]
Currently there are 2 places where we define how big header+padding are:
in the .vaddr_offset member of our target image definition struct as well
as in code in grub_install_generate_image().
Remove the latter, so that we only have a single place to modify if we
need to change the padding.
Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Origin: other, https://lists.gnu.org/archive/html/grub-devel/2018-12/msg00054.html
Bug-Debian: https://bugs.debian.org/919012
Last-Update: 2019-01-12
Patch-Name: mkimage-simplify-header-size-logic.patch
---
util/mkimage.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/util/mkimage.c b/util/mkimage.c
index c3bd23479..412e85f26 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -1169,10 +1169,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
int header_size;
int reloc_addr;
- if (image_target->voidp_sizeof == 4)
- header_size = EFI32_HEADER_SIZE;
- else
- header_size = EFI64_HEADER_SIZE;
+ header_size = image_target->vaddr_offset;
reloc_addr = ALIGN_UP (header_size + core_size,
image_target->section_align);
......@@ -120,3 +120,5 @@ xen-pvh-elfnote-defines.patch
xen-pvh-mkimage.patch
xen-pvh-install.patch
xen-pvh-configure.patch
mkimage-simplify-header-size-logic.patch
mkimage-arm64-efi-align-first-section-to-page.patch
......@@ -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>
......@@ -584,7 +585,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,
},
......@@ -1169,10 +1170,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
int header_size;
int reloc_addr;
if (image_target->voidp_sizeof == 4)
header_size = EFI32_HEADER_SIZE;
else
header_size = EFI64_HEADER_SIZE;
header_size = image_target->vaddr_offset;
reloc_addr = ALIGN_UP (header_size + core_size,
image_target->section_align);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment