From patchwork Mon May 11 06:41:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 48205 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 084922121F for ; Mon, 11 May 2015 06:47:23 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf36980769wgt.1 for ; Sun, 10 May 2015 23:47:22 -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:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=8v2Pw/yGoQhGaVnsO6PEIxZivBu5+yEe6WHLZTxjYMQ=; b=C05+YNHdJJOnL7sYmaNa+7SYkTlitZbYNTrtHygvgEADG75c2kTFxf2KUZppcXpdLu 8/SdcKNsNR2RpQV3oks/tcbSQkstg12Jas7TBZtCDSyP4m2fKvolAqWS8lC37F9vTBG+ iFjvi9WkCq7Z/HB9/ita7CN7wqgpoODJ5GUnl3lYngl/OXYK2JnsqNyhZCc3d5glBdEg YllyN4ogcj6mDdAdvNARZohT8qeriLZw6I9ZlDZThPWtXk+RSSNFZA7zYycv8IyvGQlx KdQFqjvF6BUvYfcoi6SChaZKNiG/WpxPZWuIqsra/7b14b31k8VJWTAhTMfi2gtPCK7w UZxg== X-Gm-Message-State: ALoCoQkdZhmWdFNiltEGX3g6Ibb8VqHbe6WL1grXojqoxaEblNGBVGiVW3ZAXhQTrNLHd2NU9aut X-Received: by 10.152.87.140 with SMTP id ay12mr6623338lab.8.1431326842323; Sun, 10 May 2015 23:47:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.34 with SMTP id n2ls564381laj.15.gmail; Sun, 10 May 2015 23:47:22 -0700 (PDT) X-Received: by 10.152.224.164 with SMTP id rd4mr7115418lac.77.1431326842182; Sun, 10 May 2015 23:47:22 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id bb9si7809274lab.145.2015.05.10.23.47.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 23:47:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbqq2 with SMTP id qq2so87118468lbb.3 for ; Sun, 10 May 2015 23:47:22 -0700 (PDT) X-Received: by 10.112.182.4 with SMTP id ea4mr7103988lbc.35.1431326842007; Sun, 10 May 2015 23:47:22 -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.108.230 with SMTP id hn6csp1335453lbb; Sun, 10 May 2015 23:47:20 -0700 (PDT) X-Received: by 10.70.95.131 with SMTP id dk3mr16876379pdb.44.1431326838946; Sun, 10 May 2015 23:47:18 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id vx6si16732934pab.220.2015.05.10.23.47.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 23:47:18 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) 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 1YrhRt-00087l-Lx; Mon, 11 May 2015 06:44:21 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YrhQI-0007FM-Nt for linux-arm-kernel@lists.infradead.org; Mon, 11 May 2015 06:42:44 +0000 Received: by wgbhc8 with SMTP id hc8so18121630wgb.2 for ; Sun, 10 May 2015 23:42:20 -0700 (PDT) X-Received: by 10.180.7.169 with SMTP id k9mr17949317wia.70.1431326539976; Sun, 10 May 2015 23:42:19 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id wr2sm21173009wjb.45.2015.05.10.23.42.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 May 2015 23:42:19 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, grant.likely@linaro.org, leif.lindholm@linaro.org, roy.franz@linaro.org, catalin.marinas@arm.com, mark.rutland@arm.com, matt.fleming@intel.com Subject: [PATCH 6/8] arm64/efi: ignore DT memory nodes instead of removing them Date: Mon, 11 May 2015 08:41:58 +0200 Message-Id: <1431326520-17331-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org> References: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150510_234243_009246_BD7D909A X-CRM114-Status: GOOD ( 14.53 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.49 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ganapatrao.Kulkarni@caviumnetworks.com, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , 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.171 as permitted sender) smtp.mail=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 --- arch/arm64/mm/init.c | 7 +++++++ drivers/firmware/efi/libstub/fdt.c | 24 +----------------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 64480b65ef17..95c239f43384 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -386,6 +386,13 @@ __setup("keepinitrd", keepinitrd_setup); void __init early_init_dt_add_memory_arch(u64 base, u64 size) { + /* + * EFI_MEMMAP will be set /after/ UEFI has installed all memory based + * on the content of the UEFI memory map. + */ + 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. */