Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1201676pxb; Sun, 11 Apr 2021 10:51:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb2OYZMSninT4f4o4ij1W/RVQiLxi2dtIOkkSa7hlwrOS6FM4dsxUvM/rOUGVAVqWvzsRe X-Received: by 2002:a05:6402:30ae:: with SMTP id df14mr25855759edb.97.1618163488206; Sun, 11 Apr 2021 10:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618163488; cv=none; d=google.com; s=arc-20160816; b=XFpdqzZdKFlpxRc6vLryb2E//h6D9i7HuQgzdGE7TvItL717EhQ2OBEkVarOEGTJyi SEKyAi+MMtkshIeq+LsVlRv0CeBgmXfZOoe6O17OqlKWVmqWQdS/J814aO8sJdwa+JdH 625AUWhM4VWP0pBJsEQxS5t034JFHbHro7Go4g6HlKhFenOUdGWGs5T6XM/bHc0zajXL cbHCRUFLi8qvFJX9u6JqWmLuvo4kWuzCfHZBMYKj5Tg7e5AOcbe1J+piIQUs2A3/tXj3 F1sM9zZH5RzwsYxmVLEir3I9qfFjI33XdWE3okk5UmXMZxVdGsTpgrj527kaatV8VbZb iaWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WFcLtBl6RmKjsIRqwG0zx8sBRO6mPYJiXhHMrLe6GlE=; b=aD043Fz3zWXArGHuvFerPGcFey0cNkTySyWyoei6U2atOaD3REXSVB2sRDshzTN4TT IXlozwqR1gJ1OGAQerKrOG6AStdDIwVwcjCL4gMOYYM3vFU/PmmmMB71yE6iM7m5/ATc 5GnAKFiQYGRHO6HlUlRG6yHsQA0MAzwz+ixqz+9PG/UpOTfxlH0X6abSNGMBKYpBwlyL NZzJUweAgyhdhKHbhsIWM4IdP8Js0zjBSE6qgsAvKdzuT3De5cKtTIDQ9nZ/U7Y/Z9rg 2FiwcK2WtoKY27WXuIGFlYZtFi3uzMJNbfPMj8LWHZJwYAaaGcGRMtUxURMUnCWE3063 Iwdg== ARC-Authentication-Results: i=1; mx.google.com; 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 n24si6276925edd.201.2021.04.11.10.51.05; Sun, 11 Apr 2021 10:51:28 -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; 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 S236483AbhDKQoT (ORCPT + 99 others); Sun, 11 Apr 2021 12:44:19 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:41735 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235855AbhDKQoT (ORCPT ); Sun, 11 Apr 2021 12:44:19 -0400 X-Originating-IP: 2.7.49.219 Received: from debian.home (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 3288320004; Sun, 11 Apr 2021 16:43:56 +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 v5 2/3] Documentation: riscv: Add documentation that describes the VM layout Date: Sun, 11 Apr 2021 12:41:45 -0400 Message-Id: <20210411164146.20232-3-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210411164146.20232-1-alex@ghiti.fr> References: <20210411164146.20232-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 regions 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.rst index 6e6e39482502..ea915c196048 100644 --- a/Documentation/riscv/index.rst +++ b/Documentation/riscv/index.rst @@ -6,6 +6,7 @@ RISC-V architecture :maxdepth: 1 boot-image-header + vm-layout pmu patch-acceptance diff --git a/Documentation/riscv/vm-layout.rst b/Documentation/riscv/vm-layout.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 + +===================================== +Virtual Memory Layout on RISC-V Linux +===================================== + +:Author: Alexandre Ghiti +:Date: 12 February 2021 + +This document describes the virtual memory layout used by the RISC-V Linux +Kernel. + +RISC-V Linux Kernel 32bit +========================= + +RISC-V Linux Kernel SV32 +------------------------ + +TODO + +RISC-V Linux Kernel 64bit +========================= + +The RISC-V privileged architecture document states that the 64bit addresses +"must have bits 63–48 all equal to bit 47, or else a page-fault exception will +occur.": that splits the virtual address space into 2 halves separated by 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 +------------------------ + +:: + + ======================================================================================================================== + Start addr | Offset | End addr | Size | VM area description + ======================================================================================================================== + | | | | + 0000000000000000 | 0 | 0000003fffffffff | 256 GB | user-space virtual memory, different per mm + __________________|____________|__________________|_________|___________________________________________________________ + | | | | + 0000004000000000 | +256 GB | ffffffbfffffffff | ~16M TB | ... huge, almost 64 bits wide hole of non-canonical + | | | | virtual memory addresses up to the -256 GB + | | | | starting offset of kernel mappings. + __________________|____________|__________________|_________|___________________________________________________________ + | + | Kernel-space 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 mapping of all physical memory + __________________|____________|__________________|_________|____________________________________________________________ + | + | + ____________________________________________________________|____________________________________________________________ + | | | | + ffffffff00000000 | -4 GB | ffffffff7fffffff | 2 GB | modules + ffffffff80000000 | -2 GB | ffffffffffffffff | 2 GB | kernel, BPF + __________________|____________|__________________|_________|____________________________________________________________ -- 2.20.1