From patchwork Wed Mar 15 10:01:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 95326 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp246935qgd; Wed, 15 Mar 2017 02:59:04 -0700 (PDT) X-Received: by 10.99.138.202 with SMTP id y193mr2726900pgd.60.1489571944775; Wed, 15 Mar 2017 02:59:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b35si1640919plh.80.2017.03.15.02.59.04; Wed, 15 Mar 2017 02:59:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751885AbdCOJ7E (ORCPT + 2 others); Wed, 15 Mar 2017 05:59:04 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:32974 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642AbdCOJ7E (ORCPT ); Wed, 15 Mar 2017 05:59:04 -0400 Received: by mail-pf0-f176.google.com with SMTP id w189so6894654pfb.0 for ; Wed, 15 Mar 2017 02:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jqaCl5Aa3BHdM/EvoNSWXE7yCVErZLy2r54ci6I3RQw=; b=eBXsWmQIsj7YTfNE7X/wkPuB0htl0RvJJ7kLLiroMjtQSZ6DPd+Xmct6N9x82eZNBp s4hqAeHssZT2xehZ0WGDWGbBPE6LJl4hLm2G8I7VGY5e39JC7ls3cOxJ25Fzu4ADEkea dn1nmdUu9yF4V/UFUw9pgYhRGiUjxBobuEeGU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jqaCl5Aa3BHdM/EvoNSWXE7yCVErZLy2r54ci6I3RQw=; b=Lcf5TMQM4hXVykXp5HIZkly8/59cCF6fhLWVOPt//6XEexeIO6Bfm1Y52AjvlGmDky gVqnwxlYWEr3VLyJUHHIdEgBWf1AUwmbNqGTdA2D3fRkhRaa8dyTaiicxkQxdCeyAXV2 WU1IsUCdaZUDBM3xGhSbWxWLSZiJUHbzdKRKksI1Ad/vY8FC7kydwuOfi5i0xykl3SgG gavOo/zLdLtFF7ak48FLvNd1hxywX1UQ4kEsHPXyDfvm/u4WptPrZBD4t2kgWlHmeETZ eauV4I3NFbT+ZqtybL1miRzo+mAMKzZbUJNDlEN/0wScHy8JOWluC1O51YefyNuLHOOX s58w== X-Gm-Message-State: AFeK/H1tBnxNk84g/nscfkHbgpcHMQuvsKzUen7+pCeaEC0oxFP+RglisSz9pJ9I76c8HY4/ X-Received: by 10.98.194.88 with SMTP id l85mr2649557pfg.55.1489571942646; Wed, 15 Mar 2017 02:59:02 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 75sm3214353pfp.80.2017.03.15.02.59.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 02:59:02 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Cc: james.morse@arm.com, geoff@infradead.org, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, mark.rutland@arm.com, sgoel@codeaurora.org, jhugo@codeaurora.org, ard.biesheuvel@linaro.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v33 14/14] efi/libstub/arm*: Set default address and size cells values for an empty dtb Date: Wed, 15 Mar 2017 19:01:19 +0900 Message-Id: <20170315100119.25314-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170315095656.24992-1-takahiro.akashi@linaro.org> References: <20170315095656.24992-1-takahiro.akashi@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Sameer Goel In cases where a device tree is not provided (ie ACPI based system), an empty fdt is generated by efistub. #address-cells and #size-cells are not set in the empty fdt, so they default to 1 (4 byte wide). This can be an issue on 64-bit systems where values representing addresses, etc may be 8 bytes wide as the default value does not align with the general requirements for an empty DTB, and is fragile when passed to other agents as extra care is required to read the entire width of a value. This issue is observed on Qualcomm Technologies QDF24XX platforms when kexec-tools inserts 64-bit addresses into the "linux,elfcorehdr" and "linux,usable-memory-range" properties of the fdt. When the values are later consumed, they are truncated to 32-bit. Setting #address-cells and #size-cells to 2 at creation of the empty fdt resolves the observed issue, and makes the fdt less fragile. Signed-off-by: Sameer Goel Signed-off-by: Jeffrey Hugo --- drivers/firmware/efi/libstub/fdt.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) -- 2.11.1 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index 260c4b4b492e..82973b86efe4 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c @@ -16,6 +16,22 @@ #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; + + offset = fdt_path_offset(fdt, "/"); + /* Set the #address-cells and #size-cells values for an empty tree */ + + fdt_setprop_u32(fdt, offset, "#address-cells", + EFI_DT_ADDR_CELLS_DEFAULT); + + fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT); +} + 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, @@ -42,10 +58,18 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, } } - if (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;