From patchwork Tue Jul 29 10:49:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 34464 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f69.google.com (mail-qg0-f69.google.com [209.85.192.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3DF51202E4 for ; Tue, 29 Jul 2014 10:51:27 +0000 (UTC) Received: by mail-qg0-f69.google.com with SMTP id a108sf18589175qge.8 for ; Tue, 29 Jul 2014 03:51:26 -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=fp2NspD6wqJm7uGn45E8C3mnAnXG48MPR0qt5s7eKXY=; b=NdedGY+4eQYfzE5msUL3pACExr7xYcGi8eOad3Q8sd3nfL94/44m0x5HBmcSzAUjgF cACP4WAhcUhCtaT0es0orGm9Gq9xbQEKU+Yl9kO37g8IAppHclm6vNGCnbb2iuubhT5E 6y/3wMblTX0Rr73HkTAPv70foqj0DXn1RH9rYWlknpNIhTZQUIJXx6WskC4Pak9iFRyu xV9bIwqYHDDKvVPyS5ZIkMCnyYFXVu9y1xObqD+X6F2HQwvHz0ytt6dgPLF80Hhf3lX9 eE80iZS+fQzTgYYI3nN8gARDaJ9Jr4VcXXuX/gdGH1NcUTU6aESabS6DkXSgRrtQlI05 DCVA== X-Gm-Message-State: ALoCoQlgWZRnZOLzTt5b09LECU/Ak0se/H0S+GfysdFxt9rBqPm2yTT6VmEG6P74/67XVgOSoJBy X-Received: by 10.236.122.236 with SMTP id t72mr350195yhh.15.1406631086877; Tue, 29 Jul 2014 03:51:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.239 with SMTP id l102ls57987qgd.81.gmail; Tue, 29 Jul 2014 03:51:26 -0700 (PDT) X-Received: by 10.53.5.163 with SMTP id cn3mr682537vdd.3.1406631086776; Tue, 29 Jul 2014 03:51:26 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id xt7si14295220veb.104.2014.07.29.03.51.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Jul 2014 03:51:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id id10so13149130vcb.35 for ; Tue, 29 Jul 2014 03:51:26 -0700 (PDT) X-Received: by 10.52.244.81 with SMTP id xe17mr723743vdc.24.1406631086692; Tue, 29 Jul 2014 03:51:26 -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 tc5csp235060vcb; Tue, 29 Jul 2014 03:51:25 -0700 (PDT) X-Received: by 10.70.102.130 with SMTP id fo2mr1245141pdb.68.1406631081287; Tue, 29 Jul 2014 03:51:21 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id br11si20772760pac.10.2014.07.29.03.51.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jul 2014 03:51:21 -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 1XC4yu-00056p-OM; Tue, 29 Jul 2014 10:50:08 +0000 Received: from mail-wg0-f43.google.com ([74.125.82.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XC4yc-00040R-F1 for linux-arm-kernel@lists.infradead.org; Tue, 29 Jul 2014 10:49:51 +0000 Received: by mail-wg0-f43.google.com with SMTP id l18so8479214wgh.14 for ; Tue, 29 Jul 2014 03:49:23 -0700 (PDT) X-Received: by 10.180.104.42 with SMTP id gb10mr39640329wib.65.1406630963735; Tue, 29 Jul 2014 03:49:23 -0700 (PDT) Received: from ards-macbook-pro.local (adsl59mo2.tel.net.ba. [95.156.191.2]) by mx.google.com with ESMTPSA id k6sm13852902wjq.5.2014.07.29.03.49.22 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Jul 2014 03:49:23 -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 Subject: [PATCH 2/3] arm64/efi: efistub: cover entire static mem footprint in PE/COFF .text Date: Tue, 29 Jul 2014 12:49:09 +0200 Message-Id: <1406630950-32432-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1406630950-32432-1-git-send-email-ard.biesheuvel@linaro.org> References: <1406630950-32432-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140729_034950_648984_09BF1D38 X-CRM114-Status: GOOD ( 11.64 ) 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.43 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.43 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel , matt.fleming@intel.com, 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.176 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 --- 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 69dafe9621fd..dafc4f2c1ade 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -148,7 +148,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 @@ -166,7 +166,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 @@ -213,7 +213,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