Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4079302yba; Sun, 19 May 2019 10:11:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFFQ4zFj90u9a/N8ps3vTeXlyL339IhuDVQVsiniArZkWvfYHJnrlfOGHElrK5azUmb6zM X-Received: by 2002:a17:902:bf4a:: with SMTP id u10mr50430491pls.56.1558285896220; Sun, 19 May 2019 10:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558285896; cv=none; d=google.com; s=arc-20160816; b=rGL+asg0rixkN2iQ0KqqRqS0ARpx1c0PC0cQJL14Ns57yNqKQj97THuPG6QGqQbsGt kIoW/Emv+jYR7AmcTrI3h++L6uQ7DFFeqKM13GhPIL6vR7OsZz0Mw8AbJsj8PMvFrlKf lQ78X5ifVhCRumohhvVeSIoiaCHF0H89GS52NyHnKJREVL1w1TjFXrd1jwYUWXtM4NzO sB5AXX0uRfE2retSmQX1LWIWu2IwYC6kG/FP/gh9E0Wm/V/b544w7E+R3MhUSb7ABPP/ iv0Vz9A7kmRWA+0eIfZnajxcIr7YtBtl9wonWoHkF73PbpUYDUaAWa1jYD3DN5u1jRyd Wd5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HjgKgNWvkrWu2AB4Hfm3UsbNqpkTfiMRDxIt6YpDrD8=; b=Pb/LIbk7FapDT2dzgrOkif9bf8SFxAUtgJbKzrA93A45Qln7+OIZrOq1AB4xgp5SQa ro5UAIoGXZxuwEXhxi9wBwz1B7YNzjYWx5MO2ABp/3PnV8W6igpxuUm4z4rFoNomuFu2 u/2MwA8PW/qKirc9PuknjpOIn5VphHIOFaAevjp5b/CC9dbAhetu4t4HNjihi2yY1e7D KK/n1Jj9J5ZwpAeuKIn4R/cca7rkuCk9J/x3TAS5IMuK06DQ/4KyjdrSYkrL7isjTjcO nzwJm2+DOVRRAdXSiKSyC18f8UEDUYbH25PxjI8JqRXGxC/l7YSG7sswXaNvwxuEWkc8 +vDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=F1SPpDoL; 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 205si15996883pgb.424.2019.05.19.10.11.21; Sun, 19 May 2019 10:11:36 -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=F1SPpDoL; 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 S1726914AbfESRJz (ORCPT + 99 others); Sun, 19 May 2019 13:09:55 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33025 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725766AbfESRJy (ORCPT ); Sun, 19 May 2019 13:09:54 -0400 Received: by mail-pf1-f196.google.com with SMTP id z28so6065477pfk.0 for ; Sun, 19 May 2019 10:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HjgKgNWvkrWu2AB4Hfm3UsbNqpkTfiMRDxIt6YpDrD8=; b=F1SPpDoL5/a/tOtnEuMPcZHUmxrlYpCW55VLRABVi8Ktcj+pFOspwPpb/QdIdtJBsz 41Nz2EnmkcnqlqMJ4FH9DYTW9qOWF3B9mwhUR4kc12EXddRoh1xcNY+hvWUgG0kVZaSO nmtAnQFNNwpNY2cb4wM/TTE7HA6icohq7g9rs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HjgKgNWvkrWu2AB4Hfm3UsbNqpkTfiMRDxIt6YpDrD8=; b=b0E10A+yaAAja9t6iDX5/7rI4ZgJTW9zb7YvojtEjXH5nZVl+P3jF21UOAP6z3VXE7 WK7DYLEIfOUrjIWUZLoW5ljAX0eF3JYWKEYAcr7vOpuxM8gpARoXGYS8olxfsBW5vYiH IImr3w/z7qHT7uR9d2sKd62yb/O98pVYlN5x3clIsKAllYZj77EZm/B8kBZXfi3EznAq n46bPH2xPF1YiS03M54I2h+1v/D6XUEvUx/YWFG9wcDOBrrIbfWLR7lnbOjktarLQrow rt2oUzo3ZvGArRI6DRnh52tNlCKPfYIgereu+DU58lmARZKcLSKJFuhkbMVQYpU9OQyt BYbA== X-Gm-Message-State: APjAAAVP01C6Rr8nM37DRusHrF1HssUNzE5c2kDd7jBuwDAyPw+T5CSG M2MWVvQfU6VGRVjOcMjHECQ8ew== X-Received: by 2002:a62:e10f:: with SMTP id q15mr74698143pfh.56.1558281904958; Sun, 19 May 2019 09:05:04 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id b23sm17547007pfi.6.2019.05.19.09.05.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 May 2019 09:05:04 -0700 (PDT) From: Hsin-Yi Wang To: linux-arm-kernel@lists.infradead.org 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 , Stephen Boyd , Kees Cook Subject: [PATCH v4 1/3] amr64: map FDT as RW for early_init_dt_scan() Date: Mon, 20 May 2019 00:04:44 +0800 Message-Id: <20190519160446.320-1-hsinyi@chromium.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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