From patchwork Wed Jul 30 10:59:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 34509 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0CF1820DCC for ; Wed, 30 Jul 2014 11:01:20 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id s18sf671430lam.4 for ; Wed, 30 Jul 2014 04:01:19 -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=6R0GlDfGIMaOJPpFrs0PjQqoeGHlpfOnx407vrHUxE8=; b=QNtNG9rQSt2pYoHgJEexf8PdU0/ZqGgCvGDXHbgDPVCXvyOBYja/QquSmTwZXO0jIq M36JigS2Z5/TzsgV0Ng4tKBp6kqdrgDkQ16mrQeR+GgHFqqQKY0lS5dALjMW4MmFTr2+ kBb7tCdRGvqHgThh9olrELL07cWXDzHS1IMcrnuaaUHBQ3J9Joi7+TlCO5/1VS0SuIEE RUqcOc0+emt2M35UvlJXBJ8pwpWfBHb25cqRC6VW9WDxfd0mLADI//cbUbev1yXRvNiU hMWjnrR57sdpA2CXHMWY7SYYqq+/NWx+xYOC9nAofrfFs9MQKQg9G4MTgoCSk5pcZOVK YvzQ== X-Gm-Message-State: ALoCoQmJM7eAX1XQb0KABGLhcR3BCq/zNXA3PrSjv3q2IPqbgYVrYhg65MCvZ+nrjtYvtNzn3Y4i X-Received: by 10.180.91.73 with SMTP id cc9mr422276wib.4.1406718078988; Wed, 30 Jul 2014 04:01:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.21 with SMTP id 21ls462630qgs.58.gmail; Wed, 30 Jul 2014 04:01:18 -0700 (PDT) X-Received: by 10.220.166.207 with SMTP id n15mr36843vcy.75.1406718078461; Wed, 30 Jul 2014 04:01:18 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id cz8si1241753vcb.88.2014.07.30.04.01.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jul 2014 04:01:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id le20so1452726vcb.28 for ; Wed, 30 Jul 2014 04:01:18 -0700 (PDT) X-Received: by 10.220.82.202 with SMTP id c10mr3084460vcl.31.1406718078372; Wed, 30 Jul 2014 04:01:18 -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 tc5csp18015vcb; Wed, 30 Jul 2014 04:01:17 -0700 (PDT) X-Received: by 10.66.150.169 with SMTP id uj9mr2899900pab.148.1406718076847; Wed, 30 Jul 2014 04:01:16 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id zb4si1988017pbc.164.2014.07.30.04.01.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 04:01:16 -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 1XCRbx-0005Ap-25; Wed, 30 Jul 2014 10:59:57 +0000 Received: from mail-wg0-f47.google.com ([74.125.82.47]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XCRbh-00054a-8V for linux-arm-kernel@lists.infradead.org; Wed, 30 Jul 2014 10:59:42 +0000 Received: by mail-wg0-f47.google.com with SMTP id b13so992300wgh.6 for ; Wed, 30 Jul 2014 03:59:19 -0700 (PDT) X-Received: by 10.180.39.34 with SMTP id m2mr5767064wik.80.1406717959150; Wed, 30 Jul 2014 03:59:19 -0700 (PDT) Received: from ards-macbook-pro.local (adsl26mo10.tel.net.ba. [95.156.174.10]) by mx.google.com with ESMTPSA id wu6sm4660963wjb.46.2014.07.30.03.59.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jul 2014 03:59:18 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, leif.lindholm@linaro.org, msalter@redhat.com, will.deacon@arm.com Subject: [PATCH v2 2/3] arm64/efi: efistub: cover entire static mem footprint in PE/COFF .text Date: Wed, 30 Jul 2014 12:59:03 +0200 Message-Id: <1406717944-24725-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1406717944-24725-1-git-send-email-ard.biesheuvel@linaro.org> References: <1406717944-24725-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140730_035941_476172_C24DB96C X-CRM114-Status: GOOD ( 11.90 ) 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.47 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.47 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: matt.fleming@intel.com, 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.220.169 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 (or GRUB) 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 PE/COFF 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 PE/COFF loader. Signed-off-by: Ard Biesheuvel Acked-by: Mark Salter Acked-by: Mark Rutland --- 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 144f10567f82..b6ca95aee348 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -151,7 +151,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 @@ -169,7 +169,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 - efi_head // SizeOfHeaders @@ -216,7 +216,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 - efi_head // VirtualAddress .long _edata - stext // SizeOfRawData .long stext - efi_head // PointerToRawData