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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E241C433FE for ; Wed, 29 Sep 2021 14:57:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73F82613D3 for ; Wed, 29 Sep 2021 14:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344880AbhI2O71 (ORCPT ); Wed, 29 Sep 2021 10:59:27 -0400 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]:60404 "EHLO smtp-relay-internal-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344800AbhI2O7Z (ORCPT ); Wed, 29 Sep 2021 10:59:25 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 3F6F640605 for ; Wed, 29 Sep 2021 14:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1632927463; bh=OQKNU2zsWxm9Jo/LuBgWw8xEdpf0SBZ+oU39CLxAstw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Efdf0ixdBezoNZH6rdVsJR1NZPjs5HRENkR71h6pI7bGNZ5qhPrur4JNGQhsl9ft5 lBb6Lmjsx6yyGpbfp9p1jwA52lSdtfXu4hJoKxHMLjMtWyq2WY+a2iol2c6XOj2fos nsY1GpHBmuLr0EQ+ajKS0HW+45WCdzZ5uEw1IhzHqzQ/u8yfjYZ5s6ry/NliNkiXQT 5PAKDDAE7jYyqsTwyCAuPXFrZhPWSG86ybNjsLN1JFIYv3yG5hZnDcOTb6aWRP8S9f k1nBlKodOLVNXDIo3OrAlJ0lrFpSYLrcLja5uNgcdUwv4GHj0MwLxWSayafX9eGxpq ObcSOtwZj5Waw== Received: by mail-wm1-f70.google.com with SMTP id p25-20020a1c5459000000b0030cac3d9db1so1337935wmi.6 for ; Wed, 29 Sep 2021 07:57:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OQKNU2zsWxm9Jo/LuBgWw8xEdpf0SBZ+oU39CLxAstw=; b=6l7hg6AhKk4Y7aHDCrz1uJwDhcAJKvd5nZjw1k+8xRzsG8c7B/Sb9ofUJBV7ihZCpN GommHN00zWyYwCIGwGdHX1XtRIt9fWYuCZ9vsvnGfrP2PvYSByMX1I55vrGSvf25f0Nw r6cmrMaKPUttYTwrjkuUMqbFVeOHa4/HtxFcwBIKT+UhfYS0tJWqg6rzkwTF8FEftfly Ug7uyrej8bcKIcEbvUYPKdrjXjX3o0cVVPi2eGUpLHpW88qc7vC0Hy5Kl4tHFsEMyp4Q 02kUEZ2g+eQEq7sFSPVFwtYkrT41YY6TNgXne9i40dxXjmCsAI3aE5tQTz6/Zn1lLneZ Cv4A== X-Gm-Message-State: AOAM533dU5zmbLrZQ6KQszyACoA/nsU36Xqhhihgk7P3as4A8ycyDQRt Maksl7EkWqDvCtvCvRFjqyjk6xqZ2Ue8My4Jvip9iGUdzRUOvexeS3zI5A2HluYSg7LJbcr6s7w ojU4CRnS/PRo5i83a5AdH1NiTkysX46qMd6enNNomXA== X-Received: by 2002:adf:a4cf:: with SMTP id h15mr370302wrb.56.1632927462556; Wed, 29 Sep 2021 07:57:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWeSWC8Cet11Ro5/xO8f14KgL4rhrNIaUyTxHnc/lR/+aHCeqyv0GI/LbfJlrDouaKDo8Q7w== X-Received: by 2002:adf:a4cf:: with SMTP id h15mr370287wrb.56.1632927462418; Wed, 29 Sep 2021 07:57:42 -0700 (PDT) Received: from alex.home (lfbn-lyo-1-470-249.w2-7.abo.wanadoo.fr. [2.7.60.249]) by smtp.gmail.com with ESMTPSA id a25sm1888009wmj.34.2021.09.29.07.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 07:57:42 -0700 (PDT) From: Alexandre Ghiti To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Zong Li , Anup Patel , Atish Patra , Christoph Hellwig , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Ard Biesheuvel , Arnd Bergmann , Kees Cook , Guo Ren , Heinrich Schuchardt , Mayuresh Chitale , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-efi@vger.kernel.org, linux-arch@vger.kernel.org Cc: Alexandre Ghiti , Palmer Dabbelt Subject: [PATCH v2 06/10] riscv: Explicit comment about user virtual address space size Date: Wed, 29 Sep 2021 16:51:09 +0200 Message-Id: <20210929145113.1935778-7-alexandre.ghiti@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210929145113.1935778-1-alexandre.ghiti@canonical.com> References: <20210929145113.1935778-1-alexandre.ghiti@canonical.com> 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 Define precisely the size of the user accessible virtual space size for sv32/39/48 mmu types and explain why the whole virtual address space is split into 2 equal chunks between kernel and user space. Signed-off-by: Alexandre Ghiti Reviewed-by: Anup Patel Reviewed-by: Palmer Dabbelt --- arch/riscv/include/asm/pgtable.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 2f92d61237b4..fd37cc45ef2a 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -664,6 +664,15 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma, /* * 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. + * - 0x4000000000 ( 256GB) for RV64 using SV39 mmu + * - 0x800000000000 ( 128TB) for RV64 using SV48 mmu + * + * Note that PGDIR_SIZE must evenly divide TASK_SIZE since "RISC-V + * Instruction Set Manual Volume II: Privileged Architecture" states that + * "load and store effective addresses, which are 64bits, must have bits + * 63–48 all equal to bit 47, or else a page-fault exception will occur." */ #ifdef CONFIG_64BIT #define TASK_SIZE (PGDIR_SIZE * PTRS_PER_PGD / 2) -- 2.30.2