From patchwork Tue Mar 3 11:03:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 45356 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E368721429 for ; Tue, 3 Mar 2015 11:15:58 +0000 (UTC) Received: by lams18 with SMTP id s18sf28637900lam.1 for ; Tue, 03 Mar 2015 03:15:57 -0800 (PST) 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 :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=NqkACOVRlL3pBeH1kLtIVENZGyQn2Sl93dJONbzuvDc=; b=FJssQTKY/utcDu3fvBYZLXJv2HAhn9WQlmF11zalBgV6h0IgOSdI0I+PuKQstKrrSE cuuAtL2ugWRZxJzkvGfIdVa9kCxJEEW+Wl8iz1fOrQsyl26l0zwDw23UWpolO7NgBjZV Xl1DDbXaQYoaYqS12egxl2HpqzMPsk0ivPDYim41+wwVQt+TomonpDFyWCOLr6JC1Yx+ 131QR/0o5ACNb4OMi0sYXBoFn230Ur5yGJXY+zivd2obZgRIf6l4q6zglUNjLXTgAMUJ SAhhzEh/u2NF2AEcGX+sWO6uQ77PCbO23PXBxor8epb1hYXt+yjLj3xFiem13tdV6V9K 621g== X-Gm-Message-State: ALoCoQkPoEhO9jKHA1GhFmCxN2ize7prQZgTUwLZ41EJePknyAAK00IgG6PvDgFm/RK1StgtVXag X-Received: by 10.181.29.66 with SMTP id ju2mr2877216wid.1.1425381357823; Tue, 03 Mar 2015 03:15:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.67 with SMTP id l3ls21340lae.93.gmail; Tue, 03 Mar 2015 03:15:57 -0800 (PST) X-Received: by 10.112.172.131 with SMTP id bc3mr28571715lbc.79.1425381357662; Tue, 03 Mar 2015 03:15:57 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id rw4si303216lbb.67.2015.03.03.03.15.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2015 03:15:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbvp9 with SMTP id p9so13368677lbv.8 for ; Tue, 03 Mar 2015 03:15:57 -0800 (PST) X-Received: by 10.112.224.3 with SMTP id qy3mr5837425lbc.36.1425381357564; Tue, 03 Mar 2015 03:15:57 -0800 (PST) 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.112.35.133 with SMTP id h5csp493205lbj; Tue, 3 Mar 2015 03:15:56 -0800 (PST) X-Received: by 10.66.101.73 with SMTP id fe9mr56075415pab.156.1425381355842; Tue, 03 Mar 2015 03:15:55 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id na1si499121pbc.161.2015.03.03.03.15.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2015 03:15:55 -0800 (PST) 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 1YSklY-0002Jr-Us; Tue, 03 Mar 2015 11:13:32 +0000 Received: from mail-wi0-f182.google.com ([209.85.212.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YSkdO-0002bi-Ak for linux-arm-kernel@lists.infradead.org; Tue, 03 Mar 2015 11:05:07 +0000 Received: by widem10 with SMTP id em10so20581480wid.0 for ; Tue, 03 Mar 2015 03:04:42 -0800 (PST) X-Received: by 10.180.91.47 with SMTP id cb15mr1611262wib.39.1425380682478; Tue, 03 Mar 2015 03:04:42 -0800 (PST) Received: from ards-macbook-pro.local ([213.143.61.132]) by mx.google.com with ESMTPSA id k6sm20058411wia.6.2015.03.03.03.04.28 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Mar 2015 03:04:41 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, grant.likely@linaro.org, robh@kernel.org, msalter@redhat.com Subject: [PATCH 5/5] arm64/efi: adapt to relaxed FDT placement requirements Date: Tue, 3 Mar 2015 12:03:50 +0100 Message-Id: <1425380630-3684-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1425380630-3684-1-git-send-email-ard.biesheuvel@linaro.org> References: <1425380630-3684-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150303_030506_544005_E64D67F1 X-CRM114-Status: GOOD ( 14.21 ) 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.182 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.182 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: matt.fleming@intel.com, Ard Biesheuvel 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.217.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 With the relaxed FDT placement requirements in place, we can change the allocation strategy used by the stub to put the FDT image higher up in memory. At the same time, reduce the minimal alignment to a power of 2 upper bound of the size: this way, we are still guaranteed not to cross a 2 MB boundary, but will potentially waste less memory doing so. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/efi.h | 9 ++++----- drivers/firmware/efi/libstub/arm-stub.c | 2 +- drivers/firmware/efi/libstub/fdt.c | 7 ++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index ef572206f1c3..68f7bb2ddad7 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -39,12 +39,11 @@ extern void efi_init(void); /* arch specific definitions used by the stub code */ /* - * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from - * start of kernel and may not cross a 2MiB boundary. We set alignment to - * 2MiB so we know it won't cross a 2MiB boundary. + * AArch64 requires the DTB to be 8-byte aligned and not cross a 2MiB boundary. + * So align to a power of 2 upper bound of the FDT size. */ -#define EFI_FDT_ALIGN SZ_2M /* used by allocate_new_fdt_and_exit_boot() */ -#define MAX_FDT_OFFSET SZ_512M +#define EFI_FDT_ALIGN(x) roundup_pow_of_two(x) +#define MAX_FDT_OFFSET ULONG_MAX #define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__) diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index dcae482a9a17..c58c21c22dbe 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -269,7 +269,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, new_fdt_addr = fdt_addr; status = allocate_new_fdt_and_exit_boot(sys_table, handle, - &new_fdt_addr, dram_base + MAX_FDT_OFFSET, + &new_fdt_addr, MAX_FDT_OFFSET, initrd_addr, initrd_size, cmdline_ptr, fdt_addr, fdt_size); diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index 91da56c4fd54..1a44d410a63b 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c @@ -165,10 +165,6 @@ fdt_set_fail: return EFI_LOAD_ERROR; } -#ifndef EFI_FDT_ALIGN -#define EFI_FDT_ALIGN EFI_PAGE_SIZE -#endif - /* * Allocate memory for a new FDT, then add EFI, commandline, and * initrd related fields to the FDT. This routine increases the @@ -223,7 +219,8 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, */ new_fdt_size = fdt_size + EFI_PAGE_SIZE; while (1) { - status = efi_high_alloc(sys_table, new_fdt_size, EFI_FDT_ALIGN, + status = efi_high_alloc(sys_table, new_fdt_size, + EFI_FDT_ALIGN(new_fdt_size), new_fdt_addr, max_addr); if (status != EFI_SUCCESS) { pr_efi_err(sys_table, "Unable to allocate memory for new device tree.\n");