From patchwork Tue Sep 22 00:21:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 53994 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id AD86F22B1E for ; Tue, 22 Sep 2015 00:24:29 +0000 (UTC) Received: by lagj9 with SMTP id j9sf49689091lag.0 for ; Mon, 21 Sep 2015 17:24:28 -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:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=B1plmek0WPj9oxQrm8Ze0QidMzNq/Opn7H2VSGb6lsA=; b=O+wZp86UnQiKdd4f6PJvihH15IPI88KxQlJRuBpkAm2PMENrQmLoy3MolX94iKi62N n45ZSfzUro0nTIehsyrXGFip7Mos8femGJq5ttIrkY8siH/sJOhcBEe6fShLxVFR7wyM RQiptIVLhYmgUZ1K23aD1r/YccZkL1K+dKFs6h9SBvKalbfHzHkUSnzeKPlcdVE0Pdrk 1kOzvOdLCs1Uo/pAgkuVrngYsIcHfe/WXrfTHp4cRB2w1fbfzKsydbaiNIiuo/KXjpD0 c3EYfutUmFfIgio2qdcJ8S2AUBg+bxnwK9tjbnn83avD8FNU7gHc/Q9FZVf2xjSLA+xw aofA== X-Gm-Message-State: ALoCoQmdebDA9A6iZUzG/v/dewHNEl+Vzmc2dW2fxN1BFFwaqzT77VuognWY1iUlLicVboiTrAgg X-Received: by 10.112.202.165 with SMTP id kj5mr3725147lbc.5.1442881468063; Mon, 21 Sep 2015 17:24:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.8 with SMTP id i8ls530129lam.59.gmail; Mon, 21 Sep 2015 17:24:27 -0700 (PDT) X-Received: by 10.112.156.193 with SMTP id wg1mr8647057lbb.24.1442881467929; Mon, 21 Sep 2015 17:24:27 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id 82si1409491lfu.87.2015.09.21.17.24.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 17:24:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbmp1 with SMTP id mp1so59957916lbb.1 for ; Mon, 21 Sep 2015 17:24:27 -0700 (PDT) X-Received: by 10.112.129.202 with SMTP id ny10mr8534314lbb.112.1442881467643; Mon, 21 Sep 2015 17:24:27 -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.59.35 with SMTP id w3csp179042lbq; Mon, 21 Sep 2015 17:24:26 -0700 (PDT) X-Received: by 10.194.121.232 with SMTP id ln8mr30417565wjb.76.1442881466923; Mon, 21 Sep 2015 17:24:26 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id hw7si13161969wjb.208.2015.09.21.17.24.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 17:24:26 -0700 (PDT) Received-SPF: pass (google.com: 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; 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 1ZeBMO-0001ev-Ko; Tue, 22 Sep 2015 00:23:04 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZeBLq-0001Mb-RL for linux-arm-kernel@bombadil.infradead.org; Tue, 22 Sep 2015 00:22:30 +0000 Received: from mail-pa0-f48.google.com ([209.85.220.48]) by merlin.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1ZeBLo-0003SF-LE for linux-arm-kernel@lists.infradead.org; Tue, 22 Sep 2015 00:22:29 +0000 Received: by padhy16 with SMTP id hy16so130605944pad.1 for ; Mon, 21 Sep 2015 17:22:04 -0700 (PDT) X-Received: by 10.68.111.165 with SMTP id ij5mr27649572pbb.59.1442881324525; Mon, 21 Sep 2015 17:22:04 -0700 (PDT) Received: from localhost.localdomain ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id xv12sm26924984pac.38.2015.09.21.17.22.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Sep 2015 17:22:03 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, leif.lindholm@linaro.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, msalter@redhat.com Subject: [PATCH v3 5/6] arm64/efi: ignore DT memory nodes instead of removing them Date: Mon, 21 Sep 2015 17:21:27 -0700 Message-Id: <1442881288-13962-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442881288-13962-1-git-send-email-ard.biesheuvel@linaro.org> References: <1442881288-13962-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150921_202228_764717_4E1CCCFC X-CRM114-Status: GOOD ( 16.36 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.48 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.48 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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: Ard Biesheuvel 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.180 as permitted sender) smtp.mailfrom=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 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 --- arch/arm64/kernel/efi.c | 2 +- arch/arm64/mm/init.c | 6 ++++- drivers/firmware/efi/libstub/fdt.c | 24 +------------------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index a9e63122e32d..1baa75a0df20 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -181,7 +181,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_reserve(paddr, size); diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index d88e83ebf60d..d8ce7f51dba1 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -377,5 +377,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/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index ef5d764e2a27..343e7992bd8f 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. */