From patchwork Tue Oct 28 16:18:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 39679 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BB14F24026 for ; Tue, 28 Oct 2014 16:21:57 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gq15sf664783lab.10 for ; Tue, 28 Oct 2014 09:21:56 -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 :in-reply-to:references: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=xk+2PV2Kxp7t/HJ3iQPogbvRCCXzDbA8JL5+F6X9YuE=; b=lkSawpcggfyNXqgs0YAviRQL97XZ7ti4wwRHn9KLBKotegfFOBBgEMX35lgWuHZUk8 SV7Uw9c08u+2YnWY2ZQCnHa6HAJwJl1bHRdRPP1WPhfSiDNKOC3YaR9UZEvBYl5sQmDP 1K0XExn9KaI/7B5mN6kwtWbfLx9LYr0MkQPdbDkAk++XISIPDtn2rHHms/1ms1pK9Rm0 MVdr1CyfHDKHyuk9HUnKZi4Hsw7ZMyqiGH3dTexUDQ+HGbxmzPg36e/2hA1Ezvk2fZ5w dNMTLyp52d1eRrFqCaesJg0nAowQp6fa0Ywe+9AhmXbIYnTF4CdHac3IiOIPwCem60sS Sjdg== X-Gm-Message-State: ALoCoQkswPOcw+x+1nHFRrUWVeRnflC6csXl0XtzpvPgY96U63rVgPzOmQiZ9w9c1TSOPmld749q X-Received: by 10.181.11.130 with SMTP id ei2mr921709wid.3.1414513316538; Tue, 28 Oct 2014 09:21:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.130 with SMTP id z2ls87486laa.61.gmail; Tue, 28 Oct 2014 09:21:56 -0700 (PDT) X-Received: by 10.152.5.38 with SMTP id p6mr5141391lap.44.1414513316371; Tue, 28 Oct 2014 09:21:56 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id y8si3238260lag.85.2014.10.28.09.21.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Oct 2014 09:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id f15so1034142lbj.9 for ; Tue, 28 Oct 2014 09:21:56 -0700 (PDT) X-Received: by 10.152.29.8 with SMTP id f8mr5198857lah.56.1414513316111; Tue, 28 Oct 2014 09:21:56 -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 c5csp510507lbz; Tue, 28 Oct 2014 09:21:55 -0700 (PDT) X-Received: by 10.68.130.134 with SMTP id oe6mr4462502pbb.3.1414513313874; Tue, 28 Oct 2014 09:21:53 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 1si1772594pdr.58.2014.10.28.09.21.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Oct 2014 09:21:53 -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 1Xj9VT-0005mv-5i; Tue, 28 Oct 2014 16:20:27 +0000 Received: from mail-wi0-f175.google.com ([209.85.212.175]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xj9UK-0003yv-CS for linux-arm-kernel@lists.infradead.org; Tue, 28 Oct 2014 16:19:17 +0000 Received: by mail-wi0-f175.google.com with SMTP id h11so7852008wiw.14 for ; Tue, 28 Oct 2014 09:18:53 -0700 (PDT) X-Received: by 10.194.92.82 with SMTP id ck18mr5418024wjb.103.1414513133125; Tue, 28 Oct 2014 09:18:53 -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 wc7sm2357578wjc.8.2014.10.28.09.18.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Oct 2014 09:18:51 -0700 (PDT) From: Ard Biesheuvel To: leif.lindholm@linaro.org, roy.franz@linaro.org, msalter@redhat.com, mark.rutland@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, matt.fleming@intel.com, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dyoung@redhat.com, yi.li@linaro.org Subject: [PATCH v2 02/10] arm64/efi: set PE/COFF section alignment to 4 KB Date: Tue, 28 Oct 2014 17:18:35 +0100 Message-Id: <1414513123-20400-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1414513123-20400-1-git-send-email-ard.biesheuvel@linaro.org> References: <1414513123-20400-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141028_091916_622113_92BEE434 X-CRM114-Status: GOOD ( 13.23 ) 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.175 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.175 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.178 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 Position independent AArch64 code needs to be linked and loaded at the same relative offset from a 4 KB boundary, or adrp/add and adrp/ldr pairs will not work correctly. (This is how PC relative symbol references with a 4 GB reach are emitted) We need to declare this in the PE/COFF header, otherwise the PE/COFF loader may load the Image and invoke the stub at an offset which violates this rule. Reviewed-by: Roy Franz Acked-by: Mark Rutland Signed-off-by: Ard Biesheuvel --- v2: added comment explaining '.align 12' in head.S --- arch/arm64/kernel/head.S | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 8c06c9d269d2..8ae84d8c2a8c 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -161,7 +161,7 @@ optional_header: extra_header_fields: .quad 0 // ImageBase - .long 0x20 // SectionAlignment + .long 0x1000 // SectionAlignment .long 0x8 // FileAlignment .short 0 // MajorOperatingSystemVersion .short 0 // MinorOperatingSystemVersion @@ -228,7 +228,15 @@ section_table: .short 0 // NumberOfRelocations (0 for executables) .short 0 // NumberOfLineNumbers (0 for executables) .long 0xe0500020 // Characteristics (section flags) - .align 5 + + /* + * EFI will load stext onwards at the 4k section alignment + * described in the PE/COFF header. To ensure that instruction + * sequences using an adrp and a :lo12: immediate will function + * correctly at this alignment, we must ensure that stext is + * placed at a 4k boundary in the Image to begin with. + */ + .align 12 #endif ENTRY(stext)