Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4462881yba; Sun, 19 May 2019 20:18:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwv5i1y3X2GFbnRu9D4zdzLWUCaxwH3xp8SsEXp+sLVAvivEVrvH8v4PzY5gMzBYNMOeNQk X-Received: by 2002:a17:902:2e81:: with SMTP id r1mr57393325plb.0.1558322321190; Sun, 19 May 2019 20:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558322321; cv=none; d=google.com; s=arc-20160816; b=eqFAO9eCRrj+UZ4dLfEMEShKzozw1inJyqwFVKiRX+F/uwdrjD1aKurHQFR0BS6eYe 0Fa2/eFIQLYlIsCTUAuBv1ptm2zNeiBJf/ATlEmQwu6douLgcLPLBKMsi5/JYtMVrQME W10n2AyIbeerkDvKkBFWVI14LN1uizztWz/SOjkCc+kEQxYH0b5iCnoG2BCgtRjFAAkS KgthbK6lT09ZgAmcxxdQzklOU9oY+C+iYMOGP1/IucUKD+IjtCLEifN/PF/4f6BypYXr K+L0o6n8wMMUTESAMkRnDpI+qhDJju2F1v9iM7vxwFEvFwjf0ulqcYmdcjDHHQDt8OEQ DPvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=doV3v4rh7HRUjJmLbCEHgl+MmgHA5lzEGEyVEOx1UDY=; b=FQt2qWvtfIJvf5QJmvQrtfFiAEps7NcZG8g1O5HbpdmgXNqSeHD1C4c45glih3liTG iI1asMa2D5AAFtDyjmR/kT+18WQLfNX4ipOnzJsUluuFb2JhwjF9GgLWZMGF9C0HJgMo QvY+v06ZjdhZ2Sc1wD0u1ZeC26C1zWtAAe2zU4+nuB2QuYQsJKNJlB2ivVRoFoN2Bte7 xWu+ATimdh1+Xa5TCLveRdj7bxPoVYiiDPDcV3mJfmaGS7RlmaoorjS+MfOsxJaCmIww Pbokub0z28vvlUVcpo6Hqg5JOd5TGdCk0X2NYkzCZRXiBD57G9MbBmNjJ1VMEoZDzbc1 MeKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HLIYYQBC; 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 192si2651096pfu.177.2019.05.19.20.18.26; Sun, 19 May 2019 20:18:41 -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=HLIYYQBC; 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 S1729422AbfESX6B (ORCPT + 99 others); Sun, 19 May 2019 19:58:01 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:44621 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728973AbfESX6A (ORCPT ); Sun, 19 May 2019 19:58:00 -0400 Received: by mail-qk1-f193.google.com with SMTP id w25so7755091qkj.11 for ; Sun, 19 May 2019 16:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=doV3v4rh7HRUjJmLbCEHgl+MmgHA5lzEGEyVEOx1UDY=; b=HLIYYQBC1OSzB/VEFY3lneCtGDjIBYUYBOWMow+F6FQWpZbr05UH83MoQlJX3cvlF4 LN1OOVQ7Cfe43RWifImVn1akors29h1C1fVZWa+Iw+C5UgIAItQgUVmgrc9nJDv+4hHq HCx2sicJNasbOPfqz1nAvp4HxTIwyNoTIGzcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=doV3v4rh7HRUjJmLbCEHgl+MmgHA5lzEGEyVEOx1UDY=; b=MnmegRupndRcfuvG8GNlpmFh2UZYPerQopAFOLAhwzSjfajI9lFLXFvnTTPmmQ+zgf Mbsje2as1S352QanY18N8C87ymmxklJIGaQKqobR++x1A2mSLY5jkGBZp/Qz6YHstWxQ jvsK9xHXioJQGQ7gUZM3hGSE8l14PjKfJlsDr4E91EF0FO7jMrefSXTIkv6CPDIyZltX UDs/J1HVtRxgv83iYm0R2bVQgniDATBgbIqw+2ljvkuzV/uZf8198BsR0kblT/QseWTB cF+Dqn4tuaQzcvrgcgzykl1MiNcCvkiJq3NkBURjj7vU4Pu1qe29YWonY70nTELQi7gQ IH1w== X-Gm-Message-State: APjAAAUjrnrWoKZ06Bo/F+MqmHBFp1h9PgnkLfJR1TqLjubE1cfdzfxJ dsqBy6c7972fbsWG5XCENMyxyU0p1d8j9QtZzOClVB47 X-Received: by 2002:a37:952:: with SMTP id 79mr52690407qkj.201.1558310279581; Sun, 19 May 2019 16:57:59 -0700 (PDT) MIME-Version: 1.0 References: <20190519160446.320-1-hsinyi@chromium.org> In-Reply-To: <20190519160446.320-1-hsinyi@chromium.org> From: Nicolas Boichat Date: Mon, 20 May 2019 07:57:48 +0800 Message-ID: Subject: Re: [PATCH v4 1/3] amr64: map FDT as RW for early_init_dt_scan() To: Hsin-Yi Wang Cc: linux-arm Mailing List , Rob Herring , devicetree@vger.kernel.org, lkml , Frank Rowand , Catalin Marinas , Will Deacon , Andrew Morton , Mike Rapoport , Ard Biesheuvel , Miles Chen , James Morse , Andrew Murray , Mark Rutland , Jun Yao , Yu Zhao , Robin Murphy , Laura Abbott , Stephen Boyd , Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org s/amr64/arm64/ in the commit title. On Mon, May 20, 2019 at 1:09 AM Hsin-Yi Wang wrote: > > Currently in arm64, FDT is mapped to RO before it's passed to > early_init_dt_scan(). However, there might be some code that needs > to modify FDT during init. I'd give a specific example (i.e. mention the next commit that introduces rng-seed). > Map FDT to RW until unflatten DT. > > Signed-off-by: Hsin-Yi Wang > --- > change log v2->v4: > * v3 abandoned > * add an arg pgprot_t to fixmap_remap_fdt() > --- > arch/arm64/include/asm/mmu.h | 2 +- > arch/arm64/kernel/setup.c | 5 ++++- > arch/arm64/mm/mmu.c | 4 ++-- > 3 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h > index 67ef25d037ea..4499cb00ece7 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, pgprot_t prot); > extern void mark_linear_text_alias_ro(void); > > #define INIT_MM_CONTEXT(name) \ > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > index 413d566405d1..064df3de1d14 100644 > --- a/arch/arm64/kernel/setup.c > +++ b/arch/arm64/kernel/setup.c > @@ -181,7 +181,7 @@ 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); > + void *dt_virt = fixmap_remap_fdt(dt_phys, PAGE_KERNEL); > const char *name; > > if (!dt_virt || !early_init_dt_scan(dt_virt)) { > @@ -320,6 +320,9 @@ void __init setup_arch(char **cmdline_p) > /* Parse the ACPI tables for possible boot-time configuration */ > acpi_boot_table_init(); > > + /* remap fdt to RO */ > + fixmap_remap_fdt(__fdt_pointer, PAGE_KERNEL_RO); > + > if (acpi_disabled) > unflatten_device_tree(); > > 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; > > -- > 2.20.1 >