Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp573068ybh; Tue, 21 Jul 2020 02:34:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXsz47XcAN+7j8zKAvd2b1hnCqZqoTlAn8ZHXgHcri1OHelQvx22hH6+cyEhI5TfS8dQG3 X-Received: by 2002:a17:906:5909:: with SMTP id h9mr25494740ejq.501.1595324043669; Tue, 21 Jul 2020 02:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595324043; cv=none; d=google.com; s=arc-20160816; b=Gx4ASTduBOL6+NDYnnkhcFDSVb3G1eyFg6QpNUTeEz/fzv+ucQ9BskARGRtQnTQACK TTCscoJF7n1q7gBzT7ApK3RRLkEP8o1aoeM7T/fQavsNow6YT28bbVbtCNHwq/fXXf8U 2KJZp5GhHsLW5sskJyXanemyVw8ezVsd90ZLjwnziD9taS3l4fv0F6yt40WFVZVLSGr/ 7PwxPSlXhr5Pz0rknjmb43fn1mvw0I3YjKROY7BB4BSn8XcATK9B344rUEPcAZRdk+dU 0H4M6hSMYSHjUt1r5quN7ZP+eqEV+fqYipadSr9PqUn5p+uFwzxPeLWmLup1lsUAYB9K 409g== 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=R+EF85aNDdODINrCfjjd0Lfuv95jSgpJvxBVPXo7UEI=; b=WQ5V3/mEDX24d2aYr/TtJfUizf2QcavwsMjJkitWz7mpfd154Al6wHExVvxCx0pBg1 UDWKBqcEgvZuW+vY6Wo9j3v1eQ9qJKhKg4DAzLM9QQVl8/hF2iuYGUDhI08GGrcfDgp+ 5ZwcLfcDu3bCUu7KKDErTPRf1bvK53jI8a8lY6B1JaHQEriw+8joOOW6ACQHNXOpOLGh ns4nNoO+1l4YKhv5AYNZm+XEQjyA359ACBa52UfcbWE7M74yz7sY39/6LQQEaKLZS1an p6c2S06yL1PX57TCmUiVKD7g8s1BlSJAOeM/6b+qpRyUI8tab/SHQRTi9c4ntb9pbE3j Wcfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="yY/akW2D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h23si12179983ejd.485.2020.07.21.02.33.40; Tue, 21 Jul 2020 02:34:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="yY/akW2D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728908AbgGUJa4 (ORCPT + 99 others); Tue, 21 Jul 2020 05:30:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725984AbgGUJa4 (ORCPT ); Tue, 21 Jul 2020 05:30:56 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A23B9C061794 for ; Tue, 21 Jul 2020 02:30:55 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id y3so3135258wrl.4 for ; Tue, 21 Jul 2020 02:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=R+EF85aNDdODINrCfjjd0Lfuv95jSgpJvxBVPXo7UEI=; b=yY/akW2D9+GrY1oKN3c5+dEliD4OkQM7F6PBHq+jxAt2+MgNVNgHxD8r/+H4hPWZp7 C6QNv/0wFMcXxVoU3TCemQtIbqkOS+zrtNK1Y3W9/SUy1XdL4jbRdKft5mJ77z/BPakH TRk7m1nXqDlBfEq2paJClFRCVqFNLQp9Q5w6FvRmxQfD/BsJ8NskgIwBqJSC5msTA4Xp /dPdMrboPhqh06qZbYrGbe/LnpvGSNTJlrfRctFCk5uVc/hp7RpbjH7DcmtUpXQaiP6I Zghs3hCBJZfGnwUBK0nuRl6+I9AoSqXtCQRveCQ8KX9MH8VTc+oRbDCFJBxzrXW1ETJW qg9g== 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=R+EF85aNDdODINrCfjjd0Lfuv95jSgpJvxBVPXo7UEI=; b=NCHRErp0IZh840Dk/pMBZ+KLU2+xBWJfjFafyK+HBAHRUMjetT8KVrbw/pQJpWLlea DDYnkqZU1wMcEppaVXm+iloLaQNpS2jPDL3NXk/GepBk9uOARz5/3616olZg9PkvI84W 89/Zi6aIyAr7yqe0BUND1EGaPmghuaN7YipdhtWv4yRsUDRZwCltBqXlwBHYJMOP2WGr 16b8Ad0wQ16pMWapBMM/H4Hk+yYJrU0ON9+2P04+DKIm2irJUikch4bfCdD6d5EE4xuy PR5TfcUXXIawAV2ejo1dw8M5G1wxX4KLjDQaYs/Y9jCETHkgExA9XDAklxCldM6vV7Zv bWxQ== X-Gm-Message-State: AOAM531L9slzqJszHqzZhVOO1bDmXyCWZ6ZK8W5LFJo0rXB4SXwLQOLn 9wsMx7Dj26WsndTROpYx6nJiPgfkBmtnGW6lz7s73A== X-Received: by 2002:adf:de12:: with SMTP id b18mr27796440wrm.390.1595323854198; Tue, 21 Jul 2020 02:30:54 -0700 (PDT) MIME-Version: 1.0 References: <20200716234104.29049-1-atish.patra@wdc.com> <20200716234104.29049-2-atish.patra@wdc.com> In-Reply-To: From: Anup Patel Date: Tue, 21 Jul 2020 15:00:41 +0530 Message-ID: Subject: Re: [RFT PATCH v3 1/9] RISC-V: Move DT mapping outof fixmap To: Ard Biesheuvel Cc: Arnd Bergmann , Atish Patra , Atish Patra , "linux-kernel@vger.kernel.org" , Anup Patel , Greentime Hu , Kees Cook , linux-efi , linux-riscv , Mark Rutland , Masahiro Yamada , Mike Rapoport , Palmer Dabbelt , Paul Walmsley , Will Deacon , Zong Li , Heinrich Schuchardt , Linux ARM 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 On Tue, Jul 21, 2020 at 2:32 PM Ard Biesheuvel wrote: > > On Tue, 21 Jul 2020 at 11:57, Arnd Bergmann wrote: > > > > On Tue, Jul 21, 2020 at 6:18 AM Atish Patra wrote: > > > On Sat, Jul 18, 2020 at 2:24 AM Arnd Bergmann wrote: > > > > On Sat, Jul 18, 2020 at 3:05 AM Atish Patra wrote: > > > > > That's what the original code was doing. A fixmap entry was added to > > > > > map the original fdt > > > > > location to a virtual so that parse_dtb can be operated on a virtual > > > > > address. But we can't map > > > > > both FDT & early ioremap within a single PMD region( 2MB ). That's why > > > > > we removed the DT > > > > > mapping from the fixmap to .bss section. The other alternate option is > > > > > to increase the fixmap space to 4MB which seems more fragile. > > > > > > > > Could the original location just be part of the regular linear mapping of all > > > > RAM? > > > > > > No. Because we don't map the entire RAM until setup_vm_final(). > > > We need to parse DT before setup_vm_final() to get the memblocks and > > > reserved memory regions. > > > > Ok, I see how you create a direct mapping for the kernel image, plus > > the fixmap for the dtb in setup_vm(), and how moving the dtb into the > > kernel image simplifies that. > > > > I'm still wondering why you can't do the same kind of PGD mapping > > for the dtb that you do for the vmlinux, creating linear page table > > entries exactly for the location that holds the dtb, from dtb_pa to > > dtb_pa+((struct fdt_header*)dtb_pa)->totalsize. > > > > On arm64, we limit the size of the DT to 2MB, and reserve a pair of > PMD entries adjacent to the fixmap so we can map it r/o statically > using huge pages without using fixmap/early_ioremap slots. (Using a > pair of PMD entries allows the DT to appear at any alignment in > memory, given that PMD entries cover 2 MB each on 4k pages kernels) The arch/riscv is common for both RV32 and RV64. On RV32, we don't have PMD due to only two-levels in the page table. Although, I like the idea of two consecutive PMD mappings which are not part of FIXMAP. The RISC-V early page table is totally different from the final init_mm page table. I think we can do two consecutive PGD mappings in the early page table at lower addresses (quite below PAGE_OFFSET). I will play-around with this idea. Regards, Anup