From patchwork Sat Feb 20 01:13:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 62446 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp106496lbl; Fri, 19 Feb 2016 17:16:06 -0800 (PST) X-Received: by 10.66.150.170 with SMTP id uj10mr22024949pab.91.1455930966454; Fri, 19 Feb 2016 17:16:06 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id wu1si19887002pab.71.2016.02.19.17.16.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Feb 2016 17:16:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com 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 1aWw8L-0002Jy-Lu; Sat, 20 Feb 2016 01:14:53 +0000 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWw7R-0001xF-6G for linux-arm-kernel@lists.infradead.org; Sat, 20 Feb 2016 01:14:02 +0000 Received: by mail-pf0-x229.google.com with SMTP id c10so61681333pfc.2 for ; Fri, 19 Feb 2016 17:13:38 -0800 (PST) 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=bxPy4AOa8p4i6x+3aNKV2sOmz8uaTdA9zqHn3EPg0/Y=; b=lpGyXArGnBOQx2AOUNvn3lcQ2Upludx2WOIbnEp7deqK639xDKJsxPiLHyxs5aXdlN A3/e+GuvHtURz+a/9HPXO65BNHeX4w2rMveICKQ7bqLZl8uf/y8WbRLo/RW5vbYtiCbX sl+WyFOGvpkz+7KLTYR8BNfW6qQZ/0XLzxZlI7+MpZlPuFxZWI2+SVfm0D3g9Oh63yL1 04K/SpGkKMGfrG/H9f12ZCUegELCzhidkXlURYNcGmbwaadUkKUT7Xo5MehY5/5g7VRq nxuUGIibrrTuiAGx4U07xUvsbLgdSUb8wnkm0pUaKwFyYmxwrUQqgqDbvLsFglaHzOIV J2yw== 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=bxPy4AOa8p4i6x+3aNKV2sOmz8uaTdA9zqHn3EPg0/Y=; b=I0zK7ClUzA2ka7g+/jOu0P2Jvd+vuyb9MGDWNPjBoCyDxCXZc9k0K55EN+HRBInEqS kIYCxBf+ZH0lUlhkRhMA3PEHXwIgXQqVZmYv/Pt+rjP3qozGZ0tW29t5UG6ZQJ14V5Yi nbUi6vaSsPC6tesK24Ool62Y5SxaiPpzAGTDH/b9a5temRkSLggiemBp/cgwZvPKIZr4 BWX1wRhzEaZEeLL37ShT6eB70dWMg5VbHuxV0SLOjx2XNs2VX9kOJnWc9n8Stv1p+tNn Xyshx8py5QRDPdjwhMvD4/uk1S/y3bziDI/nBi32ll9Gj4w/ixJi9xl7A1kltbW7m1bn pLtw== X-Gm-Message-State: AG10YOQwRm8pf+cXUtEII0vG3mq4G26+BT3O8GUuOaVTpz3a1VMBS45Q38TVAOQzBVfkbQ== X-Received: by 10.98.68.220 with SMTP id m89mr22062313pfi.65.1455930817868; Fri, 19 Feb 2016 17:13:37 -0800 (PST) Received: from dl.caveonetworks.com ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id m87sm20382330pfj.38.2016.02.19.17.13.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Feb 2016 17:13:31 -0800 (PST) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id u1K1DSqM005434; Fri, 19 Feb 2016 17:13:28 -0800 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u1K1DSEB005433; Fri, 19 Feb 2016 17:13:28 -0800 From: David Daney To: Will Deacon , linux-arm-kernel@lists.infradead.org, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , devicetree@vger.kernel.org, Ard Biesheuvel , Frank Rowand , Grant Likely , Catalin Marinas , Matt Fleming , linux-efi@vger.kernel.org, Ganapatrao Kulkarni , Robert Richter Subject: [PATCH v11 05/10] arm64/efi: ignore DT memory nodes instead of removing them Date: Fri, 19 Feb 2016 17:13:14 -0800 Message-Id: <1455930799-5371-6-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1455930799-5371-1-git-send-email-ddaney.cavm@gmail.com> References: <1455930799-5371-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160219_171357_618848_0A1E93D4 X-CRM114-Status: GOOD ( 16.97 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ddaney.cavm[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, David Daney MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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. Now that the UEFI initialization has moved to an earlier stage, we can actually just ignore any memblocks that are installed after we have processed 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. Acked-by: Leif Lindholm Signed-off-by: Ard Biesheuvel [ rric: Ported to v4.5-rc1 ] Signed-off-by: Robert Richter Signed-off-by: David Daney --- arch/arm64/mm/init.c | 6 +++++- drivers/firmware/efi/arm-init.c | 2 +- drivers/firmware/efi/libstub/fdt.c | 24 +----------------------- 3 files changed, 7 insertions(+), 25 deletions(-) -- 1.8.3.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 208c1d3..eda226e 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -383,5 +383,9 @@ __setup("keepinitrd", keepinitrd_setup); void __init early_init_dt_add_memory_arch(u64 base, u64 size) { - early_init_dt_add_memory(base, size); + /* + * Ignore DT memory nodes if we are booting via UEFI. + */ + if (!efi_enabled(EFI_MEMMAP)) + early_init_dt_add_memory(base, size); } diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c index 9fe0464..ded8957 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -159,7 +159,7 @@ static __init void reserve_regions(void) size = npages << PAGE_SHIFT; if (is_normal_ram(md)) - early_init_dt_add_memory_arch(paddr, size); + early_init_dt_add_memory(paddr, size); if (is_reserve_region(md)) { memblock_mark_nomap(paddr, size); diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index cf7b7d4..9df1560 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. */