From patchwork Tue Jul 15 10:58:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 33652 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A5299201F1 for ; Tue, 15 Jul 2014 11:00:11 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp18sf29991214obc.9 for ; Tue, 15 Jul 2014 04:00:09 -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=UNlf2UYCZWUcriDR+ulEXUHvg3OasZqwGAmh4fNVoi0=; b=AzEGrd3UbhtkGzwfkZPjAWC/Dj0hipCsICgnNKmyG1UO5HGX2X6vtmFwbAM+0IgzMr libSvFbZ2KKbHiM16zzpbOusyNMxrIblmYl/btvrXcYyzQY/ljaw1DLspwDqS8A0fXTJ eVYw35s2BaZ3Z63ItQjzuUXsQKOTcJIL4od0YlhENmV8PGs1TSljuludy+8lDCpBa5iD qHFUA/+G0hs9D4pC69UxzDzRkSI0ZikSJBvJnVz9vYWGiZQY9/1FH6u8MvyJhMnCUTwN Lwo30/KRkYB6pSigWhnjazyi3mNF1VLI4RWau5S+PP7yfcNgzpERvC3hwx5j9hjaWpgG gg7A== X-Gm-Message-State: ALoCoQmSveVdkagwUTA//IwqrxbG95W/G9k0DdCkv+PFzEeu0JikJTkHmuWdkswFI424beeYlhwl X-Received: by 10.50.78.69 with SMTP id z5mr1758224igw.2.1405422009458; Tue, 15 Jul 2014 04:00:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.198 with SMTP id h64ls52616qgf.66.gmail; Tue, 15 Jul 2014 04:00:09 -0700 (PDT) X-Received: by 10.220.202.69 with SMTP id fd5mr181583vcb.43.1405422009373; Tue, 15 Jul 2014 04:00:09 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id x5si6527317vei.12.2014.07.15.04.00.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 04:00:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so5917015vcb.15 for ; Tue, 15 Jul 2014 04:00:09 -0700 (PDT) X-Received: by 10.52.154.106 with SMTP id vn10mr5007014vdb.36.1405422009228; Tue, 15 Jul 2014 04:00:09 -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 tc5csp204892vcb; Tue, 15 Jul 2014 04:00:08 -0700 (PDT) X-Received: by 10.66.149.102 with SMTP id tz6mr22150417pab.76.1405422007126; Tue, 15 Jul 2014 04:00:07 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id c4si4363pdk.183.2014.07.15.04.00.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jul 2014 04:00:07 -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 1X70Rf-0006sY-O7; Tue, 15 Jul 2014 10:58:51 +0000 Received: from mail-wg0-f44.google.com ([74.125.82.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X70Rd-0006lw-UX for linux-arm-kernel@lists.infradead.org; Tue, 15 Jul 2014 10:58:50 +0000 Received: by mail-wg0-f44.google.com with SMTP id m15so5384342wgh.15 for ; Tue, 15 Jul 2014 03:58:27 -0700 (PDT) X-Received: by 10.180.19.138 with SMTP id f10mr4852116wie.38.1405421907913; Tue, 15 Jul 2014 03:58:27 -0700 (PDT) Received: from ards-macbook-pro.local ([77.237.116.228]) by mx.google.com with ESMTPSA id ek3sm31854915wjd.17.2014.07.15.03.58.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 03:58:27 -0700 (PDT) From: Ard Biesheuvel To: matt.fleming@intel.com, mark.rutland@arm.com Subject: [PATCH] arm64/efi: efistub: cover entire static mem footprint in PE/COFF .text Date: Tue, 15 Jul 2014 12:58:20 +0200 Message-Id: <1405421900-11733-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-20140715_035850_142214_78741B8B X-CRM114-Status: GOOD ( 11.50 ) 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.44 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.44 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: linux-efi@vger.kernel.org, Ard Biesheuvel , catalin.marinas@arm.com, leif.lindholm@linaro.org, roy.franz@linaro.org, msalter@redhat.com, linux-arm-kernel@lists.infradead.org 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.170 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 78ddae28b090..bbf2489939c2 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -158,7 +158,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 @@ -176,7 +176,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 @@ -223,7 +223,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