Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gj49C-0003Pn-3E for mharc-grub-devel@gnu.org; Mon, 14 Jan 2019 10:27:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj495-0003MH-Mj for grub-devel@gnu.org; Mon, 14 Jan 2019 10:27:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gj492-00089T-CF for grub-devel@gnu.org; Mon, 14 Jan 2019 10:27:21 -0500 Received: from mx2.suse.de ([195.135.220.15]:36424 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gj492-00088k-5G for grub-devel@gnu.org; Mon, 14 Jan 2019 10:27:20 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0C433AF99; Mon, 14 Jan 2019 15:27:19 +0000 (UTC) From: Alexander Graf To: grub-devel@gnu.org Cc: Leif Lindholm , Peter Jones , Jon Masters , Ard Biesheuvel , Daniel Kiper Subject: [PATCH v3 3/4] mkimage: arm64-efi: Align header to page granularity Date: Mon, 14 Jan 2019 16:27:17 +0100 Message-Id: <20190114152718.60629-4-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20190114152718.60629-1-agraf@suse.de> References: <20190114152718.60629-1-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2019 15:27:27 -0000 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 --- 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 #include #include +#include #include #include #include @@ -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