From patchwork Mon Sep 8 13:31:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 36978 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EDD1320491 for ; Mon, 8 Sep 2014 13:32:56 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kx10sf4699605pab.8 for ; Mon, 08 Sep 2014 06:32:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=fn+s/M7f5oyB/LmB/1fr9TqVzt54EigEZke2wUnh/GU=; b=X8vbvc2xqTb3/GwJcie4LaANEK6YWH4bw++B0O2SajKVTg5u8b7A445LRT8Kv9+bYC O8CoWZgN2C6z2NAeUjd33HSu4p9k91DCtw+S5oqPfDhkSmajEKCBpMt5oXxAKlQS3i/k 01+cgVAUUx0LFdVohmZS4haSAH/wgm98XVgU40/hkQ0T++l3iDaZRxGmHCBWcRN6JL+S yDDY1+VwJXAKK3bjOYVtjinIrpLTIO4rRHdBQUk5t1cdNGpqTi9uGuXAmPmYKvZWda+Z 43Q+3M9MWuEeYuuc0CzRF5ywE42I2idKF83sraJ5zEUOCPWC+YYOacO/ptiFFxYgYTtv 1MxQ== X-Gm-Message-State: ALoCoQn+JjAEJaTkBUTyYEmFd8gJ29UaCZhPBt6k1uwnFM8xEkok7LMaa8o/l6GKpgKwsBLnkn/R X-Received: by 10.70.96.197 with SMTP id du5mr17550412pdb.3.1410183176183; Mon, 08 Sep 2014 06:32:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.6 with SMTP id q6ls1860806qgd.82.gmail; Mon, 08 Sep 2014 06:32:56 -0700 (PDT) X-Received: by 10.52.1.227 with SMTP id 3mr60960vdp.90.1410183176025; Mon, 08 Sep 2014 06:32:56 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id m1si1079598vda.49.2014.09.08.06.32.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Sep 2014 06:32:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id le20so1364099vcb.13 for ; Mon, 08 Sep 2014 06:32:55 -0700 (PDT) X-Received: by 10.220.190.134 with SMTP id di6mr745422vcb.43.1410183175805; Mon, 08 Sep 2014 06:32:55 -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.221.45.67 with SMTP id uj3csp134602vcb; Mon, 8 Sep 2014 06:32:55 -0700 (PDT) X-Received: by 10.70.133.200 with SMTP id pe8mr1560955pdb.40.1410183174852; Mon, 08 Sep 2014 06:32:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ni10si17992943pbc.51.2014.09.08.06.32.54 for ; Mon, 08 Sep 2014 06:32:54 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754032AbaIHNcw (ORCPT + 26 others); Mon, 8 Sep 2014 09:32:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51529 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752925AbaIHNcu (ORCPT ); Mon, 8 Sep 2014 09:32:50 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s88DWLkj007588 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Sep 2014 09:32:21 -0400 Received: from deneb.redhat.com (ovpn-113-116.phx2.redhat.com [10.3.113.116]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s88DWJud028040; Mon, 8 Sep 2014 09:32:20 -0400 From: Mark Salter To: Leif Lindholm Cc: Ard Biesheuvel , matt.fleming@intel.com, Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, LKML , Mark Salter Subject: [PATCH] efi/arm64: fix fdt-related memory reservation Date: Mon, 8 Sep 2014 09:31:42 -0400 Message-Id: <1410183102-6969-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Commit 86c8b27a01cf: "arm64: ignore DT memreserve entries when booting in UEFI mode prevents early_init_fdt_scan_reserved_mem() from being called for arm64 kernels booting via UEFI. This was done because the kernel will use the UEFI memory map to determine reserved memory regions. That approach has problems in that early_init_fdt_scan_reserved_mem() also reserves the FDT itself and any node-specific reserved memory. By chance of some kernel configs, the FDT may be overwritten before it can be unflattened and the kernel will fail to boot. More subtle problems will result if the FDT has node specific reserved memory which is not really reserved. This patch has the UEFI stub remove the memory reserve map entries from the FDT as it does with the memory nodes. This allows early_init_fdt_scan_reserved_mem() to be called unconditionally so that the other needed reservations are made. Signed-off-by: Mark Salter Acked-by: Ard Biesheuvel Acked-by: Mark Rutland --- arch/arm64/mm/init.c | 3 +-- drivers/firmware/efi/libstub/fdt.c | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 5472c24..a83061f 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -149,8 +149,7 @@ void __init arm64_memblock_init(void) memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start); #endif - if (!efi_enabled(EFI_MEMMAP)) - early_init_fdt_scan_reserved_mem(); + early_init_fdt_scan_reserved_mem(); /* 4GB maximum for 32-bit only capable devices */ if (IS_ENABLED(CONFIG_ZONE_DMA)) diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index a56bb35..723c7da 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c @@ -22,7 +22,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; + int node, prev, i, num_rsv; int status; u32 fdt_val32; u64 fdt_val64; @@ -73,6 +73,14 @@ efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, prev = node; } + /* + * Delete all memory reserve map entries. When booting via UEFI, + * kernel will use the UEFI memory map to find reserved regions. + */ + num_rsv = fdt_num_mem_rsv(fdt); + for (i = 0; i < num_rsv; i++) + fdt_del_mem_rsv(fdt, i); + node = fdt_subnode_offset(fdt, 0, "chosen"); if (node < 0) { node = fdt_add_subnode(fdt, 0, "chosen");