Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2420324ybm; Thu, 23 May 2019 17:06:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpH0F60WOG4ebhZOWv3byy38UWZehGxzl6nCxaCj4cHDtrufG7rGym/t8ER6U2o9zQyf/t X-Received: by 2002:a17:902:5989:: with SMTP id p9mr21575560pli.179.1558656372358; Thu, 23 May 2019 17:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558656372; cv=none; d=google.com; s=arc-20160816; b=SGoRdoxNbEO3muDzqLdbAgt2UaMzFKcD+R+vrlwqaYG7Rss68RutaiwV83wLnpPHcG xLb99flxnz+EVvPHJhT3EXot+BOi1K9DKG5J13YQ+MseiLVN04I/FRmqkxjMWSg3/LAS YozjI4Eve+v4jHkLFz+VKxUjcDeR1NO+tq8QDViUylP/jfy29gtL4Y0l8TOuauN8OC4E BAv/N/Cnh0fr1CUqpKSJwtoQ8aOHOuapd3smhMJOwSJooEj0otitxQX6ScIsmoxJYhMN 4YQH2cq0xzXETik51e7mQenwGEJXY5AvnfGCMx0EH/udcoAMoZXezjuJc1LJweKTR3XT ww4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=rEVWZ6CY2T1sOfRBqu5yo6RqvdsQIs5DONP6SvlW0AM=; b=h5rQ7mFsyB3cjjWWC3eyDBHgHDz/PlxjCn164UVgeXBOHOZgXU+fH9PmNz/05OZbxt G3SU+yf3hv2zmU41OR04LGxnRKAuJTqA2ZQ4w/3f1wy/i7u7Q1SI3i4CxbMcvYMcgWjc 93ensSkTaP2nZgED3QD6L7GvtLmdp60gemZO+Th+yxcPudp1yPckhNSKOvBnrJOqE5e6 KaJUBNZY7dYWwGWgwwnYONxmeunL41Ig1WmhMQ6ooq0lUJhjJNvsPlrp/a3ziTvUOqvo Y/u3vbjLnfzSjlLqXLObAOMy30V55bfRvXmsv4Fn7VHqqwqiU4x0dCAWuQEvMyaXiXQq OBJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=A5bq+DlV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w207si1631403pff.69.2019.05.23.17.05.50; Thu, 23 May 2019 17:06:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=A5bq+DlV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388561AbfEXAEW (ORCPT + 99 others); Thu, 23 May 2019 20:04:22 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35950 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388423AbfEXAEV (ORCPT ); Thu, 23 May 2019 20:04:21 -0400 Received: by mail-pl1-f196.google.com with SMTP id d21so3386013plr.3 for ; Thu, 23 May 2019 17:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:mime-version:content-transfer-encoding:in-reply-to :references:subject:from:cc:to:user-agent:date; bh=rEVWZ6CY2T1sOfRBqu5yo6RqvdsQIs5DONP6SvlW0AM=; b=A5bq+DlVBxOWKQFEMlCo85nduYntCXDn0IbtZJHJoDJIP/A9P/lc9kAhjahRhOg6aB fH7uFR5pcQhJ3sY6aV2vpt2VukMXrjAJwGlDtqbrsVuRTUpcapahrz0Ty6z7pFy48Fld RS2H0xeriUHh7VouuZMHvoEl+1YhktdsoZ1nI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:in-reply-to:references:subject:from:cc:to :user-agent:date; bh=rEVWZ6CY2T1sOfRBqu5yo6RqvdsQIs5DONP6SvlW0AM=; b=uELP3Wqn2EadEbLC3pZrZlRhWSLlwywlaSWfuqT/XE3G8g7phgO7Nk6f75uKrE+qmC EVR/1Kh1CbRf3k36UhX1XySXiLcfl+vJiQWhwWSuwuS3W0GNlFc0OY6swE+MIz0Lu/gA 39ikgC7ztXwK4jHy3287K6lBP1R8WL/thGPrxh2eZzMIve3pzSePjv/HB1eipTt+tDdd n+01dY2WQJjFR3Id63hmt+KHLbv18UvPOchkXh5aWhPAxwq+kUnCxoZCdLYyVxq1Tdz0 l5BWBgTSWWk1gFv0dLYbHmM/1aYCbwJaYJ+l5uQDP0B/d3oua8NxP84RGDlUXvig/z1x KsrQ== X-Gm-Message-State: APjAAAWsH0Z29Pm3Zc5Xen+8FgViq3F4KHQzVFYnGniMBY8f0I9bRqvw mMf/BlXvnHdSYQx3hveGrUSV3g== X-Received: by 2002:a17:902:8c8f:: with SMTP id t15mr46446795plo.87.1558656260216; Thu, 23 May 2019 17:04:20 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id s12sm425435pji.30.2019.05.23.17.04.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 May 2019 17:04:19 -0700 (PDT) Message-ID: <5ce73503.1c69fb81.5f889.1d84@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20190519160446.320-1-hsinyi@chromium.org> References: <20190519160446.320-1-hsinyi@chromium.org> Subject: Re: [PATCH v4 1/3] amr64: map FDT as RW for early_init_dt_scan() From: Stephen Boyd Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Rowand , Catalin Marinas , Will Deacon , Andrew Morton , Mike Rapoport , Ard Biesheuvel , Miles Chen , Hsin-Yi Wang , James Morse , Andrew Murray , Mark Rutland , Jun Yao , Yu Zhao , Robin Murphy , Laura Abbott , Kees Cook To: Hsin-Yi Wang , linux-arm-kernel@lists.infradead.org User-Agent: alot/0.8.1 Date: Thu, 23 May 2019 17:04:18 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Hsin-Yi Wang (2019-05-19 09:04:44) > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index a170c6369a68..29648e86f7e5 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -940,12 +940,12 @@ void *__init __fixmap_remap_fdt(phys_addr_t dt_phys= , int *size, pgprot_t prot) > return dt_virt; > } > =20 > -void *__init fixmap_remap_fdt(phys_addr_t dt_phys) > +void *__init fixmap_remap_fdt(phys_addr_t dt_phys, pgprot_t prot) > { > void *dt_virt; > int size; > =20 > - dt_virt =3D __fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL_RO); > + dt_virt =3D __fixmap_remap_fdt(dt_phys, &size, prot); > if (!dt_virt) > return NULL; > =20 Sorry, I'm still confused why we want to call memblock_reserve() again. Why not avoid it? diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h index 67ef25d037ea..d0d9de9da5c1 100644 --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -137,7 +137,7 @@ extern void init_mem_pgprot(void); extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, unsigned long virt, phys_addr_t size, pgprot_t prot, bool page_mappings_only); -extern void *fixmap_remap_fdt(phys_addr_t dt_phys); +extern void *__fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t p= rot); extern void mark_linear_text_alias_ro(void); =20 #define INIT_MM_CONTEXT(name) \ diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c index b09b6f75f759..0701c2cf1534 100644 --- a/arch/arm64/kernel/kaslr.c +++ b/arch/arm64/kernel/kaslr.c @@ -65,9 +65,6 @@ static __init const u8 *kaslr_get_cmdline(void *fdt) return default_cmdline; } =20 -extern void *__init __fixmap_remap_fdt(phys_addr_t dt_phys, int *size, - pgprot_t prot); - /* * This routine will be executed with the kernel mapped at its default vir= tual * address, and if it returns successfully, the kernel will be remapped, a= nd diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 413d566405d1..3e97354566ff 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -181,9 +181,13 @@ static void __init smp_build_mpidr_hash(void) =20 static void __init setup_machine_fdt(phys_addr_t dt_phys) { - void *dt_virt =3D fixmap_remap_fdt(dt_phys); + int size; + void *dt_virt =3D __fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL); const char *name; =20 + if (dt_virt) + memblock_reserve(dt_phys, size); + if (!dt_virt || !early_init_dt_scan(dt_virt)) { pr_crit("\n" "Error: invalid device tree blob at physical address %pa (virtual addre= ss 0x%p)\n" @@ -195,6 +199,9 @@ static void __init setup_machine_fdt(phys_addr_t dt_phy= s) cpu_relax(); } =20 + /* Early fixups are done, map the FDT as read-only now */ + __fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL_RO); + name =3D of_flat_dt_get_machine_name(); if (!name) return; diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a170c6369a68..ddf6086cd9dd 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -940,19 +940,6 @@ void *__init __fixmap_remap_fdt(phys_addr_t dt_phys, i= nt *size, pgprot_t prot) return dt_virt; } =20 -void *__init fixmap_remap_fdt(phys_addr_t dt_phys) -{ - void *dt_virt; - int size; - - dt_virt =3D __fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL_RO); - if (!dt_virt) - return NULL; - - memblock_reserve(dt_phys, size); - return dt_virt; -} - int __init arch_ioremap_pud_supported(void) { /* only 4k granule supports level 1 block mappings */