From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gj37x-0007Xz-UY for mharc-grub-devel@gnu.org; Mon, 14 Jan 2019 09:22:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj37v-0007Vd-GH for grub-devel@gnu.org; Mon, 14 Jan 2019 09:22:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gj37t-00075H-Jt for grub-devel@gnu.org; Mon, 14 Jan 2019 09:22:07 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:40219) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gj37r-0006zp-8n for grub-devel@gnu.org; Mon, 14 Jan 2019 09:22:05 -0500 Received: by mail-wr1-x442.google.com with SMTP id p4so23057046wrt.7 for ; Mon, 14 Jan 2019 06:21:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VBbnwVhw3GzmT3i1MiG74bPe6zgXNRBRckGNrkmnudw=; b=ctKAe+eKeLnmgiL/6yRSObDXc9JSfmfPt/O/zNncqaO6gBZz8COqRb8AA+anIJLXIV LzpXpgD9ODvAdY7qUwcc96Iyqy0jbMmjXkhM9KHfa3nM+FgjU/OCvbHZj/7s4O6Opmmv 0fqPjcwgGdVBM2OEVGJy6aYayncIynEv1KQrs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VBbnwVhw3GzmT3i1MiG74bPe6zgXNRBRckGNrkmnudw=; b=rcuzVsRY93u+ZzYttWLugdH9qRpHerQD76BXQgmUKjfFYYKMHXRe7l+my6w7m23kRH XP0YwfwkBhG0G/UBYLSHomyLuKWud0EC+OaoY2LjFTreZiSkKaTwpq32ChrM9tnFap2U PLtWc32pkT/sUnBEQPEgDPx27/sLnf5lOamgEVfZiQBla0vJr/fqqbNbIMxvWoKLsW1P wN7YOcGW01kE6iOIbvrnpnZqGIcjxdvywzmIEXppIcoT9MNKHI+v8+ZSXhPS4hl5Yoou bFepyQjjlqcm73Qk2RbY/8S4pXhCcfQtyZFXjemfr2sMuXDm7rsodM3WDksh8zHbeNPW Ze8g== X-Gm-Message-State: AJcUukdHbEFHhKvQsXDJNp/e4G1KXFo873yrdJk46C9HuyMWVZQH8U2U HmmFbpO41tNEPMQCqTuVXLIZWA== X-Google-Smtp-Source: ALg8bN5dVe+T+oSgXb3asbRT3O0x/Xu2BA7VxUZxQ7zAJpZrFMSlclf9adJLCehwwzhqDlqyYcyijA== X-Received: by 2002:adf:8c09:: with SMTP id z9mr24668126wra.301.1547475716468; Mon, 14 Jan 2019 06:21:56 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id u204sm49310205wmu.30.2019.01.14.06.21.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 06:21:55 -0800 (PST) Date: Mon, 14 Jan 2019 14:21:54 +0000 From: Leif Lindholm To: Alexander Graf Cc: Daniel Kiper , grub-devel@gnu.org, Jon Masters , Ard Biesheuvel Subject: Re: [PATCH v2 2/2] mkimage: arm64-efi: Align first section to page Message-ID: <20190114142154.uonzhvn4ry6xltgx@bivouac.eciton.net> References: <20181223025207.40755-1-agraf@suse.de> <20181223025207.40755-3-agraf@suse.de> <20190114133742.qevv52titdjzve2y@tomti.i.net-space.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 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 14:22:08 -0000 On Mon, Jan 14, 2019 at 02:41:30PM +0100, Alexander Graf wrote: > On 01/14/2019 02:37 PM, Daniel Kiper wrote: > > On Sun, Dec 23, 2018 at 03:52:07AM +0100, Alexander Graf wrote: > > > 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(-) > > > > > > 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, > > Nack. > > > > I think that we will soon have the same problem on other targtes. > > So, I would try this: > > > > #define EFI32_HEADER_SIZE ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE \ > > + GRUB_PE32_SIGNATURE_SIZE \ > > + sizeof (struct grub_pe32_coff_header) \ > > + sizeof (struct grub_pe32_optional_header) \ > > + 4 * sizeof (struct grub_pe32_section_table), \ > > ALIGN_UP (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), \ > > ALIGN_UP (GRUB_PE32_SECTION_ALIGNMENT, GRUB_EFI_PAGE_SIZE)) > > > > And there is another problem with your proposal. What will happen > > if EFI64_HEADER_SIZE > GRUB_EFI_PAGE_SIZE? > > I don't think it ever can be, can it? The header size is pretty constant. > > > Additionally, why arm-efi is different? > > Mostly because in the wild I have not seen anyone on non-aarch64 pull in > page alignment requirements :). arm-efi is mainly different in that I don't expect non-embedded 32-bit devices to show up. There would be nothing wrong in applying the same change. There is an argument for i386/x86_64 to do the same as arm64, but ... > But yes, I'll be happy to redo the patch and make EFI binaries always 4k > aligned. I also learned in an off-list mailing list thread, that newer > versions of that Qcom firmware require 4k section alignments, so I will push > for that across all targets too. That way we should be aligned with the MS > compiler suite. Ouch. But, yes, that would also make sense. / Leif