From patchwork Wed Oct 22 14:21:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 39310 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 49475202DB for ; Wed, 22 Oct 2014 14:24:44 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id ge10sf2120411lab.9 for ; Wed, 22 Oct 2014 07:24:43 -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=JQGXia97ogsQKB5UdlY8sqBFF/GBtgK9mbm3SgSoNUo=; b=B+cn/WwTGfoGidUFMOinedAeSLZWnSkFL7YiaEfpVKTrVdOMiB5DMEr/tHyq6FnZgo shNQdu0YYfMaRxcEjk8ZBKE01WLVDMKJLPANAA+6NI+u/Qj5edYONWZcYt07qKFkk/Iu 9l+d+twNZTzNDTnZNpBTLQG0z6Ex6j76tQiwE3TMNWcLfYGwoJqNSioHswq6uU04zCbi A1xQlmTg0F485nLIQ19fYJgvMQgi+mxI8suzO8B5qFq+Mzh27mBWJufbQ4EJMbg8EzaW hyV2rNBsZ1D99q7yMf2Q7ETHSngTH7RqzQZKgE0guMPpb8192FF9RM8slVBXthn5WEcg Dx5Q== X-Gm-Message-State: ALoCoQlb8QXoVBsrfTBWBwG1HSL4o8q855lAnQbL/QxuPKdqqi6DtbDRaR8LhjJhPE26fJcbO+ki X-Received: by 10.112.247.74 with SMTP id yc10mr74148lbc.8.1413987883115; Wed, 22 Oct 2014 07:24:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.194 with SMTP id t2ls194140laa.14.gmail; Wed, 22 Oct 2014 07:24:42 -0700 (PDT) X-Received: by 10.112.73.37 with SMTP id i5mr6418046lbv.83.1413987882936; Wed, 22 Oct 2014 07:24:42 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id jl10si23507815lbc.96.2014.10.22.07.24.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 07:24:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id mc6so3053539lab.2 for ; Wed, 22 Oct 2014 07:24:42 -0700 (PDT) X-Received: by 10.112.130.41 with SMTP id ob9mr41248620lbb.74.1413987882745; Wed, 22 Oct 2014 07:24:42 -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 c5csp82237lbz; Wed, 22 Oct 2014 07:24:42 -0700 (PDT) X-Received: by 10.70.43.1 with SMTP id s1mr5574487pdl.56.1413987881236; Wed, 22 Oct 2014 07:24:41 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id gx1si14382063pbd.62.2014.10.22.07.24.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Oct 2014 07:24:41 -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 1Xgwod-0000NC-G8; Wed, 22 Oct 2014 14:23:07 +0000 Received: from mail-wg0-f45.google.com ([74.125.82.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XgwoB-00007E-3a for linux-arm-kernel@lists.infradead.org; Wed, 22 Oct 2014 14:22:40 +0000 Received: by mail-wg0-f45.google.com with SMTP id m15so3856202wgh.28 for ; Wed, 22 Oct 2014 07:22:17 -0700 (PDT) X-Received: by 10.194.81.6 with SMTP id v6mr50937970wjx.39.1413987736980; Wed, 22 Oct 2014 07:22:16 -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 10sm19063250wjs.21.2014.10.22.07.22.15 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 07:22:16 -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 02/10] arm64/efi: set PE/COFF section alignment to 4 KB Date: Wed, 22 Oct 2014 16:21:45 +0200 Message-Id: <1413987713-30528-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1413987713-30528-1-git-send-email-ard.biesheuvel@linaro.org> References: <1413987713-30528-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141022_072239_352060_CBE5A9EC X-CRM114-Status: GOOD ( 13.07 ) 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 [74.125.82.45 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.45 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.215.43 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 Signed-off-by: Ard Biesheuvel Acked-by: Mark Rutland --- 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)