Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp642023ybm; Tue, 21 May 2019 00:40:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxpqD5DeWD4VTyu7S8VMDOZ4nKCPZcrYt8PknCqZkWSGJZ6guKgWs3pzWjUb0YkFPZi3bt X-Received: by 2002:a17:902:6b:: with SMTP id 98mr80825439pla.271.1558424410313; Tue, 21 May 2019 00:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558424410; cv=none; d=google.com; s=arc-20160816; b=OrrV53LSz8b/ceWxCgSxIZHrh4zge1WsjqZdvuBtX2zXVrscYInvLITNheF7F7rpB7 MD+GSdE2bRk+U4c0lQ7h4V8V23eFfPSG1Hc118rU3FVB+ZP8JHjxdqrcENjR/ebhJYbf 4QE4eXsyVjeMKKcQ3v8ExcMA2JmzAxgMaGCn319iySHmz7W3qPQaPKEILgWxS56l8C58 gahLdIX06cQxQnk59zRc5f4RbsveP+FHjcs+bdyzh29o96ud3ZoM8zIRTuL/9WYizw/1 zHq7dVmt7MbuX3PudGsaOquT2zO/v/m9dKpJgZ9G6rIhrvx8Uzst8WGKD6lZvD1ckXxc ljGQ== 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=Hyv8dbu1hXdVe8oH/C/wgPhiFce8VkAWKoNE8lVkSkE=; b=Ey9T11fTuPaAJKfCaw2XC4g1IYe0JPuC3O0Hf+nX/hV9Zlrv+Js9B81LdXsmUp+0xK Ig5apTrH1yNSeI4Tg6rbyF3FJWxvI830PvUmWZocs0K6kpZEr081cVznBdlaCCT9VxbZ QJK1d8+iMpJRvxxgoX8W/MGJGIGpic0zWdrlO8O/SLguDEqkx/NWlYp36QtK6WmSZ+PE mPCoPhsVrgy+eMMCVGmD/ij4UX0NKJeTBPzFLqrOnBe02+A+4/9WVwP9yJ5hV9GVXg8w MQ3wA7NUTbFTPyXTKZiVMU14I8fSCU1lU6JSMiA1f0PKNg2zpWNsXzFSZYKooaPeGeYc wpDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=2JxvFy0Z; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si16979547pla.406.2019.05.21.00.39.54; Tue, 21 May 2019 00:40:10 -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=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=2JxvFy0Z; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbfEUHi2 (ORCPT + 99 others); Tue, 21 May 2019 03:38:28 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:32966 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726006AbfEUHi1 (ORCPT ); Tue, 21 May 2019 03:38:27 -0400 Received: by mail-wm1-f65.google.com with SMTP id c66so1646332wme.0 for ; Tue, 21 May 2019 00:38:26 -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=Hyv8dbu1hXdVe8oH/C/wgPhiFce8VkAWKoNE8lVkSkE=; b=2JxvFy0ZoOzBLDEIiB+zZywTTKxMZm8uWiW4+G2QZV9sw9JxK1R9VdWTIXtCLg1n+w nAMaeaocUuXeeHDF2xPoj/C9FWwLpOI9ywmD7LiOJ8OwG7c//6QVdfNtg74bHeM1R7Pe v1xEHkVaQqBDCGJYNl2QDNL7qqG4if2mvXLPT2ruJWXyyVHUmdIkZTzv/E9hv+0qZsLW GCHuhRGIi531rD0AN1hToSSqWuBHrEBXJDvbP+BqsaqNMuk6GH3kbjyiXVR5TebJRHQr 7mMA4U1Ld45CAI226Na4YMcm2/qxMDEqEQZO6yLrbeyvnxJ6zlaxyo/zYkK/RDdPqrbj oWCg== 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=Hyv8dbu1hXdVe8oH/C/wgPhiFce8VkAWKoNE8lVkSkE=; b=E0AdVnJs9F/Z5ePxnsZm2zm7gwEt+E4l4aOgnXeeq3aHL9gezB3lMaugDHW0epOEYZ 5gKY9k4rOrYvvLraxHnmRzPUPQPZQFDXKd27RbcV4sfiAP8WrBwNlYQLgV/GAmP4b6SN joO4LW9uIl1JEHs+pIgZLESY76hGKNkJrCdKJjSnfK0F99mlkABRzd79kOr3FbnKMyoD /mY3Hjg1NbrdrzRfjFkDllsLCPa9yVWb/yOvfEd1o3Dk7aZyS4qUARrf4M5QlWh+DNd8 WcAYPso7LJv/e4yawHd6b67kkyINR7m/LdCU8rff3DKAH+ZBchaXIJdW5NdS0oOlJ8Iz 5Adg== X-Gm-Message-State: APjAAAXkAwZTvZbdiAH9TCwiX8tDKQmobcgB0yE2IA1LPbEjiVSf+u/C GNLA87BaP3Fdx1zkORxAuasExCmx5LxcAJS4FwqAUg== X-Received: by 2002:a1c:eb0c:: with SMTP id j12mr2117204wmh.55.1558424305961; Tue, 21 May 2019 00:38:25 -0700 (PDT) MIME-Version: 1.0 References: <20190502050206.23373-1-anup.patel@wdc.com> <20190502050206.23373-3-anup.patel@wdc.com> <20190520114352.GA5372@infradead.org> In-Reply-To: <20190520114352.GA5372@infradead.org> From: Anup Patel Date: Tue, 21 May 2019 13:08:14 +0530 Message-ID: Subject: Re: [PATCH v4 2/2] RISC-V: Setup initial page tables in two stages To: Christoph Hellwig Cc: Anup Patel , Palmer Dabbelt , Albert Ou , "linux-kernel@vger.kernel.org" , Mike Rapoport , Atish Patra , Paul Walmsley , "linux-riscv@lists.infradead.org" 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 Mon, May 20, 2019 at 5:13 PM Christoph Hellwig wrote: > > > void __init parse_dtb(unsigned int hartid, void *dtb) > > { > > - if (early_init_dt_scan(__va(dtb))) > > + dtb = (void *)fix_to_virt(FIX_FDT) + ((uintptr_t)dtb & ~PAGE_MASK); > > + if (early_init_dt_scan(dtb)) > > FYI, parse_dtb in mainline now lost the hartid argument and takes a > phys_addr_t for the dtb address. Okay, this patch is based on 5.1 kernel. I guess I will have to rebase it anyway. > > That being said I find the above way to magic. So we take the fixmap > address and then only the offset from something passed as a pointer? > This just looks very weird. The way FIX_FDT is defined to add to my > confusion, which might partially be due to not understanding fixmaps > very well. But it seems like at very least we should set up an > actual kernel pointer for the dtb in setup_vm based on what that > gets passed and stop passing any arguments to parse_dtb to keep > that magic in one place. And possibly add some comment. I agree with your suggestion. I will setup early_dtb_ptr in setup_vm() and use it here. FYI, the fixmap virtual address range is not covered by linear va-to-pa translation (i.e. __va() and __pa() cannot be used). The mapping granularity of fixmap is always PAGE_SIZE hence add offset to fix_to_virt(FIX_FDT). > > > +#if MAX_EARLY_MAPPING_SIZE < PGDIR_SIZE > > It seems MAX_EARLY_MAPPING_SIZE is defined to a fix constant, > why do we need these conditionals? Sure, I will remove the conditional. It's totally redundant. I forgot to remove it previously. Regards, Anup