From patchwork Mon Jul 14 15:25: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: 33610 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 36AD82061E for ; Mon, 14 Jul 2014 15:27:31 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id s7sf9259706qap.10 for ; Mon, 14 Jul 2014 08:27:31 -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=oV0yv/33EUrpgtLBS7EbOi2yUiehXuAPyVNsTyRhKAs=; b=dO7juDrbaGKZA0ECPW7xIRJazTo1s6QHmnz6RYUs30sLhUAfHf3sT9OhbXjn/XsS/6 kWA4DjkrlXmhve4I7Mp5ASSmuFRieUPAkSpwnblG4MW8K0FJxYNz/O9NK/Mlv2dBD3LC HbJZWBfG72/EAolj5NX4eVmlre9nraYx7QQFeb1K/hkvetQfsr+K6ORl0knzIiecado3 1/h8DHnkvBZDvwt3fp/Zaf6xFjQeM2xSPcHwBlphZSgRtpcy7dhenFNDEJiAX6iD4A86 21qi31qsy7bWIaEK9Vh/fTdB3wpHquLIhnyp2V76IPx1xPXbCJcuiE6DtGRtkI1seIpS PC7g== X-Gm-Message-State: ALoCoQlY+ooH7UAwcPQJxjFFcUiLZkzgKqTY9VmL03D0D4ySfSp/m/JvW4UKtlcARkYLgeEzP8SH X-Received: by 10.58.41.99 with SMTP id e3mr7741616vel.20.1405351651848; Mon, 14 Jul 2014 08:27:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.11 with SMTP id n11ls1090926qge.11.gmail; Mon, 14 Jul 2014 08:27:31 -0700 (PDT) X-Received: by 10.52.186.103 with SMTP id fj7mr705212vdc.53.1405351651770; Mon, 14 Jul 2014 08:27:31 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id p7si5468360vda.40.2014.07.14.08.27.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 08:27:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hq11so6368400vcb.17 for ; Mon, 14 Jul 2014 08:27:31 -0700 (PDT) X-Received: by 10.220.187.134 with SMTP id cw6mr16545998vcb.3.1405351651672; Mon, 14 Jul 2014 08:27:31 -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 tc5csp143405vcb; Mon, 14 Jul 2014 08:27:31 -0700 (PDT) X-Received: by 10.70.43.170 with SMTP id x10mr12124398pdl.9.1405351650932; Mon, 14 Jul 2014 08:27:30 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id kr6si9442872pab.60.2014.07.14.08.27.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jul 2014 08:27:30 -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 1X6i8Z-0002sb-GX; Mon, 14 Jul 2014 15:25:55 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X6i8X-0002rC-Fe for linux-arm-kernel@lists.infradead.org; Mon, 14 Jul 2014 15:25:54 +0000 Received: by mail-wi0-f169.google.com with SMTP id n3so2657907wiv.0 for ; Mon, 14 Jul 2014 08:25:29 -0700 (PDT) X-Received: by 10.180.91.6 with SMTP id ca6mr25228398wib.77.1405351529394; Mon, 14 Jul 2014 08:25:29 -0700 (PDT) Received: from ards-macbook-pro.local ([109.227.8.83]) by mx.google.com with ESMTPSA id dn3sm32269004wib.12.2014.07.14.08.25.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 08:25:28 -0700 (PDT) From: Ard Biesheuvel To: matt.fleming@intel.com Subject: [PATCH] efi/arm64: efistub: don't abort if base of DRAM is occupied Date: Mon, 14 Jul 2014 17:25:21 +0200 Message-Id: <1405351521-12010-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-20140714_082553_671734_B28931EB X-CRM114-Status: GOOD ( 13.20 ) 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.169 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.169 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.172 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 If we fail to relocate the kernel Image to its preferred offset of TEXT_OFFSET bytes above the base of DRAM, accept the lowest alternative mapping available instead of aborting. We may lose a bit of memory at the low end, but we can still proceed normally otherwise. Signed-off-by: Ard Biesheuvel --- This is a proposed bug fix for arm64 platforms that fail to boot through EFI due to the fact that some bits of EFI itself are occupying the low end of DRAM. Note that this code now triggers an 'unused function' warning for efi_relocate_kernel(), as that is no longer used. This warning will disappear automatically once the already queued up EFISTUB refactoring patches will get merged for 3.17. arch/arm64/kernel/efi-stub.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index 60e98a639ac5..5165b3accefe 100644 --- a/arch/arm64/kernel/efi-stub.c +++ b/arch/arm64/kernel/efi-stub.c @@ -60,20 +60,16 @@ static efi_status_t handle_kernel_image(efi_system_table_t *sys_table, 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, - dram_base + TEXT_OFFSET, - PAGE_SIZE); + status = efi_low_alloc(sys_table, kernel_memsize + TEXT_OFFSET, + SZ_2M, reserve_addr); if (status != EFI_SUCCESS) { pr_efi_err(sys_table, "Failed to relocate kernel\n"); return status; } - 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); - return EFI_ERROR; - } - *image_size = kernel_memsize; + memcpy((void *)*reserve_addr + TEXT_OFFSET, (void *)*image_addr, + kernel_size); + *image_addr = *reserve_addr + TEXT_OFFSET; + *reserve_size = kernel_memsize; }