From patchwork Wed Nov 28 14:31: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: 152270 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1160579ljp; Wed, 28 Nov 2018 06:31:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/WjD+wWibvIAQyYwa1h3fL+xbPbGnmLEwsS+7na6rNAfzji4O+7n0Nexqb7d6KVfLyjsZhQ X-Received: by 2002:a25:b990:: with SMTP id r16-v6mr37086181ybg.74.1543415492373; Wed, 28 Nov 2018 06:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543415492; cv=none; d=google.com; s=arc-20160816; b=FI3HmITEQzP2B3e80wvzzXAEOla84OkgWto0fUAg9axwwi+DUSc2SwklHN64s2taas M+ZYrqFHBWjZ//5M4ErenOmUkvxGGTolSjD4mc+/CxaTVi8n4NL0A9pPZee72CcxXzbb o/wbH9WLQ/nPhTgHjKlXl4uPP+R32NRvF0RlkpiampOoBEvgljGA2lcUE/ujf2kPoq/y h0nlEGA/XCRjOtuM94Q5oapoYRLy6PNBTGKPmoTaMEWleIPxWduGqAxZjLyYL1+ZLOW9 4QOh2XGkbwwxJ9B181lNZrgqPIGgc4JHxHPIXJMrbl+2vDWaq9aWMERLNzsFGYU4YCcq HlLQ== 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=YGcDAWrxmuJrKgjO3xTe9jA3xeCHS/gE2TNPEeAI+/g=; b=rUicehuJVEU/YWIsLcHs1czVtyyPmArepsn6nfwT24JZYSIL/bKxVVisnmJlWvzuCx FKUd2Xh71tEjGNIDD/8co9CtZR5IlQKXJTpXIf/48sWeyMuljvhUowcqKdqObcvjnRvX yY2Z5ieYk7X/huRMge6Ce8SCIVBhMau8+GjvO7faejvjLUf5yUflZNrHooCHtlBqBQma Em54HzoZq9KhnqJ7TtoSzrPJcBom68xC04+Gv7fGj9aw2Ulik5iARqxcq8vJYJjSM2Gh OHdoeAaZbX6116+O4QNOALJWF7biu5Uvr6hdWbc0D8FDzFoHcJz3PwULTGwI6KZTsCCA sd8g== 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::11 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v4si5225896ywh.60.2018.11.28.06.31.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:31:32 -0800 (PST) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Received: from localhost ([::1]:48052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gS0sF-0001qq-IF for patch@linaro.org; Wed, 28 Nov 2018 09:31:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gS0rw-0001ox-FK for grub-devel@gnu.org; Wed, 28 Nov 2018 09:31:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gS0rt-0008MS-9Y for grub-devel@gnu.org; Wed, 28 Nov 2018 09:31:12 -0500 Received: from mx2.suse.de ([195.135.220.15]:41148 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 1gS0rt-0008M2-22 for grub-devel@gnu.org; Wed, 28 Nov 2018 09:31:09 -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 D4108B0E5; Wed, 28 Nov 2018 14:31:07 +0000 (UTC) From: Alexander Graf To: grub-devel@gnu.org Subject: [PATCH 1/2] mkimage: Simplify header size logic Date: Wed, 28 Nov 2018 15:31:06 +0100 Message-Id: <20181128143107.37583-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20181128143107.37583-1-agraf@suse.de> References: <20181128143107.37583-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: Nicolas Dechesne , Jon Masters , leif.lindholm@linaro.org, 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.19.0 _______________________________________________ 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 b2f43fea6..05333a76a 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -1206,10 +1206,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 Wed Nov 28 14:31: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: 152269 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1160451ljp; Wed, 28 Nov 2018 06:31:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/XxDX101aaql7DLQ0lnXPVKd9FrPS0YjKdq0rKOt4trQiN5hdWqbg8rOzIoegwrDrA/r2XU X-Received: by 2002:a81:3c52:: with SMTP id j79mr735296ywa.38.1543415487098; Wed, 28 Nov 2018 06:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543415487; cv=none; d=google.com; s=arc-20160816; b=pJxuPsu4q7YnA6z47uMPK36CJjV1P5yo31qhK4OSZRFx6guAM7+Or/pKkP0e+b4diQ MC12elfK2VA5brp96OeEjQ9sYHEMcpu9WnIQLGTitkY463/OwsRzZ0x6Iqh7ynM1apB7 IQwVQzoybLt8ve+45lPJokrc+10dBSmq5Ryx+ok8c4GOAHt5N4gBRd9Db6ETrYxPu3Qd Cz9b7W0/6qEFccLvT0XAk0taeI1U5V4sIaNwBxTkF79qKPBMQ0wlT+X8kHlEppjd/0Ga rPZ3Qx04F3LGPvNNAmHFIQEBzlilvr45Nx3mD2LbTvYaxLIxYVTSzLKjVT0i8IGuMZ7r 7Mgw== 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=o119h9HV/+wT6gyHYW797ASA5IgFGocfxD+Y6AU3a4w=; b=zAy8878fFkxfvX26C+w+GY1T6VWSmFWOLRKCf/2dVC7/lTNT6BhwCac3rrjVPli44P k6B/OPxaWij85yf0EVE+XfByR6Gak/9S6laqvf4rFh9SjwdEKw1QPHGOZkckuqXIiwra 38zTuTCU+OqxX80/YHeM5WJgcRZQBHoJs4xWCjzSOD9FKWFC0LIIwUwIEbQ/kX2bUxLz OrOKXB70/hJ3rpbD+mHjvMJLB5Pq6MTGUNeIT96fNKtwWtOeTix5PYBiLAlNL+jdoFHO XA+HzlYJC/pVy9kUSnBXu4meVGNhOX6lG0RIXSpOrrw5VlD7cHhVhrkbpGvjzxkV4+wf 3LXw== 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::11 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c3-v6si4798636ybf.196.2018.11.28.06.31.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:31:27 -0800 (PST) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Received: from localhost ([::1]:48051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gS0sA-0001pP-GK for patch@linaro.org; Wed, 28 Nov 2018 09:31:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gS0rw-0001ov-Ey for grub-devel@gnu.org; Wed, 28 Nov 2018 09:31:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gS0rt-0008MR-9a for grub-devel@gnu.org; Wed, 28 Nov 2018 09:31:12 -0500 Received: from mx2.suse.de ([195.135.220.15]:41152 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 1gS0rt-0008M3-25 for grub-devel@gnu.org; Wed, 28 Nov 2018 09:31:09 -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 DCC53B0E7; Wed, 28 Nov 2018 14:31:07 +0000 (UTC) From: Alexander Graf To: grub-devel@gnu.org Subject: [PATCH 2/2] mkimage: arm64-efi: Align first section to page Date: Wed, 28 Nov 2018 15:31:07 +0100 Message-Id: <20181128143107.37583-3-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20181128143107.37583-1-agraf@suse.de> References: <20181128143107.37583-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: Nicolas Dechesne , Jon Masters , leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" I encountered a broken edk2 implementation in the wild (HP Envy x2) which fails to load PE binaries that have a non-page-aligned first section (read: header is < 4k). Work around this by just aligning the text start to page granule on the arm64-efi target. With this patch applied, I can successfully run grub on my HP Envy x2 system. Signed-off-by: Alexander Graf --- util/mkimage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.19.0 _______________________________________________ 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 05333a76a..bfdb0328a 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -605,7 +605,8 @@ 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, + /* Needed for some broken edk2 implementations */ + .vaddr_offset = 4096, .pe_target = GRUB_PE32_MACHINE_ARM64, .elf_target = EM_AARCH64, },