From patchwork Sun Dec 23 02:52:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 154441 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2558502ljp; Sat, 22 Dec 2018 18:52:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN5OQAROXLxVO74R3V5sPMAFEWyJNrDCR8w6hpfb0vzrVCQ2I6YKd1RzbUDAnYO2DOayd2fx X-Received: by 2002:a37:8541:: with SMTP id h62mr7518422qkd.213.1545533543013; Sat, 22 Dec 2018 18:52:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545533543; cv=none; d=google.com; s=arc-20160816; b=SuzVez14DyWnrlpqjo+pn0plGaL5mhEtucwE5SYOBTXCS2AslL91ZjOqcn7cP9paYD VZ9UG2un/gd8WgMQ9Y9hHACOBIKncbPkOOZlups3t0nSWCcyi0oP6HCTYIwG0QJeK5KL ypH9jqMpwYifNBcEhvg2/qMqFrotNOpA07pgjpuIHxE8pRfUMC9Z3PmP7/1HPm+yFPwv 8E8MaOjb+Ph3ZUzDyvVqH9BILLUVLVIroeh5h2BVfEcLTzWDnGtSqpLoenYRZt3b7RZU +KcilGsK+4iGU958BeDf3MAN/NH4sytrcyYFmBYgZvNePxt75Rz6XewWU+IV33L+xCrk 9hWA== 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=qncc3kkyUtI8R06HCnpgBtKrC7kdh+8rL30j4yZwusw=; b=z+qPJKBoTZtubvLgyrTNQucCi7Nb9g3EY+MB2c4qMGEbvTYlCQOkDzqthc6yo6UZTd 9kmdKQbiqfj83vXETChEu989zxd40SNuqYP+evuD/CLjpYfLpu7ualn49sMP/5QtHdbz w6fXLrLcp8ZCQ/MyLMvPNwMpdriBEUloEPAAR9lDphf6Zf4NiGO+2hQWQ2qFr9TrYEqF eSEhbFh4yX09K58qo/9My0ErdYsJqpG7dc04iXTNialnsMHThCzx9NbN86l0iEC/oaQ9 coXUL57dnilhD14NPGGIz+RG435SHK3CdkEj93wnJh/JtHO7tHoRDHmXt6vOptn+oTpz 8Vvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::12 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Return-Path: Received: from lists.nongnu.org (lists.nongnu.org. [2001:4830:134:3::12]) by mx.google.com with ESMTPS id o14si582904qtr.110.2018.12.22.18.52.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 22 Dec 2018 18:52:23 -0800 (PST) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::12 as permitted sender) client-ip=2001:4830:134:3::12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::12 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Received: from localhost ([::1]:52103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gatsM-0002vs-Gr for patch@linaro.org; Sat, 22 Dec 2018 21:52:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gatsG-0002vd-0b for grub-devel@gnu.org; Sat, 22 Dec 2018 21:52:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gatsB-0006Jr-38 for grub-devel@gnu.org; Sat, 22 Dec 2018 21:52:15 -0500 Received: from mx2.suse.de ([195.135.220.15]:44730 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 1gatsA-0006IK-RL for grub-devel@gnu.org; Sat, 22 Dec 2018 21:52:10 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BBD61AF31; Sun, 23 Dec 2018 02:52:08 +0000 (UTC) From: Alexander Graf To: grub-devel@gnu.org Subject: [PATCH v2 1/2] mkimage: Simplify header size logic Date: Sun, 23 Dec 2018 03:52:06 +0100 Message-Id: <20181223025207.40755-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20181223025207.40755-1-agraf@suse.de> References: <20181223025207.40755-1-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] 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 , Leif Lindholm , Ard Biesheuvel MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" 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 --- util/mkimage.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.12.3 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel Reviewed-by: Daniel Kiper diff --git a/util/mkimage.c b/util/mkimage.c index 353bb1098..88b991764 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -1226,10 +1226,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); From patchwork Sun Dec 23 02:52:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 154442 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2558513ljp; Sat, 22 Dec 2018 18:52:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/W61XTw3TK/7/nygPg+ZFilqWruLZuJcg1FprulE6/lSPQalIHYiaB9IHA6F3fcPltVx5za X-Received: by 2002:aed:3105:: with SMTP id 5mr7868478qtg.364.1545533544945; Sat, 22 Dec 2018 18:52:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545533544; cv=none; d=google.com; s=arc-20160816; b=R3TTy22FM/KI0LDQhBHZOVtyuPPiJUXKkd1ZgZwru9w2at9l77MpEYwDk+XzxIU8M8 CtG6RlTCFKUDw2mvn+TycYBpNpoo3wuUgYvjHlqaHRj/LCxFfEiTZK+6slnaUrtmlFhx hEPTGJgY40lbZOyCFcuw4l7euQeACPVrNiYTzwLtG456UM3EhmV5LFY6vhYRlqUdItBR y3jXwQ97G6VXD5fhcEuQqeXdx5hJm7lSfBkp71lmRPLwmEsb+1SY/dlugpmFFHPTIalH gV+QaxU+8CCTYy2gmGyh5NZNLkCbG6iii2Jm68DL9eek3xt7vvBdgy54kNf1iMypn6F3 Sd4w== 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=KVoRKPJD53bKz5zQbNZPVDnb2nb+VyYWryOrcOqJ+E8=; b=PAWv2ER8pnkdOA/st/6wyvs22POTpIuUf/WyVeC1oghl3M9WzdqIY8MWDzY07WEMQ/ WsixamsF7Z2ZcTYqgnYyXxeyvyWhcCOYNS8hJGVIZFYx1DAZHhzvRIP4dUEZ3NA8/afI 6TvSlBMOKOnKrIr32DjUSJZWqBNuF2EIbQWSMiPQZKzviN9E+h3EqI+Un5OZuHBwwsA/ bg5ziUj9sFsZFZp2SDT5ntuxbrrhGEONBqoMpBGa/XC1+E7mlKYLowb9YjDJB1n+JVFl OriTdKGw5JcvJrP9aIhKIH6ExEJyhk5WH8HzmLeIYOrOz3ndWeVLZ/m9X3jerZOM3M3J 0H3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::12 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Return-Path: Received: from lists.nongnu.org (lists.nongnu.org. [2001:4830:134:3::12]) by mx.google.com with ESMTPS id k68si1291551qte.349.2018.12.22.18.52.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 22 Dec 2018 18:52:24 -0800 (PST) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::12 as permitted sender) client-ip=2001:4830:134:3::12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::12 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Received: from localhost ([::1]:52122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gatsO-0002wu-FK for patch@linaro.org; Sat, 22 Dec 2018 21:52:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gatsG-0002vf-1E for grub-devel@gnu.org; Sat, 22 Dec 2018 21:52:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gatsB-0006Jf-2Z for grub-devel@gnu.org; Sat, 22 Dec 2018 21:52:15 -0500 Received: from mx2.suse.de ([195.135.220.15]:44726 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 1gatsA-0006IJ-RI for grub-devel@gnu.org; Sat, 22 Dec 2018 21:52:10 -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 BDDB2AF3B; Sun, 23 Dec 2018 02:52:08 +0000 (UTC) From: Alexander Graf To: grub-devel@gnu.org Subject: [PATCH v2 2/2] mkimage: arm64-efi: Align first section to page Date: Sun, 23 Dec 2018 03:52:07 +0100 Message-Id: <20181223025207.40755-3-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20181223025207.40755-1-agraf@suse.de> References: <20181223025207.40755-1-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] 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 , 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 --- util/mkimage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 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 88b991764..de93c5a13 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -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, },