From patchwork Fri Oct 10 16:58:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 38626 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D59DC202DB for ; Fri, 10 Oct 2014 17:01:24 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id y10sf2333347wgg.6 for ; Fri, 10 Oct 2014 10:01:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=NDKmhQNm3BRd5aZhEwpsNTcarXA3e6kw+JngtJb/2K8=; b=c7m78+JTZ49YBGMszSR3p5BNwTwdCAMJ+2Bc9NqmMGnL96ZGJG+8N5e7HKkckCHLOG fM9DAaK91DpFDlwU6qNpIsBMuwdpk3zn7URTjiBVNi6h5agzjdacAJVG5XZRpdN3HGNa uIl9tFXjOOrWJXMQzKT/gYkZEtVujVOXxgMhjPQMZd+Z75qahdOrZXJurbpokkZF1olJ klBxBmTlVa0f93kUTg5bVXW63vXaRyK/9KPyWeggFigrki6zOgy0Tpi+q/EE2lAqNGGR UY9nSTYcPLbbge8pfnuEoUsdqSmRhJPe5CSQrAQfR7GyhYwxxtdQtDfmEW65tOo8y6GU UVUw== X-Gm-Message-State: ALoCoQkvUSLwFaOCNvSp4o9ArURZ5H9RZmGM8InYvn3R9kX+ZU///hVoEFpVgoIEVRz61ZpDUvce X-Received: by 10.112.190.40 with SMTP id gn8mr957890lbc.10.1412960483924; Fri, 10 Oct 2014 10:01:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.169 with SMTP id ld9ls308180lab.12.gmail; Fri, 10 Oct 2014 10:01:23 -0700 (PDT) X-Received: by 10.152.170.194 with SMTP id ao2mr6224576lac.78.1412960483531; Fri, 10 Oct 2014 10:01:23 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by mx.google.com with ESMTPS id b6si10083282lae.131.2014.10.10.10.01.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Oct 2014 10:01:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id z12so3487403lbi.30 for ; Fri, 10 Oct 2014 10:01:23 -0700 (PDT) X-Received: by 10.152.28.167 with SMTP id c7mr6174812lah.27.1412960483448; Fri, 10 Oct 2014 10:01:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp464907lbz; Fri, 10 Oct 2014 10:01:22 -0700 (PDT) X-Received: by 10.70.94.104 with SMTP id db8mr6698825pdb.124.1412960481733; Fri, 10 Oct 2014 10:01:21 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id y3si4237492pdf.115.2014.10.10.10.01.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Oct 2014 10:01:21 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcdXH-0004R8-1J; Fri, 10 Oct 2014 16:59:23 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcdXD-0004Lr-Ub for linux-arm-kernel@lists.infradead.org; Fri, 10 Oct 2014 16:59:20 +0000 Received: by mail-wi0-f177.google.com with SMTP id fb4so2653908wid.16 for ; Fri, 10 Oct 2014 09:58:56 -0700 (PDT) X-Received: by 10.181.9.73 with SMTP id dq9mr6215015wid.40.1412960336375; Fri, 10 Oct 2014 09:58:56 -0700 (PDT) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id d6sm3243283wiz.0.2014.10.10.09.58.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Oct 2014 09:58:55 -0700 (PDT) From: Ard Biesheuvel To: leif.lindholm@linaro.org, roy.franz@linaro.org, will.deacon@arm.com, mark.rutland@arm.com, matt.fleming@intel.com, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, msalter@redhat.com Subject: [PATCH] arm64/efi: set PE/COFF file alignment to 512 bytes Date: Fri, 10 Oct 2014 18:58:55 +0200 Message-Id: <1412960335-22905-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141010_095920_135288_B7B9D757 X-CRM114-Status: GOOD ( 12.79 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.177 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.177 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Change our PE/COFF header to use the minimum file alignment of 512 bytes (0x200), as mandated by the PE/COFF spec v8.3 Also update the linker script so that the Image file itself is also a round multiple of FileAlignment. Signed-off-by: Ard Biesheuvel Signed-off-by: Roy Franz Acked-by: Catalin Marinas Acked-by: Roy Franz --- Another one from the PE/COFF rabbit hole. I will follow up next week and repost as a coherent series, once I have collected all the feedback. arch/arm64/kernel/head.S | 2 +- arch/arm64/kernel/vmlinux.lds.S | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index ba715ce3f7f1..e7e83b3128fd 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -162,7 +162,7 @@ optional_header: extra_header_fields: .quad 0 // ImageBase .long 0x1000 // SectionAlignment - .long 0x8 // FileAlignment + .long PECOFF_FILE_ALIGNMENT // FileAlignment .short 0 // MajorOperatingSystemVersion .short 0 // MinorOperatingSystemVersion .short 0 // MajorImageVersion diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index edf8715ba39b..4596f46d0244 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -32,6 +32,22 @@ jiffies = jiffies_64; *(.hyp.text) \ VMLINUX_SYMBOL(__hyp_text_end) = .; +/* + * The size of the PE/COFF section that covers the kernel image, which + * runs from stext to _edata, must be a round multiple of the PE/COFF + * FileAlignment, which we set to its minimum value of 0x200. 'stext' + * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned + * boundary should be sufficient. + */ +PECOFF_FILE_ALIGNMENT = 0x200; + +#ifdef CONFIG_EFI +#define PECOFF_EDATA_PADDING \ + .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); } +#else +#define PECOFF_EDATA_PADDING +#endif + SECTIONS { /* @@ -103,6 +119,7 @@ SECTIONS _data = .; _sdata = .; RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE) + PECOFF_EDATA_PADDING _edata = .; BSS_SECTION(0, 0, 0)