From patchwork Tue Sep 16 00:47:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 37438 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AD924203E6 for ; Tue, 16 Sep 2014 02:34:31 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id u57sf2709075wes.3 for ; Mon, 15 Sep 2014 19:34:30 -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:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=2+m3XRzwFdTSDlfdLqQiHZ4aKQv7UfSZgw+u0vRlcVc=; b=Il2XbqJDIsfUZWQi7osATsJZzHcV5RWdSbGc0/BFHKWjAF0gjh+J98KgKCk8Qxk3pt /zuNKyShB+b0AKiU7b6u3i3QolykMFFKWYxo3z2JQtEe4nFrEl7+Zt1y+eYmaZ5SnAIa niVBXF29bnkgNHXEVU0I0wCnNDHVGWqj6b35G5o7at9WKi4Ov7TXjGBojyu5Ud8yTZcb 0eJWXten/xfCQA5DI9nkM3Ts8GYtyslFQoFTEpCwsD3CmanwdAGXqKQhIUVcve5HBmes h6AR9o8Bj9pnbfP511a+t6twH3eoNdSSYLh2ORvZIScoeXUolEVdauVGZrRim1lZupf4 5VCw== X-Gm-Message-State: ALoCoQkqp1mGZd4Ec+TTvB4bSVcHXeul/v5ceGpGm2AiGg6hbspZy0pcC1mXMusYtbBXBF3E/MwZ X-Received: by 10.112.188.136 with SMTP id ga8mr7824574lbc.8.1410834870848; Mon, 15 Sep 2014 19:34:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.132 with SMTP id ay4ls415111lab.46.gmail; Mon, 15 Sep 2014 19:34:30 -0700 (PDT) X-Received: by 10.152.25.170 with SMTP id d10mr32150854lag.37.1410834870556; Mon, 15 Sep 2014 19:34:30 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com [209.85.215.45]) by mx.google.com with ESMTPS id j15si21847164lbg.30.2014.09.15.19.34.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Sep 2014 19:34:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id b17so5939461lan.18 for ; Mon, 15 Sep 2014 19:34:30 -0700 (PDT) X-Received: by 10.152.204.231 with SMTP id lb7mr30805030lac.44.1410834870478; Mon, 15 Sep 2014 19:34:30 -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.130.169 with SMTP id of9csp318887lbb; Mon, 15 Sep 2014 19:34:29 -0700 (PDT) X-Received: by 10.68.69.38 with SMTP id b6mr39782550pbu.70.1410834868880; Mon, 15 Sep 2014 19:34:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bl7si26487693pdb.165.2014.09.15.19.34.28 for ; Mon, 15 Sep 2014 19:34:28 -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 S1754348AbaIPCd7 (ORCPT + 27 others); Mon, 15 Sep 2014 22:33:59 -0400 Received: from mail-by2on0127.outbound.protection.outlook.com ([207.46.100.127]:13440 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753907AbaIPCdi (ORCPT ); Mon, 15 Sep 2014 22:33:38 -0400 Received: from BY1PR0201CA0038.namprd02.prod.outlook.com (25.160.191.176) by BY2PR02MB490.namprd02.prod.outlook.com (10.141.145.14) with Microsoft SMTP Server (TLS) id 15.0.1024.12; Tue, 16 Sep 2014 02:33:36 +0000 Received: from BY2FFO11FD057.protection.gbl (2a01:111:f400:7c0c::164) by BY1PR0201CA0038.outlook.office365.com (2a01:111:e400:4814::48) with Microsoft SMTP Server (TLS) id 15.0.1029.13 via Frontend Transport; Tue, 16 Sep 2014 02:33:36 +0000 Received: from atltwp01.amd.com (165.204.84.221) by BY2FFO11FD057.mail.protection.outlook.com (10.1.15.185) with Microsoft SMTP Server id 15.0.1019.14 via Frontend Transport; Tue, 16 Sep 2014 02:33:34 +0000 X-WSS-ID: 0NBZ33W-07-F1R-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2A379CAE7EF; Mon, 15 Sep 2014 21:33:31 -0500 (CDT) Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 15 Sep 2014 21:33:40 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.195.1; Mon, 15 Sep 2014 22:33:31 -0400 From: To: , , , CC: , , , , , , , , , , , , Mark Salter Subject: [PATCH 3/4] efi/arm64: fix fdt-related memory reservation Date: Mon, 15 Sep 2014 19:47:25 -0500 Message-ID: <1410828446-28502-4-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1410828446-28502-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1410828446-28502-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(199003)(189002)(104166001)(99396002)(89996001)(62966002)(101416001)(20776003)(4396001)(85306004)(33646002)(85852003)(88136002)(105586002)(102836001)(47776003)(48376002)(46102003)(80022003)(74502003)(74662003)(79102003)(77982003)(53416004)(81342003)(84676001)(81542003)(87286001)(87936001)(92566001)(92726001)(44976005)(77156001)(77096002)(50226001)(21056001)(76482001)(2201001)(86152002)(31966008)(90102001)(76176999)(229853001)(36756003)(83072002)(86362001)(93916002)(50986999)(106466001)(83322001)(19580395003)(107046002)(97736003)(68736004)(19580405001)(95666004)(2101003); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR02MB490; H:atltwp01.amd.com; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 03361FCC43 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-OriginatorOrg: amd4.onmicrosoft.com 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: suravee.suthikulpanit@amd.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.215.45 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: , From: Mark Salter 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 --- 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..c846a96 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, 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); + while (num_rsv-- > 0) + fdt_del_mem_rsv(fdt, num_rsv); + node = fdt_subnode_offset(fdt, 0, "chosen"); if (node < 0) { node = fdt_add_subnode(fdt, 0, "chosen");