From patchwork Wed Aug 26 08:06:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 52708 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id C8EC922E8B for ; Wed, 26 Aug 2015 08:08:43 +0000 (UTC) Received: by lbcue2 with SMTP id ue2sf59417434lbc.1 for ; Wed, 26 Aug 2015 01:08:42 -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=PAn5H/3OerxYuuKfg9O+0hzgW9ZwLIoIAYzvWThdsjQ=; b=WZ72xVaMGppCra+28f9NjVgMZWtFKTn4lV8JFyXhhV4qsc/wKI9v4SNzxJLdh3M8wJ j4fw2rfARScvy6jX4VmXsCanHFQOTXp4e7dpN0gYGbSmKZAdZX3Y1Ul+t59qazJlvwyR EZlStmmKH+tIXtYN97u1VTb6rVKv/vMtDJAeJlW7PZM867ajq+NZuwTOY2XJJM3a5466 nLgnkEGYbHf8enaK+46C+ddIBIGtLGA9rpZowWeKA6JiEE7c3LlNsK5spYPNH2Df0JEO NfRqukS0XvbJMQiRNVDfrA19UOqUqM1xYqiTTxrsojRS2uJtMuxMlKr2YINdVodtwjwV VMRg== X-Gm-Message-State: ALoCoQlHmmVM2i9Eek0RkBhZG2reCFh7bMEcEANwVGC6CARG8ru35izbc2UZSw01YQC7j8N1D6nO X-Received: by 10.152.9.4 with SMTP id v4mr9693506laa.6.1440576522802; Wed, 26 Aug 2015 01:08:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.108 with SMTP id db12ls828805lad.70.gmail; Wed, 26 Aug 2015 01:08:42 -0700 (PDT) X-Received: by 10.112.163.72 with SMTP id yg8mr29398274lbb.82.1440576522510; Wed, 26 Aug 2015 01:08:42 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id qb2si18179927lbc.125.2015.08.26.01.08.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 01:08:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbpu9 with SMTP id pu9so115132750lbb.3 for ; Wed, 26 Aug 2015 01:08:42 -0700 (PDT) X-Received: by 10.152.164.130 with SMTP id yq2mr26758907lab.76.1440576522401; Wed, 26 Aug 2015 01:08:42 -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.162.200 with SMTP id yc8csp3739745lbb; Wed, 26 Aug 2015 01:08:41 -0700 (PDT) X-Received: by 10.55.18.6 with SMTP id c6mr75193654qkh.96.1440576519492; Wed, 26 Aug 2015 01:08:39 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id k140si3307738qhk.111.2015.08.26.01.08.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 01:08:39 -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 1ZUVk0-0007wp-0d; Wed, 26 Aug 2015 08:07:28 +0000 Received: from mail-wi0-f174.google.com ([209.85.212.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUVjg-0007i3-Lu for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2015 08:07:09 +0000 Received: by wicne3 with SMTP id ne3so36572075wic.0 for ; Wed, 26 Aug 2015 01:06:48 -0700 (PDT) X-Received: by 10.180.84.33 with SMTP id v1mr10947485wiy.39.1440576408710; Wed, 26 Aug 2015 01:06:48 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by smtp.gmail.com with ESMTPSA id gm20sm2569597wjc.17.2015.08.26.01.06.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 01:06:48 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, leif.lindholm@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, msalter@redhat.com Subject: [PATCH v2 4/5] arm64/efi: ignore DT memory nodes instead of removing them Date: Wed, 26 Aug 2015 10:06:30 +0200 Message-Id: <1440576391-25725-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440576391-25725-1-git-send-email-ard.biesheuvel@linaro.org> References: <1440576391-25725-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150826_010708_878490_76550071 X-CRM114-Status: GOOD ( 17.64 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.174 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.174 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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 , haojian.zhuang@linaro.org, Ganapatrao.Kulkarni@caviumnetworks.com, leo.yan@linaro.org 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.175 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. Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm --- arch/arm64/mm/init.c | 10 ++++++++ drivers/firmware/efi/libstub/fdt.c | 24 +------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index ab25fde7397c..ecbc051bc66b 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -379,6 +379,16 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) { const u64 phys_offset = __pa(PAGE_OFFSET); + /* + * This callback will be invoked both when booting via UEFI and when + * booting via DT only. In the former case, we need to ignore memory + * nodes in the DT since UEFI is authoritative when it comes to the + * memory map. So ignore any invocations of this callback after + * EFI_MEMMAP has been set. + */ + if (efi_enabled(EFI_MEMMAP)) + return; + if (!PAGE_ALIGNED(base)) { if (size < PAGE_SIZE - (base & ~PAGE_MASK)) { pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", 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. */