Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp743918rdb; Fri, 22 Dec 2023 03:59:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGDqWO0qIXfjhsQ/iNtBVLkxWQUTz7f22D8cJGrMMnAX5CiO1fsOT0aOGU9w+EpnI9/axX X-Received: by 2002:a17:906:57d4:b0:a23:3292:9fc2 with SMTP id u20-20020a17090657d400b00a2332929fc2mr728159ejr.33.1703246353433; Fri, 22 Dec 2023 03:59:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703246353; cv=none; d=google.com; s=arc-20160816; b=LY41yaPpC/ThBn34oCW5DSBn0duF14OUQFr7v8BlS4GMisuQ2JpifqrOkIZufZ/EaZ Fdu6ZHYiSIEj0961sbjmKclU++N1N5OW0WgOokiA/LqM3P6t3EZBIB34UEgpkvmHaaLC AkppvIdNhPJDiAuL1v7mdSnyVQvWriTx42L7HbSlr9pGnss7nEXOz3YnvOIyWyGv5Q3u TDrj1fqGcnXy4Uk0ouILfkClCKsz2Rt4wgObzqKiBA/G03aqjBSPiHkp2aTiLpKq3Pjb IL0OdnDYRzqgWYFSYFNE7EpQSE28Urxoi76dnzYaEolukAOlalKkwTW7vbOO5o6YK8o/ Y/RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oOZZs3PpDAkDeF0MOjYrzS4GP5LC1t8VKDdE5SDt6qw=; fh=+2B64yVuborNRhR0hRJ4G06jDIODc2br0dk92JgFIMw=; b=aMct/qhhh2TxenihWEOQJXUwfODOLrbwKFVTnA0AV86CY0afjcPx4KP1PH6d2OKpAK nD2Wun1K0P9ODzwwr4/ae39YEwloWr1cQC0L4HMA4e5vrHjFWMLB/OS5nWMExZ/P6NPF jryC7IZhYV/CNACP/kDGJ1lmwKGyc3tHBjBjwSpzfq9qHCsrSXQDdpcucaHQiFBQZ5vK 7lMS70vl4fuPDYfzDPcFw+bqhPtOuet8CouRW47YTZbJojaQUAuXg5NCCjB2dGGjqPJZ 5btvpJkHTT/Q5fZO392BEmUwbON/R9Sfpf8kM/v9ovVOBasr2aljGIo3ooPx35B5XfS/ Nbpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rjcGbIgb; spf=pass (google.com: domain of linux-kernel+bounces-9682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9682-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u12-20020a170906c40c00b00a26c852d39asi26976ejz.985.2023.12.22.03.59.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 03:59:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rjcGbIgb; spf=pass (google.com: domain of linux-kernel+bounces-9682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9682-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3260C1F257B1 for ; Fri, 22 Dec 2023 11:59:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEEE9179B3; Fri, 22 Dec 2023 11:57:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rjcGbIgb" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03AB317756 for ; Fri, 22 Dec 2023 11:57:36 +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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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 -- 2.40.1