From patchwork Mon Jul 21 15:16:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 33981 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9714620672 for ; Mon, 21 Jul 2014 15:19:37 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id 29sf23931868yhl.2 for ; Mon, 21 Jul 2014 08:19:37 -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=67WReL3Jh3tRSenbotbpjXtrbb23snQdiEOCxOYx1E8=; b=myr4eACdR5JzTs8Xb2ZITa8vegI4hSmmGrAWyIh3nCEfzNvwNdbXEAG41XTEhBNfh/ TwlBX7ZfD+6qCNxJsyG3yQ8D6RJfkxaS7qi4PIBUghVCfTUTY/hKrSpCMfjwjqpl37jM SCPoCXIfwmg2yyqf58djCq6VOWjrscXFa5ScDnFcpYD/1XolokKcl8zqni7ecx3QPuth xQ2HdlmNcsEBWFmv3ZI62pypMDOLBCJ4NBJJLqXYc9Era/p2esV7A0BlfH7LswvxdR4P pdu4xoLUzcYazW1AfpiKLx3Lq5OO5DCvfZBU/J3LfDqs51fuwpfDdjaS2wAHqoOOGwcl Ap8Q== X-Gm-Message-State: ALoCoQnAabyJvsHUUKpN6Prw/iN0R9eGDt0w8N9n6xVP7ZeKY9mnLsSkK2kAqOykHy8BSl6hsqIE X-Received: by 10.236.1.198 with SMTP id 46mr11094037yhd.16.1405955977260; Mon, 21 Jul 2014 08:19:37 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.203 with SMTP id 69ls462458qgl.13.gmail; Mon, 21 Jul 2014 08:19:37 -0700 (PDT) X-Received: by 10.52.227.41 with SMTP id rx9mr2471843vdc.92.1405955977118; Mon, 21 Jul 2014 08:19:37 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id t14si11546485vdi.30.2014.07.21.08.19.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:19:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so12473068vcb.9 for ; Mon, 21 Jul 2014 08:19:36 -0700 (PDT) X-Received: by 10.220.44.141 with SMTP id a13mr2926554vcf.71.1405955976941; Mon, 21 Jul 2014 08:19:36 -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 tc5csp121016vcb; Mon, 21 Jul 2014 08:19:36 -0700 (PDT) X-Received: by 10.70.38.134 with SMTP id g6mr4411052pdk.135.1405955976147; Mon, 21 Jul 2014 08:19:36 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id dt16si7292828pdb.237.2014.07.21.08.19.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jul 2014 08:19:36 -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 1X9FM6-00085V-3T; Mon, 21 Jul 2014 15:18:22 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9FLK-00075G-MB for linux-arm-kernel@lists.infradead.org; Mon, 21 Jul 2014 15:17:35 +0000 Received: by mail-wi0-f177.google.com with SMTP id ho1so4274392wib.10 for ; Mon, 21 Jul 2014 08:17:14 -0700 (PDT) X-Received: by 10.194.92.115 with SMTP id cl19mr24346842wjb.29.1405955834635; Mon, 21 Jul 2014 08:17:14 -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.17.11 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:17:13 -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 06/10] arm64/efi: efistub: avoid using linker defined constants Date: Mon, 21 Jul 2014 17:16:21 +0200 Message-Id: <1405955785-13477-7-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_081734_923251_9BD22BC9 X-CRM114-Status: GOOD ( 12.60 ) 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 [209.85.212.177 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.177 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -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.178 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 When we build the stub as a separate executable, we cannot refer to symbols like _edata or _end to find out how large the kernel is. Use image->image_size instead, this covers the entire static memory footprint including BSS. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi-stub.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index 1317fef8dde9..8401d7795395 100644 --- a/arch/arm64/kernel/efi-stub.c +++ b/arch/arm64/kernel/efi-stub.c @@ -11,7 +11,6 @@ */ #include #include -#include efi_status_t handle_kernel_image(efi_system_table_t *sys_table, unsigned long *image_addr, @@ -22,14 +21,12 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table, efi_loaded_image_t *image) { efi_status_t status; - unsigned long kernel_size, kernel_memsize = 0; /* Relocate the image, if required. */ - kernel_size = _edata - _text; if (*image_addr != (dram_base + TEXT_OFFSET)) { - kernel_memsize = kernel_size + (_end - _edata); status = efi_relocate_kernel(sys_table, image_addr, - kernel_size, kernel_memsize, + image->image_size, + image->image_size, dram_base + TEXT_OFFSET, PAGE_SIZE); if (status != EFI_SUCCESS) { @@ -38,10 +35,10 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table, } if (*image_addr != (dram_base + TEXT_OFFSET)) { pr_efi_err(sys_table, "Failed to alloc kernel memory\n"); - efi_free(sys_table, kernel_memsize, *image_addr); + efi_free(sys_table, image->image_size, *image_addr); return EFI_LOAD_ERROR; } - *image_size = kernel_memsize; + *image_size = image->image_size; }