Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp326187pxb; Thu, 25 Feb 2021 03:43:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFGACOHcuQrV1U7pG8skduQQVT2KdZCGsLWqJ/ibCraHFRgssbBFQkfqeR3sL3y+Uv/GPh X-Received: by 2002:a17:906:b14b:: with SMTP id bt11mr2356464ejb.162.1614253429253; Thu, 25 Feb 2021 03:43:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614253429; cv=none; d=google.com; s=arc-20160816; b=NzokBFqwLMY8HHFcwBFroXYKjhzoYscSRicDqy0S0x+mMEjrBvXUiJHE2vQ1IAHFaY V0vAsbxNoK16TCdDl0HCRylIc9MsAZJ4s3RTouaWzh80cQYMQNlgfMgXOXCqnd4Ke16W qVgcdbFUzVh2cBmSpfpgrkSDFHD/gKXu+I0HdfXhauq3ywuxvT1/KXpywr/Uz3QNTsii xKcKmRsnnmeiISjCRssFWI26Iid/B9Y0206hypVh/I6QyfpipjpKVXVFkUrfxGztmg0G blBoCkMlJ5S27JuYvkWx953zvI8E2T2FGtAp+VgBuxirPV2RLpjRyBZa8f/D7yvlMXP9 LEwQ== 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=F6pdI9z3UQbsR5ipulUys7eGQja2lsllBCEK4vYtI6o=; b=svQsncXnRmo8PScbUfvT4sXZO1iL6wupHiQcLZvfiq1NVirffP0GFsCLgRtodIColW 2L9XkaP7Tn1Vs/HGqkRll9fHj39p6xaXJLj5XSnUX+e52g7zWkNcbyc8xlUyRRMdDPCT Kqqusgnu9X5G0337Y32qt7sja7uaLveEwe1mTEgovir17S58xT9kFA0HxOlIpl98cy2u oDoGrKFkiW06/9NPgvdRWn5bnN+xAozAeu6S452r50qe1ad2Ka9D3ry/PU+VQYf/NsD8 TYcvATEDzrRiMwLtRHEGLjzTYYJs7/DV4MLVhSHfmx3Zwo2Nw3oxFpUcyz6S1e5fIyL4 tJnA== 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 o11si3037820edc.411.2021.02.25.03.43.27; Thu, 25 Feb 2021 03:43:49 -0800 (PST) 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 S235382AbhBYII4 (ORCPT + 99 others); Thu, 25 Feb 2021 03:08:56 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:40263 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235616AbhBYII1 (ORCPT ); Thu, 25 Feb 2021 03:08:27 -0500 X-Originating-IP: 81.185.161.35 Received: from localhost.localdomain (35.161.185.81.rev.sfr.net [81.185.161.35]) (Authenticated sender: alex@ghiti.fr) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 8DAD41C0006; Thu, 25 Feb 2021 08:07:26 +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 2/3] Documentation: riscv: Add documentation that describes the VM layout Date: Thu, 25 Feb 2021 03:04:52 -0500 Message-Id: <20210225080453.1314-3-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210225080453.1314-1-alex@ghiti.fr> References: <20210225080453.1314-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 | 61 +++++++++++++++++++++++++++++++ 2 files changed, 62 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..e8e569e2686a --- /dev/null +++ b/Documentation/riscv/vm-layout.rst @@ -0,0 +1,61 @@ +===================================== +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 | 126 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