From patchwork Tue Feb 7 17:59:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Hugo X-Patchwork-Id: 9560791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F40076047A for ; Tue, 7 Feb 2017 18:00:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E626F28415 for ; Tue, 7 Feb 2017 18:00:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB09128457; Tue, 7 Feb 2017 18:00:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6024528415 for ; Tue, 7 Feb 2017 18:00:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cbA4D-0002wQ-CO; Tue, 07 Feb 2017 18:00:37 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cbA48-0002vl-Pg for linux-arm-kernel@lists.infradead.org; Tue, 07 Feb 2017 18:00:35 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id ABC01609C6; Tue, 7 Feb 2017 18:00:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486490411; bh=RenJFD9h4KIVCEQNjMjH+5y9qYg3iq0++Wniu+3fluM=; h=From:To:Cc:Subject:Date:From; b=SJ9LnCUVbcZIvxUlxnW8WGifnXwTKL7CPSgs5KHPOE23l+3Q4qEOOgib2nXQwl072 9iJ+2a65vTgHC+30Z9lA0z98KCJGmyLSkUxyaFVTOHt1QnEKWBnCVp6jvq8JEa3FxL K6hnHNQUhT/MQKqxwVIjoGSxAChObzBdec0HVpAI= Received: from jhugo-perf-lnx.qualcomm.com (unknown [129.46.14.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jhugo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id F373C608C5; Tue, 7 Feb 2017 18:00:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486490411; bh=RenJFD9h4KIVCEQNjMjH+5y9qYg3iq0++Wniu+3fluM=; h=From:To:Cc:Subject:Date:From; b=SJ9LnCUVbcZIvxUlxnW8WGifnXwTKL7CPSgs5KHPOE23l+3Q4qEOOgib2nXQwl072 9iJ+2a65vTgHC+30Z9lA0z98KCJGmyLSkUxyaFVTOHt1QnEKWBnCVp6jvq8JEa3FxL K6hnHNQUhT/MQKqxwVIjoGSxAChObzBdec0HVpAI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org F373C608C5 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jhugo@codeaurora.org From: Jeffrey Hugo To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] efi/libstub/arm*: Set default address and size cells values for an empty dtb Date: Tue, 7 Feb 2017 10:59:50 -0700 Message-Id: <1486490390-25251-1-git-send-email-jhugo@codeaurora.org> X-Mailer: git-send-email 1.8.5.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170207_100032_919540_CC1D0554 X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeffrey Hugo , Sameer Goel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sameer Goel In cases where a device tree is not provided (ie ACPI based system), an empty fdt is generated by efistub. Sets the address and size cell values in a generated fdt to support 64 bit addressing. This enables kexec/kdump on Qualcomm Technologies QDF24XX platforms as those utilities will read the address/size values from the fdt, and such values may exceed the range provided by the 32 bit default. Change-Id: Ie7f3637e375bd6631c6bda1f7b3c9003765ff4a5 Signed-off-by: Sameer Goel Signed-off-by: Jeffrey Hugo --- drivers/firmware/efi/libstub/fdt.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index 921dfa0..def5c9c 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c @@ -16,6 +16,34 @@ #include "efistub.h" +#define EFI_DT_ADDR_CELLS_DEFAULT 2 +#define EFI_DT_SIZE_CELLS_DEFAULT 2 + +static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt) +{ + int offset; + int status; + + offset = fdt_path_offset(fdt, "/"); + /* Set the #address-cells and #size-cells values for an empty tree */ + + status = fdt_setprop_u32(fdt, offset, "#address-cells", + EFI_DT_ADDR_CELLS_DEFAULT); + if (status) { + pr_efi(sys_table, + "Failed to set #address-cells for empty dtb\n"); + return; + } + + status = fdt_setprop_u32(fdt, offset, "#size-cells", + EFI_DT_SIZE_CELLS_DEFAULT); + if (status) { + pr_efi(sys_table, + "Failed to set #size-cells for empty dtb\n"); + return; + } +} + static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, unsigned long orig_fdt_size, void *fdt, int new_fdt_size, char *cmdline_ptr, @@ -44,8 +72,16 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, if (orig_fdt) status = fdt_open_into(orig_fdt, fdt, new_fdt_size); - else + else { status = fdt_create_empty_tree(fdt, new_fdt_size); + if (status == 0) { + /* + * Any failure from the following function is non + * critical + */ + fdt_update_cell_size(sys_table, fdt); + } + } if (status != 0) goto fdt_set_fail;