From patchwork Mon Jan 14 15:27:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 155541 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3794822jaa; Mon, 14 Jan 2019 07:39:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN7cpo7op2NqT94tKh5fIC/QkT9ySbwWlXRhXVw3V6czzmyoPbqgPH+wiHVvckRBZ3ZBkSBL X-Received: by 2002:adf:fa05:: with SMTP id m5mr24177605wrr.155.1547480384641; Mon, 14 Jan 2019 07:39:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547480384; cv=none; d=google.com; s=arc-20160816; b=Cn0oyvmXaIFj1n47Jpn4hGkbBFwFZcGd2jnEg/ZYOiEcmrT5UeSJSrKiEm7uygah6p Cfw8eQSsvlMHsfOgU/z8J5cwqi/Q5k66CsXOrUN+NCr2G5hJMzLfXiDfN5dMT78+XHeb mCnPbGEjLu68HQCmjosiF/IQGRynBLoeCidTBbcssmPTp1S4ua3D2RfmifDlZbqjew7c mC0QcdTS5kMxDTm7xSSsicQW0WZKAs10rShxf3X6YeIhLDFl5UNnRPZ2jiMThjIrJaPP Fh5Zjqh6lbiaLbLUFhtuIiE4/PcsF43isT0VNTp75XL1wup1HktFB6qqk9gJJ+WVibBh 1gLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from; bh=7aVPQ3yE+GuPKI2PeufUa+7OydZ4YdBfVuo5J2jU86E=; b=r8QCJEldJRoq6fBKiMn48VNT412yaExfCjYo55SQKKpXoRgjMisC70oryovBFX23bB WIQR7kv0c9Dc68OpQaUkUNfohKDn7BsRUStkqPW3xMDZNosi3LHUEZeE6fDGEzX4LGqa 6+JUQkkK71+j3AmD+FC62aL8+heXcMCbBOVvgXHhPXLQjHQb8SbfmF7Nj6bi83uVAUge wLsZNIOcB8izDLUY8zeanHTdpqjfuHgmD9GYCOVdTVbI9OS25ecEg8lsxL+gr/Vh0Bvw nlujaI29Y8BiklrzuX20FR/wb8hJgWzepbc2/IV6UNTEhvpUVjt4+ZNm6OMYRU2ouRfg qasQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h133si19277083wmf.41.2019.01.14.07.39.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 Jan 2019 07:39:44 -0800 (PST) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Received: from localhost ([127.0.0.1]:56138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj4L1-00062j-KO for patch@linaro.org; Mon, 14 Jan 2019 10:39:43 -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 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: , Reply-To: The development of GNU GRUB Cc: Jon Masters , Daniel Kiper , Leif Lindholm , Ard Biesheuvel MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" 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(-) -- 2.12.3 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel 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[] = {