Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1200634pxb; Sun, 11 Apr 2021 10:48:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9oGmdqTwfW6zPs11qBziD3IzhnfW2bLukGtkc3FwoHKJaC3JXvljZsDNz1T4P6WH8P1kb X-Received: by 2002:a17:907:10d8:: with SMTP id rv24mr1498108ejb.542.1618163334321; Sun, 11 Apr 2021 10:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618163334; cv=none; d=google.com; s=arc-20160816; b=AwEWNa13SwtAS8OIwCXCp4fli580mCgRllvhBIyyN6RjUJhsYZ3IIspRu1S0/07NE5 4L3mQx1Bnh1bXHOXeTxCqGNvmMAcYOtliupnJd4KYdjfmwwk8tfEwquDQdSkvsqg9IxR uv9xCnqicyeGTUF/kfAHQkvhd8IdI1gHDhP5F9zOUOYAqnDqQUYCyRR6UUbcJknQ1lzn 938MebebGnUrxU+UUitdQ9DYMr5B4NB6mFwD1/C+N3aGtQ4pSnQX+O4HOa3Z+8lQmX59 M6fwZ7miSg9/6Tb6FnAljOw6G27SrWmqga9g0vKPN5UIrW9hTMSvNwc2hTrOpacEe3zD 0NVg== 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 :message-id:date:subject:cc:to:from; bh=Ch/IfGD5PGyjnqwG0mYAKGWiVWhbCS/KfAIOn22xtx8=; b=wEYfionb0M7Fi98v2dw8InHodb1xJQ839Fzrk5iW/qf/4JcptRbttLbKybb3xNpPZd IjwAyeQyCATzRGJJQrFY7ZYxYhM0WoKWNxYoknfzbFwUg9spQPguF0Qb0hYpucJz9HMm I2QIGLSz+Rrx6rQmCuRlh8XUKivfqAllrapK1JIfq2jM+ZxS30tNe968k48h6n3OKheT ali0tpwo1v1oLQsa9oPRDe0GF0HpDJ0rKxHmMRUIqnD3V78OWWhlp3V83zRKC+JkOCra 1/UKOempuy0RjBSJVj89NLGrD8obsKAXlkBlOS6qU7fiBCpC3qjFqkUZ6GSMWE4VM7JB yw5A== 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 v1si2296787ejr.749.2021.04.11.10.48.28; Sun, 11 Apr 2021 10:48:54 -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 S235825AbhDKQmK (ORCPT + 99 others); Sun, 11 Apr 2021 12:42:10 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:21491 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236406AbhDKQmJ (ORCPT ); Sun, 11 Apr 2021 12:42:09 -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 relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 4736C240012; Sun, 11 Apr 2021 16:41:47 +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 0/3] Move kernel mapping outside the linear mapping Date: Sun, 11 Apr 2021 12:41:43 -0400 Message-Id: <20210411164146.20232-1-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I decided to split sv48 support in small series to ease the review. This patchset pushes the kernel mapping (modules and BPF too) to the last 4GB of the 64bit address space, this allows to: - implement relocatable kernel (that will come later in another patchset) that requires to move the kernel mapping out of the linear mapping to avoid to copy the kernel at a different physical address. - have a single kernel that is not relocatable (and then that avoids the performance penalty imposed by PIC kernel) for both sv39 and sv48. The first patch implements this behaviour, the second patch introduces a documentation that describes the virtual address space layout of the 64bit kernel and the last patch is taken from my sv48 series where I simply added the dump of the modules/kernel/BPF mapping. I removed the Reviewed-by on the first patch since it changed enough from last time and deserves a second look. Changes in v5: - Fix 32BIT build that failed because MODULE_VADDR does not exist as modules lie in the vmalloc zone in 32BIT, reported by kernel test robot. Changes in v4: - Fix BUILTIN_DTB since we used __va to obtain the virtual address of the builtin DTB which returns a linear mapping address, and then we use this address before setup_vm_final installs the linear mapping: this is not possible anymore since the kernel does not lie inside the linear mapping anymore. Changes in v3: - Fix broken nommu build as reported by kernel test robot by protecting the kernel mapping only in 64BIT and MMU configs, by reverting the introduction of load_sz_pmd and by not exporting load_sz/load_pa anymore since they were not initialized in nommu config. Changes in v2: - Fix documentation about direct mapping size which is 124GB instead of 126GB. - Fix SPDX missing header in documentation. - Fix another checkpatch warning about EXPORT_SYMBOL which was not directly below variable declaration. Alexandre Ghiti (3): riscv: Move kernel mapping outside of linear mapping Documentation: riscv: Add documentation that describes the VM layout riscv: Prepare ptdump for vm layout dynamic addresses Documentation/riscv/index.rst | 1 + Documentation/riscv/vm-layout.rst | 63 +++++++++++++++++++++ arch/riscv/boot/loader.lds.S | 3 +- arch/riscv/include/asm/page.h | 17 +++++- arch/riscv/include/asm/pgtable.h | 37 ++++++++---- arch/riscv/include/asm/set_memory.h | 1 + arch/riscv/kernel/head.S | 3 +- arch/riscv/kernel/module.c | 6 +- arch/riscv/kernel/setup.c | 5 ++ arch/riscv/kernel/vmlinux.lds.S | 3 +- arch/riscv/mm/fault.c | 13 +++++ arch/riscv/mm/init.c | 87 ++++++++++++++++++++++------- arch/riscv/mm/kasan_init.c | 9 +++ arch/riscv/mm/physaddr.c | 2 +- arch/riscv/mm/ptdump.c | 73 ++++++++++++++++++++---- 15 files changed, 271 insertions(+), 52 deletions(-) create mode 100644 Documentation/riscv/vm-layout.rst -- 2.20.1