From nobody Sat Sep 26 20:27:43 2026 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1E693B8D70 for ; Sun, 30 Aug 2026 16:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788106354; cv=none; b=RfyUxxmW83FC7BjDbFg5OGkcBeOUReweCqkNoflC0BiqnMBPe25Bb3+wVIlwIhITncJ/5WHx7DfbzlYzn2KTzi85J379Rfp7zgt6277t9Ieb7pyhDx5z9dbw0PnQnz9zYXIDAC+A8v0zSTooOLDKDiASLL5AUIqROzOiHLlOwUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788106354; c=relaxed/simple; bh=9DJZMB7UOJGJmvWQBrhA3BWiZH+aupD6L+/YhsXD9T4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sNUzjlF6qnYWyp/mxMoCC+ypnDok2biEnCEzrn59scUjo5STdvtfslKTyyWDQYZxKQugfQAOda+XiGTLhj9B9/s7edF/OjMrSjTD+oYIuDa3uOcDVokeSdbuxq6E6esTBAvo+UcCDeOEanHORboKvrR5EwVfBo7E2ZXzWkkjJw4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EwpDsnls; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EwpDsnls" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3856d6fbcb3so2585606a91.2 for ; Sun, 30 Aug 2026 09:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788106349; x=1788711149; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3oPpwMsCahf6JtLGhYR2mgNDmu982ouZaUg+WHl9e+M=; b=EwpDsnlsNhcPubF9v5YWvGR1JdL0FHlkcQp0CsLQopdjjKRI+TOZ/BYZhH14FaBxmK cgyOZGSEiwOyfhT4lb9L/Ta3lDzeA/xdSUnmqHcBuu1V+PWQnUEJej63DH00aT0KghCb I6s8e2EsK/ww5XFn6ruKzHxy2ZyPT6J1/CvosFHaeZWJjg7QLxjDR+O5+H7E5QTVUueD rlqlBs9jy4LPr+bh4sXjNm8V1vhNOmDa34NcfR+/4fIxFu0rJqYpUP6WlfRhPeSZTaEP O/TMIhMIx0SgNVEtsnysD1FvQ9Q6YVkZ6UZjPbCbzmjpkswUNb5qLYq6uIucvijWNYc0 bqwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788106349; x=1788711149; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=3oPpwMsCahf6JtLGhYR2mgNDmu982ouZaUg+WHl9e+M=; b=ntiuPM0del7nqjsztacxcz2827EqNturIk2jr2edtzAH+jca6VmGLOY5+Vavm5W16g Qttshh1butKpKS/qY0AKAYJZMXHmXYaqMfIRyTXisMajcLHyxNIsKYALAgWE7dYDM7Df wDhb9LiKn/T5EC0z/45bujyXChIX+2nnNdCOwRRluA6d+hphANM7yb0SEO1pvUC/ruZ7 gBEhwXeIjyBsR1FBvpJ42G8WEJvzotPGSO66d0SY7Fm8t4TTJ4sNMm7sPqg/dx+Wz4+I HZDghHNicubd1YwToSLx0knBNG0V5uyuc+p0h7J7YhswZrX363TOicVLaYw/LEtjgFIF MUNw== X-Forwarded-Encrypted: i=1; AKwUvByLFyenqgS3icu2zreVzAtfMfEE/XyQsxXuFruE5IBIiIbqHyS4PXyJcKUPUm/e4x1gBD7tN5h35Ef3bgU=@vger.kernel.org X-Gm-Message-State: AFuF++ml92IDfE1eVyBvWg2sm7A8bHYYVKK62DESXAJrHRCAOf4Gv6Kk mbE6BwpKGtRMWqGEzgwsLJrTH9QP7Mag2/endvSdDz45432BNKxmIienXqkwJxDco1c6kw== X-Gm-Gg: AYBFou1nM71oXJP2NIak4JPl1oM36R4ICE0wB+NTBaYjhrxNv4Iy+6rfOZyJmOQ9EcI FJbHK0L2WPk+1Is52qOSk3NYYmb8cn2U5godX3DIu4qeYsfcArqf9vVX0EN0sEQ0ZRgk4EoE439 CCxGjbio0xlT0CIKBhYey64IjlWNDMEs27TCLRKz8nxMrrZde+rU26eyL2nBZuzqGLPIiVXYv0n 0UoZoOkpl+sqh5NIe6hhfZRz0MsdZpJXuj1+WL+lEzTM0BLevUeTLRJvWhyTWI8AfgVXOuHVPIl QxsXOF22NHyLcdFnyOoxHITaWsFohS3ZzNLK7lZiujY69phAOrkNGYnjYOHl8TiA0hw+VJ+XI27 m8rxJrRyiC2mnzqoSFrAw9oOUhYL9qbYlkg9awm8UR5vVOXPg0ug0AbsUHE9W8vBGMo2UsLFcFA yXJbHPKB9QTzbGLTP90OgZq7JYH98OiW3xK8nnLpo0gMfwnrJcxCRQhOFSVIUUajfsujVwkfUmK wruQkhhWwsnYMl4nrR3Subj5Zt5iIFZ7uY= X-Received: by 2002:a17:90b:3ec1:b0:38e:7168:281 with SMTP id 98e67ed59e1d1-396d0f2dcd8mr23466138a91.10.1788106349495; Sun, 30 Aug 2026 09:12:29 -0700 (PDT) Received: from localhost.localdomain ([134.195.101.83]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32bdfd03e71sm5719005eec.1.2026.08.30.09.12.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 30 Aug 2026 09:12:28 -0700 (PDT) From: Yu Jin To: linux-riscv@lists.infradead.org Cc: Albert Ou , Alexandre Ghiti , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Randy Dunlap , Shuah Khan , Yu Jin Subject: [RFC PATCH 1/2] docs: riscv: document the Sv32 virtual memory layout Date: Mon, 31 Aug 2026 00:12:04 +0800 Message-ID: <20260830161205.80162-2-lambda.jinyu@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260830161205.80162-1-lambda.jinyu@gmail.com> References: <20260830161205.80162-1-lambda.jinyu@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RISC-V virtual memory layout documentation describes the 64-bit paging modes but leaves the Sv32 section as a TODO. Document the rv32_defconfig layout and clarify which boundaries depend on the configured size of struct page. Distinguish the maximum direct-map range from the portion backed by physical memory. Also explain why the 34-bit physical addresses encoded by Sv32 page table entries do not make all of that address space usable as RAM by the current RV32 kernel. Signed-off-by: Yu Jin --- Documentation/arch/riscv/vm-layout.rst | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/riscv/vm-layout.rst b/Documentation/arch/ri= scv/vm-layout.rst index eabec99b5852..8e1447cf574e 100644 --- a/Documentation/arch/riscv/vm-layout.rst +++ b/Documentation/arch/riscv/vm-layout.rst @@ -16,7 +16,33 @@ RISC-V Linux Kernel 32bit RISC-V Linux Kernel SV32 ------------------------ =20 -TODO +Sv32 provides a 4GB virtual address space, with the upper part used by the +kernel. Unlike the 64-bit layouts, the kernel image is part of the direct +mapping. The following layout is produced by ``rv32_defconfig``. + +:: + + =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 de= scription + =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 + | | | | + 00000000 | 0 | 9c7fffff | 2504 MB | user-space= virtual memory, different per mm + __________________|____________|__________________|_________|___________= ________________________________________________ + | + | Kernel-spa= ce virtual memory, shared between all processes: + ____________________________________________________________|___________= ________________________________________________ + | | | | + 9c800000 | -1592 MB | 9cffffff | 8 MB | fixmap + 9d000000 | -1584 MB | 9dffffff | 16 MB | PCI io + 9e000000 | -1568 MB | 9fffffff | 32 MB | vmemmap-si= zed reserved area + a0000000 | -1.5 GB | bfffffff | 512 MB | vmalloc/io= remap/modules; BPF JIT uses the last 128 MB + c0000000 | -1 GB | ffffffff | 1 GB | direct map= ping of physical memory + __________________|____________|__________________|_________|___________= ________________________________________________ + +The layout before ``VMALLOC_START`` depends on the configured size of +``struct page``. The direct mapping row shows its maximum range; usable RA= M is +limited by its mapped portion and the 32-bit ``phys_addr_t``, despite the +34-bit physical addresses encoded by Sv32 page table entries. =20 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 --=20 2.43.0 From nobody Sat Sep 26 20:27:43 2026 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A13D33BF682 for ; Sun, 30 Aug 2026 16:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788106361; cv=none; b=QJHJsVro/9Le6IvXj5dd7HKuNw266GPA6/TPcEOlGKpJGHzQ1Zoat7YspkyO96PU9cXtPUt2VDklRxpoP3sYj70UBVFLDL3GxOljzqYPPWizxAlKnTrQKEMS+sVr1IEbFMPlPRwk2OeZdYFB6OM4tnT9et+D6IlV6GEcF0jX38U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788106361; c=relaxed/simple; bh=JGZgOh3NLnQ3zE3ReM7hQZC4iKeVrPllBAT/3U7VeAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RzzK2i64ygCEqcfoz7UN7aK96rG5qcknQPR0gdo3B+u9FMfFSfQQN4ZmkZHQnch6V/uk5Xmduya30MN9YLagCKKa+ASBNcx7LV04cG7lv6RKIf7JCdSDV6yF7HZ1eOlUA3rPz4TYcbXn4LtaWhqMo0pj/Nk903VumY+eO21RnDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eh3SVeDk; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eh3SVeDk" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2d9201076b3so2073225ad.0 for ; Sun, 30 Aug 2026 09:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788106354; x=1788711154; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NdTRN44Y9INGZlIdKi2+i3Dw0ibf1fzMAsMfvmYvVnE=; b=eh3SVeDkcASA+OzGer+RuE0DcyA/Z7AwG/LgS8k0tKLzNk3Gjc343kvpqxinY9eps2 sNQkpKxgJcpZE90lODYoh6ADaFtdRUmPWhAF1jOibWZ9prjWX4lPjvcnZTi6eAA/9/uR QJsBPMSh5WdHVseSoEyQaYSaF3EyTjNViy9w9BG1f8ic7S8id4mql7sN2BNU8Pw/QJfl 7OB21SgLqvATM3QWYM26MFOCDsRO8ur4W1qxaw64PaSc+nZxUDNkiVDhG4POVnF3PJJ/ JZdrBzrPQqD1tK5vyagt346JAawxRMwXmKUX9iJCh/trrt1h8m7Qu5b0Z2KhIFJ1A0Pa HxEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788106354; x=1788711154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NdTRN44Y9INGZlIdKi2+i3Dw0ibf1fzMAsMfvmYvVnE=; b=FxD1ubSvZW6IUD4ezKy82GlL/k3DKyBzHf8HuFn9D05uLGPS1zpze3LsgtpJ8hGsJw JbAjQM5ezRsQfo0yHzUUUs5fx7oIQL8aZ6RI24US5tdjUXsgqvszaWUTBOFNVlii8h7K FMmV0zoUI3NH8Sgaia45L3hhfR/SG6RwYlTH2RuxB6RaQsKa71sK9JOdpchgbs02zrlW FSG+l/9tmnRA+wU4RIY7UbWadOYfYEjL+PAFAYvsVoH0HOFL+Rf3dfQzLOl1fOxEAVfK L8eR8r9LDSFcykRahF6rs0W3b9sAeoaN88Av0KATbG8x7ms+IO/9+Ovpu1w1ocmMEMtm KzdQ== X-Forwarded-Encrypted: i=1; AKwUvByPvGxNJ+kJ0NSgNWf0NZ8UUuOrU4HZlX6H4jUoVvYEnuoRS7j8oh9bXG8KSfDYnwpZEmFpcD6tCvoXpls=@vger.kernel.org X-Gm-Message-State: AFuF++nV9R+9sRaNy7tHJLeEUBW3BbjST9Ti1M0mmn7cyE08Z2uwfL8E mIuO2+TMJLmezKIMnmkji6W+xICLT7yQT5CRbtbaA8nfo4EpkzAiRmZt X-Gm-Gg: AYBFou177yyIP4GTmuLRsvrQjgwKRpuiQ5QH/rXy5hDc66N2G03WFkGjUOl8lVt7LQy TWmjTfNdtGvyk2bsw+4xapwkiVlK1I+GxeQaTS0aUJQOLJ2Q/nEaxZw1gPfqjG7jBXAy4WajhHq 0vFjq5C/A+xnwi+Z5AQSPEJBNrJoYAyAKwWz8aI1n2TxFQ5UpWtXAASIYfe2nKmodW9CYCVn9xT i+MWsud6yKsdfPWkBF2BUGPb6IKWeWzQ2qNQgt+hTJxFz6UMBDmMS2EQfieTdzwPqVXj7KOFdfB evST/qFPhyi8U8LziRSF2V0cO9TF4tDSyZJrq4VWVddIoVxVeUDlbWb2Yf7PtVjN6egYpfTffEA BL7C4hjC+4PVyFPk27AlujXxqSlIUMNwWJsqrit8MoK7/Eeg1rFVdspf9rXLiFxCPBzrUZ1c4Rp fRGk7dI/2d8SWd5BMZuVSouL1pi1rrZ+ghcWZ7ak2ejoq9dg+N9pFZkHeKY6Yln4NsVUorMQZN+ fTMeKMPR6W4U9Jr3rJU3ShM1xGMq0jx6BY= X-Received: by 2002:a17:903:1aec:b0:2d7:203b:9863 with SMTP id d9443c01a7336-2d74dc6e97fmr364985975ad.1.1788106354469; Sun, 30 Aug 2026 09:12:34 -0700 (PDT) Received: from localhost.localdomain ([134.195.101.83]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-32bdfd03e71sm5719005eec.1.2026.08.30.09.12.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 30 Aug 2026 09:12:34 -0700 (PDT) From: Yu Jin To: linux-riscv@lists.infradead.org Cc: Albert Ou , Alexandre Ghiti , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Randy Dunlap , Shuah Khan , Yu Jin Subject: [RFC PATCH 2/2] riscv: mm: correct the stale RV32 TASK_SIZE comment Date: Mon, 31 Aug 2026 00:12:05 +0800 Message-ID: <20260830161205.80162-3-lambda.jinyu@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260830161205.80162-1-lambda.jinyu@gmail.com> References: <20260830161205.80162-1-lambda.jinyu@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RV32 defines TASK_SIZE as FIXADDR_START. Its value depends on VMEMMAP_SIZE, which in turn depends on the configured size of struct page. The fixed 0x9fc00000 value in the comment is therefore stale. Describe the macro relationship instead of replacing one configuration-specific address with another. Signed-off-by: Yu Jin --- arch/riscv/include/asm/pgtable.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgta= ble.h index 40b1ed4f3ea8..32348787462c 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -1231,10 +1231,8 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pt= e) #endif =20 /* - * Task size is 0x4000000000 for RV64 or 0x9fc00000 for RV32. - * Note that PGDIR_SIZE must evenly divide TASK_SIZE. - * Task size is: - * - 0x9fc00000 (~2.5GB) for RV32. + * For RV32, TASK_SIZE is FIXADDR_START and depends on VMEMMAP_SIZE. + * For RV64, task size is: * - 0x4000000000 ( 256GB) for RV64 using SV39 mmu * - 0x800000000000 ( 128TB) for RV64 using SV48 mmu * - 0x100000000000000 ( 64PB) for RV64 using SV57 mmu --=20 2.43.0