From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12046C43461 for ; Fri, 9 Apr 2021 06:17:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 988F061168 for ; Fri, 9 Apr 2021 06:17:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 988F061168 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 23C136B006C; Fri, 9 Apr 2021 02:17:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2139D6B006E; Fri, 9 Apr 2021 02:17:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B3CC6B0070; Fri, 9 Apr 2021 02:17:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id DD44B6B006C for ; Fri, 9 Apr 2021 02:17:30 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9528A1830D190 for ; Fri, 9 Apr 2021 06:17:30 +0000 (UTC) X-FDA: 78011821860.05.82AA38E Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by imf10.hostedemail.com (Postfix) with ESMTP id 4986C40002C0 for ; Fri, 9 Apr 2021 06:17:26 +0000 (UTC) X-Originating-IP: 81.185.169.105 Received: from localhost.localdomain (105.169.185.81.rev.sfr.net [81.185.169.105]) (Authenticated sender: alex@ghiti.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id D86D3E0003; Fri, 9 Apr 2021 06:17:23 +0000 (UTC) From: Alexandre Ghiti To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH v4 2/3] Documentation: riscv: Add documentation that describes the VM layout Date: Fri, 9 Apr 2021 02:14:59 -0400 Message-Id: <20210409061500.14673-3-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210409061500.14673-1-alex@ghiti.fr> References: <20210409061500.14673-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 4986C40002C0 X-Stat-Signature: zrwg71wwki8833in8giz9xo1th5uq7yq Received-SPF: none (ghiti.fr>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=relay4-d.mail.gandi.net; client-ip=217.70.183.196 X-HE-DKIM-Result: none/none X-HE-Tag: 1617949046-748318 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This new document presents the RISC-V virtual memory layout and is based one the x86 one: it describes the different limits of the different regio= ns of the virtual address space. Signed-off-by: Alexandre Ghiti --- Documentation/riscv/index.rst | 1 + Documentation/riscv/vm-layout.rst | 63 +++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 Documentation/riscv/vm-layout.rst diff --git a/Documentation/riscv/index.rst b/Documentation/riscv/index.rs= t index 6e6e39482502..ea915c196048 100644 --- a/Documentation/riscv/index.rst +++ b/Documentation/riscv/index.rst @@ -6,6 +6,7 @@ RISC-V architecture :maxdepth: 1 =20 boot-image-header + vm-layout pmu patch-acceptance =20 diff --git a/Documentation/riscv/vm-layout.rst b/Documentation/riscv/vm-l= ayout.rst new file mode 100644 index 000000000000..329d32098af4 --- /dev/null +++ b/Documentation/riscv/vm-layout.rst @@ -0,0 +1,63 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Virtual Memory Layout on RISC-V Linux +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +:Author: Alexandre Ghiti +:Date: 12 February 2021 + +This document describes the virtual memory layout used by the RISC-V Lin= ux +Kernel. + +RISC-V Linux Kernel 32bit +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +RISC-V Linux Kernel SV32 +------------------------ + +TODO + +RISC-V Linux Kernel 64bit +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +The RISC-V privileged architecture document states that the 64bit addres= ses +"must have bits 63=E2=80=9348 all equal to bit 47, or else a page-fault = exception will +occur.": that splits the virtual address space into 2 halves separated b= y a very +big hole, the lower half is where the userspace resides, the upper half = is where +the RISC-V Linux Kernel resides. + +RISC-V Linux Kernel SV39 +------------------------ + +:: + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + Start addr | Offset | End addr | Size | VM area = description + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + | | | | + 0000000000000000 | 0 | 0000003fffffffff | 256 GB | user-spa= ce virtual memory, different per mm + __________________|____________|__________________|_________|_________= __________________________________________________ + | | | | + 0000004000000000 | +256 GB | ffffffbfffffffff | ~16M TB | ... huge= , almost 64 bits wide hole of non-canonical + | | | | virt= ual memory addresses up to the -256 GB + | | | | star= ting offset of kernel mappings. + __________________|____________|__________________|_________|_________= __________________________________________________ + | + | Kernel-s= pace virtual memory, shared between all processes: + ____________________________________________________________|_________= __________________________________________________ + | | | | + ffffffc000000000 | -256 GB | ffffffc7ffffffff | 32 GB | kasan + ffffffcefee00000 | -196 GB | ffffffcefeffffff | 2 MB | fixmap + ffffffceff000000 | -196 GB | ffffffceffffffff | 16 MB | PCI io + ffffffcf00000000 | -196 GB | ffffffcfffffffff | 4 GB | vmemmap + ffffffd000000000 | -192 GB | ffffffdfffffffff | 64 GB | vmalloc/= ioremap space + ffffffe000000000 | -128 GB | ffffffff7fffffff | 124 GB | direct m= apping of all physical memory + __________________|____________|__________________|_________|_________= ___________________________________________________ + | + | + ____________________________________________________________|_________= ___________________________________________________ + | | | | + ffffffff00000000 | -4 GB | ffffffff7fffffff | 2 GB | modules + ffffffff80000000 | -2 GB | ffffffffffffffff | 2 GB | kernel, = BPF + __________________|____________|__________________|_________|_________= ___________________________________________________ --=20 2.20.1