From patchwork Mon Jul 21 15:16:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 33978 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7392720672 for ; Mon, 21 Jul 2014 15:19:01 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id ft15sf51045968pdb.10 for ; Mon, 21 Jul 2014 08:18:58 -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=etwsh8jNZnWiRuSZcBfMrg6L5Kntww6FJF2OuuFkCbw=; b=h7jU69L3CF+NuzztYRHB/ivSAZ0Je+nyywuTZy53WLKpRuobe/jY0rdmt/wXMAyjXK 9AWZI/gLAxF3qKtKVaLuACNrmiZA3f9gWlFj9I9z9C6QnHW/yitRDK6QFZcI1+UPxhif 4B9zYpe/ltc1dyaDR19Tv5xdDkO8ZbPAAIiMY4ZsnkVrW3w5agFC7dWkFbnaRf/nVycq jtqDgTzzGO5MmrQwll/FJptU4SEZNGPsk0PsEBTOHoXkVRbq2UTT+Tp4ELQ7Wqql41er cRL5BbODF7O/lg6UnQf/BxxOrISaYuOWEzF58TGWlomR6FLpsW+ffU8/Rh6FuPLHV4eO GJ0A== X-Gm-Message-State: ALoCoQl4zoZHlUbiQoUMCZtTdguy+aGuGF6a5UJEvDB0yhreo0HhvqfJlddXXpEJkbxkUiyWxzXA X-Received: by 10.66.182.130 with SMTP id ee2mr13362247pac.37.1405955938880; Mon, 21 Jul 2014 08:18:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.68 with SMTP id h62ls2064284qge.52.gmail; Mon, 21 Jul 2014 08:18:58 -0700 (PDT) X-Received: by 10.220.167.2 with SMTP id o2mr30415121vcy.8.1405955938699; Mon, 21 Jul 2014 08:18:58 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id xj9si11552078veb.92.2014.07.21.08.18.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so10867335vcb.16 for ; Mon, 21 Jul 2014 08:18:58 -0700 (PDT) X-Received: by 10.52.120.38 with SMTP id kz6mr2510565vdb.86.1405955938620; Mon, 21 Jul 2014 08:18:58 -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.221.37.5 with SMTP id tc5csp120973vcb; Mon, 21 Jul 2014 08:18:58 -0700 (PDT) X-Received: by 10.68.162.34 with SMTP id xx2mr10104985pbb.120.1405955937517; Mon, 21 Jul 2014 08:18:57 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id py9si10770066pac.70.2014.07.21.08.18.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jul 2014 08:18:57 -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 1X9FLU-0007WJ-VX; Mon, 21 Jul 2014 15:17:44 +0000 Received: from mail-wg0-f46.google.com ([74.125.82.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9FKs-0006a5-Vr for linux-arm-kernel@lists.infradead.org; Mon, 21 Jul 2014 15:17:07 +0000 Received: by mail-wg0-f46.google.com with SMTP id m15so6492017wgh.17 for ; Mon, 21 Jul 2014 08:16:43 -0700 (PDT) X-Received: by 10.180.208.13 with SMTP id ma13mr5274798wic.45.1405955803331; Mon, 21 Jul 2014 08:16:43 -0700 (PDT) Received: from ards-macbook-pro.local ([212.91.105.246]) by mx.google.com with ESMTPSA id ft17sm38327602wjc.14.2014.07.21.08.16.38 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:16:42 -0700 (PDT) From: Ard Biesheuvel To: matt.fleming@intel.com, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, leif.lindholm@linaro.org Subject: [RFC PATCH 02/10] arm64/efi: efistub: cover entire static mem footprint in PE/COFF .text Date: Mon, 21 Jul 2014 17:16:17 +0200 Message-Id: <1405955785-13477-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1405955785-13477-1-git-send-email-ard.biesheuvel@linaro.org> References: <1405955785-13477-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140721_081707_181345_C7AAECFC X-CRM114-Status: GOOD ( 12.37 ) 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.46 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.46 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: roy.franz@linaro.org, victor.kamensky@linaro.org, steve.capper@linaro.org, Ard Biesheuvel , msalter@redhat.com 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.220.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 The static memory footprint of a kernel Image at boot is larger than the Image file itself. Things like .bss data and initial page tables are allocated statically but populated dynamically so their content is not contained in the Image file. However, if EFI has loaded the Image at precisely the desired offset of base of DRAM + TEXT_OFFSET, the Image will be booted in place, and we have to make sure that the allocation done by the EFI loader is large enough. Fix this by growing the PE/COFF .text section to cover the entire static memory footprint. The part of the section that is not covered by the payload will be zero initialised by the EFI loader. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 5cd1f3491df5..c63f44f20ae3 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -150,7 +150,7 @@ optional_header: .short 0x20b // PE32+ format .byte 0x02 // MajorLinkerVersion .byte 0x14 // MinorLinkerVersion - .long _edata - stext // SizeOfCode + .long _end - stext // SizeOfCode .long 0 // SizeOfInitializedData .long 0 // SizeOfUninitializedData .long efi_stub_entry - efi_head // AddressOfEntryPoint @@ -168,7 +168,7 @@ extra_header_fields: .short 0 // MinorSubsystemVersion .long 0 // Win32VersionValue - .long _edata - efi_head // SizeOfImage + .long _end - efi_head // SizeOfImage // Everything before the kernel image is considered part of the header .long stext_offset // SizeOfHeaders @@ -215,7 +215,7 @@ section_table: .byte 0 .byte 0 .byte 0 // end of 0 padding of section name - .long _edata - stext // VirtualSize + .long _end - stext // VirtualSize .long stext_offset // VirtualAddress .long _edata - stext // SizeOfRawData .long stext_offset // PointerToRawData