Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1461579ybi; Sat, 25 May 2019 02:32:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxctZ3HvDIIRiWrbcbjxHyVkuIvPjwO1wBoL6uF2K/d2UGWdufwQJ0lavR3bKZQoVMxZ1+h X-Received: by 2002:a17:902:2d03:: with SMTP id o3mr76232910plb.309.1558776749942; Sat, 25 May 2019 02:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558776749; cv=none; d=google.com; s=arc-20160816; b=oPYDRGL2tzbgkAKiFfI/XwQERlmgX+z9OfhXJv1mI5F2KVln5GaUAInEHwcY+5xPRi OhjuNWCVEQyzy07by8rQtynI9f2jcan26/v/ylSGN33sVzLAGHuUfrynuLHS6u+iCFT6 HGBXJIlFcHDgghv953XHzE/u51JuIJX5OyIwRVCaDbdolHFdNufpVSSCINZYJH2syM0E 9dNVf4/YDBaMQvxim+ubWJ4nrwgHgCshmvaW1Xa0m+81+JYHtNqAiJ4Tsosmzr3cX/PG Ybgwo/kmUUe+rIvXH8PINn0BgWtB3GRp17m6dAZbLe1KZQRr1eO7FCBpdXy2EuZhzNRK NLRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=kqQ277OPjIgeX49IUZC2aKcrSO/1CgDoVYaNX54zlSo=; b=S6qjddVWAxcgI/wRJE9l0/oMDKo/H3i7DC+PTpvvbsPH6FLgqjpPvZbyAsHbMLI1S5 7fASlyqs7qPo1cc226EF0nX4jOONTVAJQnTT61XUSbJIKLrSmxeT23hNeUjJ5S9xffP7 nhkEk5w9QnhiJOw7bMnzdC8cN004broBS5LmWOwXWL5Ctv0YXrXkqPapdmbyVMQbLmCY AJyjaGccLOrJSsy4yJM5xvmWP4rMCCo/CPsg9vZWrdWlMRc4Tq7PkgYAcEIR+i4ke0IM 9xupbk1Ybn0vQZgoN7Qmggw9G7QX+wlwpapMbXqeVfg/1/2Lch/jcpPaxG9GPNI6UQFF t/mA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si7954950pfa.67.2019.05.25.02.32.12; Sat, 25 May 2019 02:32:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726679AbfEYJbD (ORCPT + 99 others); Sat, 25 May 2019 05:31:03 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41242 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbfEYJbD (ORCPT ); Sat, 25 May 2019 05:31:03 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4P9SB6e015961 for ; Sat, 25 May 2019 05:31:02 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2sq1sj9yyf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 25 May 2019 05:31:01 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 25 May 2019 10:30:59 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sat, 25 May 2019 10:30:53 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4P9UqPT61014152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 25 May 2019 09:30:52 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7C6611C054; Sat, 25 May 2019 09:30:52 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0478411C04A; Sat, 25 May 2019 09:30:51 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.205.112]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sat, 25 May 2019 09:30:50 +0000 (GMT) Date: Sat, 25 May 2019 12:30:49 +0300 From: Mike Rapoport To: Stephen Boyd Cc: Hsin-Yi Wang , linux-arm-kernel@lists.infradead.org, Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Rowand , Catalin Marinas , Will Deacon , Andrew Morton , Ard Biesheuvel , Miles Chen , James Morse , Andrew Murray , Mark Rutland , Jun Yao , Yu Zhao , Robin Murphy , Laura Abbott , Kees Cook Subject: Re: [PATCH v4 1/3] amr64: map FDT as RW for early_init_dt_scan() References: <20190519160446.320-1-hsinyi@chromium.org> <5ce73503.1c69fb81.5f889.1d84@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ce73503.1c69fb81.5f889.1d84@mx.google.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19052509-0028-0000-0000-000003714C55 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19052509-0029-0000-0000-00002431045F Message-Id: <20190525093048.GB31026@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-25_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905250067 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 23, 2019 at 05:04:18PM -0700, Stephen Boyd wrote: > 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; > > } > > > > -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; > > > > - dt_virt = __fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL_RO); > > + dt_virt = __fixmap_remap_fdt(dt_phys, &size, prot); > > if (!dt_virt) > > return NULL; > > > > 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 prot); I'd drop '__' prefix from __fixmap_remap_fdt is it's the only function to remain. Otherwise makes perfect sense. > extern void mark_linear_text_alias_ro(void); > > #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; > } > > -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 virtual > * address, and if it returns successfully, the kernel will be remapped, and > 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) > > static void __init setup_machine_fdt(phys_addr_t dt_phys) > { > - void *dt_virt = fixmap_remap_fdt(dt_phys); > + int size; > + void *dt_virt = __fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL); > const char *name; > > + 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 address 0x%p)\n" > @@ -195,6 +199,9 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys) > cpu_relax(); > } > > + /* Early fixups are done, map the FDT as read-only now */ > + __fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL_RO); > + > name = 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, int *size, pgprot_t prot) > return dt_virt; > } > > -void *__init fixmap_remap_fdt(phys_addr_t dt_phys) > -{ > - void *dt_virt; > - int size; > - > - dt_virt = __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 */ > -- Sincerely yours, Mike.