From patchwork Fri Dec 22 11:57:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 13503258 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0676C4706C for ; Fri, 22 Dec 2023 11:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bzXtVp1jbxK7Iu0w0f4cCGIy8V/d21usQR3bKIN7zYY=; b=2g86V3MgfdUZeX 7kZ30p5wMukUMgmjKQITi2YkUmA5CMXkE60W26GLgG7BhZcJbQ9hM9/f3nmkzk2/9sEMVWCRYt5e+ wN+txzfPIlxVcbuX6yf4FLvCRQWwL3n+LHW2FEs74N7vdB7X6to3WWMH6voVvdJcE2tMRPvTvNLMj /OLb9nJLbQBLKS/NcxiEUQVmnjoskn7dqN/wNHQribc6VU7yyYtAK7nYv+UriodkxZ+yIorMWfchr J7EE028oipJUzX20O/z9btaOEh1AxomG2QUD7gSyuscDxTTOHibdb7y62xcxgv6b5O8BERcjesS3g pGeBoCm6CMm+pAq7xfpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGe9r-005sMe-2A; Fri, 22 Dec 2023 11:57:39 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGe9p-005sKx-1l for linux-riscv@lists.infradead.org; Fri, 22 Dec 2023 11:57:38 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0A09761BF4; Fri, 22 Dec 2023 11:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A766CC433C8; Fri, 22 Dec 2023 11:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703246256; bh=Bpr3cN4ZdKoHQcirLqVi0ln0qEuA20LN4TwxV/9UyIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rjcGbIgbK6jeqRf0kFK/o/IXjdlWN8p3XQ341829gtV0RN55zBIUKzU9aN7xDTlgA zyf6OCzTD5OC9qHWt3vJyq2YcHKDP0SMJ9HbtR3ap1kESS4nV7DFY31dyGYZY+JuVS J3FlEf3O+GyKQDOBGV9HsfJ2kT/RSJQdmiz0fDn5fgqKFknvpe2YPpAJLkf7ZWp/dV MPSXzXd+ixCj0hN9NEyzV5U/K6kPSbGIAipGtlKaXKWh7hpap4klETzGww7OPff+sx bmPFbqvn/rbd2/W+Q3T/Q23dUe66PeSpwB/7AQErVEWtM+uQZhq42Q0OOt8taV+Pf2 Yh8qaadcxErdA== From: guoren@kernel.org To: linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, alexghiti@rivosinc.com, charlie@rivosinc.com, xiao.w.wang@intel.com, guoren@kernel.org, david@redhat.com, panqinglin2020@iscas.ac.cn, rick.p.edgecombe@intel.com, willy@infradead.org, bjorn@rivosinc.com, conor.dooley@microchip.com, cleger@rivosinc.com, leobras@redhat.com Cc: linux-riscv@lists.infradead.org, Guo Ren Subject: [PATCH V3 4/4] riscv: mm: Optimize TASK_SIZE definition Date: Fri, 22 Dec 2023 06:57:03 -0500 Message-Id: <20231222115703.2404036-5-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231222115703.2404036-1-guoren@kernel.org> References: <20231222115703.2404036-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231222_035737_636737_70FD8166 X-CRM114-Status: UNSURE ( 8.22 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Guo Ren Unify the TASK_SIZE definition with VA_BITS for better readability. Add COMPAT mode user address space info in the comment. Reviewed-by: Leonardo Bras Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Charlie Jenkins --- arch/riscv/include/asm/pgtable.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index e415582276ec..271565e1956f 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -866,6 +866,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) * Note that PGDIR_SIZE must evenly divide TASK_SIZE. * Task size is: * - 0x9fc00000 (~2.5GB) for RV32. + * - 0x80000000 ( 2GB) for RV64 compat mode * - 0x4000000000 ( 256GB) for RV64 using SV39 mmu * - 0x800000000000 ( 128TB) for RV64 using SV48 mmu * - 0x100000000000000 ( 64PB) for RV64 using SV57 mmu @@ -877,10 +878,10 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) * Similarly for SV57, bits 63–57 must be equal to bit 56. */ #ifdef CONFIG_64BIT -#define TASK_SIZE_64 (PGDIR_SIZE * PTRS_PER_PGD / 2) +#define TASK_SIZE_64 (UL(1) << (VA_BITS - 1)) #ifdef CONFIG_COMPAT -#define TASK_SIZE_32 (_AC(0x80000000, UL)) +#define TASK_SIZE_32 (UL(1) << (VA_BITS_SV32 - 1)) #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ TASK_SIZE_32 : TASK_SIZE_64) #else