From patchwork Tue Jul 29 10:49:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 34463 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3F4EA202E4 for ; Tue, 29 Jul 2014 10:51:26 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id ft15sf55970981pdb.10 for ; Tue, 29 Jul 2014 03:51:25 -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=kxjuKfSsavxn/Er/OuGMA4YMi4nG4+k780tgnGCfh5E=; b=jpT9N+wzlazKjSPolPcevoNJIRb3d3Xh4EDYgVNmEC7vQIXKEDLdiwhsFhIuMZoWVK TUCJTjUVSEoWwGaVweQ0chD8MfiuEaYSoKEquEX+9KLVIIFk2vjXN83TqtrFm9eZt1G2 +KBZGTf+vwWPB4Yi3WmE5gG1Uoy9oSFp5wP1TU0zXjS+uGhN2kurYgl8wWz5OfnGQoo1 8Q9klYGZ+hra0jqe/pRjy1eH2aVpkRsbNcER0kC4ESYFaiwtIiV+dweDhgoJRZDwdlyS 1ZwqT+WfqI4LzDa5qy76TAL1PDj0pYrLtuEoHboLHHikyH8e4l2buyQkPicDMpUrOH0K rotw== X-Gm-Message-State: ALoCoQmXK2hYq7A7j1dokkI2kw02qday3HgJ6JdkS4HTFIpLRffGiBRNQDIZfc8itibdQQ7hWLve X-Received: by 10.66.145.33 with SMTP id sr1mr441120pab.18.1406631085548; Tue, 29 Jul 2014 03:51:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.36 with SMTP id b33ls58250qgd.68.gmail; Tue, 29 Jul 2014 03:51:25 -0700 (PDT) X-Received: by 10.220.105.201 with SMTP id u9mr812957vco.11.1406631085380; Tue, 29 Jul 2014 03:51:25 -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 t1si14336204vcx.69.2014.07.29.03.51.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Jul 2014 03:51:25 -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 id10so13076707vcb.7 for ; Tue, 29 Jul 2014 03:51:25 -0700 (PDT) X-Received: by 10.52.63.226 with SMTP id j2mr658387vds.43.1406631085301; Tue, 29 Jul 2014 03:51:25 -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 tc5csp235058vcb; Tue, 29 Jul 2014 03:51:24 -0700 (PDT) X-Received: by 10.68.102.3 with SMTP id fk3mr1128000pbb.95.1406631080866; Tue, 29 Jul 2014 03:51:20 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id yb1si17166928pbc.221.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:20 -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 1XC4yk-0004AG-UA; Tue, 29 Jul 2014 10:49:58 +0000 Received: from mail-wi0-f170.google.com ([209.85.212.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XC4ya-000404-6A for linux-arm-kernel@lists.infradead.org; Tue, 29 Jul 2014 10:49:51 +0000 Received: by mail-wi0-f170.google.com with SMTP id f8so5664000wiw.3 for ; Tue, 29 Jul 2014 03:49:25 -0700 (PDT) X-Received: by 10.180.105.68 with SMTP id gk4mr5053796wib.24.1406630965335; Tue, 29 Jul 2014 03:49:25 -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.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Jul 2014 03:49:24 -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 3/3] arm64/efi: efistub: don't abort if base of DRAM is occupied Date: Tue, 29 Jul 2014 12:49:10 +0200 Message-Id: <1406630950-32432-4-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_034948_372438_59CC5683 X-CRM114-Status: GOOD ( 12.38 ) 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.170 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.170 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 If we cannot relocate the kernel Image to its preferred offset of base of DRAM plus TEXT_OFFSET, instead relocate it to the lowest available 2 MB boundary plus TEXT_OFFSET. We may lose a bit of memory at the low end, but we can still proceed normally otherwise. Signed-off-by: Ard Biesheuvel Acked-by: Mark Salter --- arch/arm64/kernel/efi-stub.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index 60e98a639ac5..460c00c41e57 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 + TEXT_OFFSET; }