From patchwork Fri Apr 8 22:50:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 65427 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp316184lbl; Fri, 8 Apr 2016 15:52:01 -0700 (PDT) X-Received: by 10.98.53.6 with SMTP id c6mr1354640pfa.57.1460155916670; Fri, 08 Apr 2016 15:51:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si3213728pat.170.2016.04.08.15.51.56; Fri, 08 Apr 2016 15:51:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932338AbcDHWvq (ORCPT + 29 others); Fri, 8 Apr 2016 18:51:46 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35947 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759174AbcDHWup (ORCPT ); Fri, 8 Apr 2016 18:50:45 -0400 Received: by mail-pf0-f195.google.com with SMTP id q129so10261204pfb.3; Fri, 08 Apr 2016 15:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pLOD0TdBUOpJeU3x/geuPim3e8pSUCT4bpKerGoCkP8=; b=tbo/Puza+N7C/765qepx8mwUtNqW81ImAez0ZNy2ilX4niVRouEw//wPEf6hvCvB/a 4Hr/8YIxBPob0hivcKnvhCKOSAROnw6VebRpFhRuDGfQRcXZ8HLQaT/IXu0MqV1SXkdN S+uNZ0aPIcMPic+dN6Y5ztm84rJ0A84xq9kMJDkAzgB6cgAnJ9Wf3UNgF8WH6gvPfXgA NNKsR/u09i/0abaFsgI1EUag0nPqjw3+5r0t3Ui/3uumpbaC7uimud3IsgYtaKgDP1p7 OoQZ7sUDnOmcz99L6Wr6x/RLH5NOswQCq38PlIKINdJBpFis7wi9t88Q1r15IqRxhm5k uRhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pLOD0TdBUOpJeU3x/geuPim3e8pSUCT4bpKerGoCkP8=; b=W3ZFmiADMcMc5SxL0+W+CoZJ/a7qvId+dNfP4d/Ww0xRBTbJW1ykbjkSa7NAj6E/iI YFLqo6cSh7GJMfx32i0MuXZbc31gOBoMBlEJLJtirSbMzjQTwvNDwEYfuvKmPoVLXjpG YOui01kkj+niRgFvNLWXo3sCAP5Cem0H/exY5bGfjI9ko3OffxPzERr6Tb3yBnF3gSGB f8QolhZ1uZTHHqFv4OMVAbVGVd/RFM6/lnvIUsLUvbq/KvewxgoUQWHbW7ZxzF1/sc+E oigs0/6+sgsf7z+sJCbZYxrHUOVXTCTvBo3k55xjSvburjaNG1EqlOORRED9xWMkYrP4 +wIA== X-Gm-Message-State: AD7BkJJmImNPh2aB8aX1zJycuvzHQBMFVJ9E2kSHxRh5RsYOgHzeqyP8kytFAuOEVxQLhg== X-Received: by 10.98.18.195 with SMTP id 64mr15885183pfs.131.1460155844215; Fri, 08 Apr 2016 15:50:44 -0700 (PDT) Received: from dl.caveonetworks.com ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id fw9sm20928163pac.21.2016.04.08.15.50.38 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Apr 2016 15:50:40 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id u38Mobjm008735; Fri, 8 Apr 2016 15:50:37 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u38MobWp008734; Fri, 8 Apr 2016 15:50:37 -0700 From: David Daney To: Will Deacon , linux-arm-kernel@lists.infradead.org, Rob Herring , Frank Rowand , Grant Likely , Pawel Moll , Ian Campbell , Kumar Gala , Ganapatrao Kulkarni , Robert Richter , Ard Biesheuvel , Matt Fleming , Mark Rutland , Catalin Marinas Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, David Daney Subject: [PATCH v16 1/6] efi: ARM/arm64: ignore DT memory nodes instead of removing them Date: Fri, 8 Apr 2016 15:50:23 -0700 Message-Id: <1460155828-8690-2-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1460155828-8690-1-git-send-email-ddaney.cavm@gmail.com> References: <1460155828-8690-1-git-send-email-ddaney.cavm@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel There are two problems with the UEFI stub DT memory node removal routine: - it deletes nodes as it traverses the tree, which happens to work but is not supported, as deletion invalidates the node iterator; - deleting memory nodes entirely may discard annotations in the form of additional properties on the nodes. Since the discovery of DT memory nodes occurs strictly before the UEFI init sequence, we can simply clear the memblock memory table before parsing the UEFI memory map. This way, it is no longer necessary to remove the nodes, so we can remove that logic from the stub as well. Signed-off-by: Ard Biesheuvel Signed-off-by: David Daney --- drivers/firmware/efi/arm-init.c | 8 ++++++++ drivers/firmware/efi/libstub/fdt.c | 24 +----------------------- 2 files changed, 9 insertions(+), 23 deletions(-) -- 1.8.3.1 diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c index aa1f743..5d6945b 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -143,6 +143,14 @@ static __init void reserve_regions(void) if (efi_enabled(EFI_DBG)) pr_info("Processing EFI memory map:\n"); + /* + * Discard memblocks discovered so far: if there are any at this + * point, they originate from memory nodes in the DT, and UEFI + * uses its own memory map instead. + */ + memblock_dump_all(); + memblock_remove(0, ULLONG_MAX); + for_each_efi_memory_desc(&memmap, md) { paddr = md->phys_addr; npages = md->num_pages; diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index 6dba78a..e58abfa 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c @@ -24,7 +24,7 @@ efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, unsigned long map_size, unsigned long desc_size, u32 desc_ver) { - int node, prev, num_rsv; + int node, num_rsv; int status; u32 fdt_val32; u64 fdt_val64; @@ -54,28 +54,6 @@ efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, goto fdt_set_fail; /* - * Delete any memory nodes present. We must delete nodes which - * early_init_dt_scan_memory may try to use. - */ - prev = 0; - for (;;) { - const char *type; - int len; - - node = fdt_next_node(fdt, prev, NULL); - if (node < 0) - break; - - type = fdt_getprop(fdt, node, "device_type", &len); - if (type && strncmp(type, "memory", len) == 0) { - fdt_del_node(fdt, node); - continue; - } - - prev = node; - } - - /* * Delete all memory reserve map entries. When booting via UEFI, * kernel will use the UEFI memory map to find reserved regions. */