From patchwork Wed Mar 18 17:05:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 45980 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A17A52153C for ; Wed, 18 Mar 2015 17:11:04 +0000 (UTC) Received: by lams18 with SMTP id s18sf8532553lam.2 for ; Wed, 18 Mar 2015 10:11:03 -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 :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=b1ADF3Z4cTSy1w1ZAjmfBX+4gIkdzqVz5OxXtimQUak=; b=ZkAFCC/nA8S5k4Qztz+mAQunzd8dEBxdFnA+EmJKNPanYJdgNG8Ibip+N7MDrhK4Vb VhHs23zuBlvlrDTIlBnUJNWRU24m7mNFuKtLi50redK+Ae0g9swMz1W7FXz+tqPf+2Xs UEU9OQYtaWv5RNZegp3NVnqytLDzS2il9dsU5nrAXVRTJWLLjl4n7XgrJxW6oaf+qbCB 3zieslXOVGA2y3FYmpxcXlUrurobl0TyDwFPKKPiuCBp0tYGxvDUnH5Eoli+uGlnRad7 PAy+EVYlCqeW1PNH/hottg2DG6Zvtrnej0Vq7gGB2btuUfiXJsD7RSI1ELCd+aqtobx+ 95UQ== X-Gm-Message-State: ALoCoQnkEhNaTNQdG5uXgEt2m0vMJp4Q7VYDWXC60zwXfSH9WLPMRFgDKx/GiLc7jWzt0M1CgD49 X-Received: by 10.152.87.141 with SMTP id ay13mr7189360lab.3.1426698663651; Wed, 18 Mar 2015 10:11:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.233 with SMTP id y9ls192780lae.9.gmail; Wed, 18 Mar 2015 10:11:03 -0700 (PDT) X-Received: by 10.112.133.35 with SMTP id oz3mr63655941lbb.98.1426698663434; Wed, 18 Mar 2015 10:11:03 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id py2si13362814lbb.33.2015.03.18.10.11.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 10:11:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbcgn8 with SMTP id gn8so34604191lbc.2 for ; Wed, 18 Mar 2015 10:11:03 -0700 (PDT) X-Received: by 10.152.5.194 with SMTP id u2mr65442768lau.88.1426698663309; Wed, 18 Mar 2015 10:11:03 -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.112.35.133 with SMTP id h5csp1288339lbj; Wed, 18 Mar 2015 10:11:02 -0700 (PDT) X-Received: by 10.107.6.212 with SMTP id f81mr127151652ioi.37.1426698661738; Wed, 18 Mar 2015 10:11:01 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id cc10si37229810pad.30.2015.03.18.10.11.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 10:11:01 -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 1YYHSL-0001AW-CM; Wed, 18 Mar 2015 17:08:33 +0000 Received: from mail-wi0-f171.google.com ([209.85.212.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYHPr-0008HR-JQ for linux-arm-kernel@lists.infradead.org; Wed, 18 Mar 2015 17:06:00 +0000 Received: by wixw10 with SMTP id w10so45615285wix.0 for ; Wed, 18 Mar 2015 10:05:37 -0700 (PDT) X-Received: by 10.194.90.7 with SMTP id bs7mr107104099wjb.7.1426698337325; Wed, 18 Mar 2015 10:05:37 -0700 (PDT) Received: from ards-macbook-pro.local ([84.78.25.113]) by mx.google.com with ESMTPSA id dc9sm3972217wib.9.2015.03.18.10.05.34 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Mar 2015 10:05:36 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, will.deacon@arm.com, mark.rutland@arm.com, catalin.marinas@arm.com, robh@kernel.org Subject: [PATCH v3 5/5] arm64/efi: adapt to relaxed FDT placement requirements Date: Wed, 18 Mar 2015 18:05:08 +0100 Message-Id: <1426698308-726-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1426698308-726-1-git-send-email-ard.biesheuvel@linaro.org> References: <1426698308-726-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150318_100559_942627_9F87C00D X-CRM114-Status: GOOD ( 14.73 ) 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.171 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.171 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: 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.170 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. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/efi.h | 8 +++----- drivers/firmware/efi/libstub/arm-stub.c | 5 ++--- drivers/firmware/efi/libstub/efistub.h | 1 - drivers/firmware/efi/libstub/fdt.c | 10 +++------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index ef572206f1c3..6f526fcc6b70 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -39,12 +39,10 @@ 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 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..f54c76a4fd32 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -269,9 +269,8 @@ 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, - initrd_addr, initrd_size, cmdline_ptr, - fdt_addr, fdt_size); + &new_fdt_addr, initrd_addr, initrd_size, + cmdline_ptr, fdt_addr, fdt_size); /* * If all went well, we need to return the FDT address to the diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 47437b16b186..c8e096094ea9 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -35,7 +35,6 @@ efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, void *handle, unsigned long *new_fdt_addr, - unsigned long max_addr, u64 initrd_addr, u64 initrd_size, char *cmdline_ptr, unsigned long fdt_addr, diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index 91da56c4fd54..48218e91cce1 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 @@ -186,7 +182,6 @@ fdt_set_fail: efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, void *handle, unsigned long *new_fdt_addr, - unsigned long max_addr, u64 initrd_addr, u64 initrd_size, char *cmdline_ptr, unsigned long fdt_addr, @@ -223,8 +218,9 @@ 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, - new_fdt_addr, max_addr); + status = efi_high_alloc(sys_table, new_fdt_size, + EFI_FDT_ALIGN(new_fdt_size), + new_fdt_addr, ULONG_MAX); if (status != EFI_SUCCESS) { pr_efi_err(sys_table, "Unable to allocate memory for new device tree.\n"); goto fail;