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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8162C04A94 for ; Thu, 27 Jul 2023 12:33:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B39A6B0071; Thu, 27 Jul 2023 08:33:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 464B26B0074; Thu, 27 Jul 2023 08:33:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 352806B0075; Thu, 27 Jul 2023 08:33:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 259AB6B0071 for ; Thu, 27 Jul 2023 08:33:51 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EA651A059E for ; Thu, 27 Jul 2023 12:33:50 +0000 (UTC) X-FDA: 81057333420.20.0B26FF8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 32774100012 for ; Thu, 27 Jul 2023 12:33:47 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KryMqBMv; spf=pass (imf05.hostedemail.com: domain of conor@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=conor@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690461228; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sSRJ621p/V9LHZWQ95juYX1mSTxrblnSCB2e2kORw74=; b=fJ5OwPffxIFc6g1O5dhFAmCO1XRVFrm/jTeue2TN0o2QilGbtSQpaZgwBWrnO08shK4363 tgkuPrsXoTye8iXKu0/D3jnPqDGmq5GA2dAwR7rPXROFyDs5jpV1lL8baSJjCZ59AXjQYS eWoXHe956mghG8yhmweotpVaaBjSM7A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690461228; a=rsa-sha256; cv=none; b=7mRwDYjPwkxwAHMhxG272Lnr0DZHn07vZrOPCZ25/oia/lfvlnLWGHr0TYxf6UwApKGg+T u0Ot/iEEMR5qYgyNE8X2c4hrpmO+nmpiYlRZbIWR4g+Zjg37/gUzb68ws8f3olKbyISIis zS86SYlYz1S+54fkpqJgpSxZLG/Z994= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KryMqBMv; spf=pass (imf05.hostedemail.com: domain of conor@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=conor@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 12A5961E5D; Thu, 27 Jul 2023 12:33:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96677C433C8; Thu, 27 Jul 2023 12:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690461226; bh=7VsMmtHFnt3Mu8te/EKSf4+ZEamhC9GT5n3lbZ8HcF0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KryMqBMvkbHpL7pIWShH5LDgkQwzn4vj30MjLrUKKcupCQw0pYVMWO+JBKD8n74es WSTLcMbzb5HcSjtxpdsDLQwgyhjDziMh1rIQIcpVZJkJ7q998QwCJWE/d7v0gugot4 lSNcnerOHaHeiPZ8yFSFVOl7fS9POcfpRAmJjLpZiaKHW+Nx3KReQ11+0xcQEYj7Rd BYx9/GYFS36xA68BhbZyefhKmdfTIkMAPz0pV+P+CYLrpIkspEY7815Ho+n4rzaqv5 IQueyjIk4ayVdFn7Anr+T4fEMCaRfUQ6MmvGBSYP01oVnG8BngrTSLuoH+1kgZ3DqI KlyaLbKhTAwHg== Date: Thu, 27 Jul 2023 13:33:41 +0100 From: Conor Dooley To: Charlie Jenkins Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@rivosinc.com, aou@eecs.berkeley.edu, anup@brainfault.org, konstantin@linuxfoundation.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, mick@ics.forth.gr, jrtc27@jrtc27.com, rdunlap@infradead.org, alexghiti@rivosinc.com Subject: Re: [PATCH v7 1/4] RISC-V: mm: Restrict address space for sv39,sv48,sv57 Message-ID: <20230727-unruffled-joyride-410fc348ce7b@spud> References: <20230726164620.717288-1-charlie@rivosinc.com> <20230726164620.717288-2-charlie@rivosinc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0svxelhh/GmhJGt3" Content-Disposition: inline In-Reply-To: <20230726164620.717288-2-charlie@rivosinc.com> X-Rspamd-Queue-Id: 32774100012 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: fg16ry61cigjxq98nf7psrqtyotfu68u X-HE-Tag: 1690461227-798740 X-HE-Meta: U2FsdGVkX19FqwM86cjb3sgvZ8RnsAKbQesgP3ZLGcCNCMP0+fseHHhKUwdOJ7avBw+YBzgYJYBdYfsflL6ZCKdXLqAYn83SkCqXdEYHAcc+Sra3Z4nrOic3WTLZDc4C3RDtwhTDtxR5jJnTy1PULsbvn6DND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fa+UTT6WLT2kRGcnrTNHt8Y4yl8zH0EJLR144yADYAjmtqx6QoQfc/GkpvgcnM6acW/r2NWc5MPr+nSlkupUcT9u/XKXvGj1JNYpNPAXtaJ4dmRiGTtGHnIzaocYoVu9OskfjeAlGZRaZSdu0xEBZYSvwd2H0NxLHNvSGITpuxCYJkebXd2nI5w86c9d5zk2AuL7zbVkBjmwe19ucqglxE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --0svxelhh/GmhJGt3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey Charlie, On Wed, Jul 26, 2023 at 09:45:55AM -0700, Charlie Jenkins wrote: > Make sv48 the default address space for mmap as some applications > currently depend on this assumption. A hint address passed to mmap will > cause the largest address space that fits entirely into the hint to be > used. If the hint is less than or equal to 1<<38, an sv39 address will > be used. An exception is that if the hint address is 0, then a sv48 > address will be used. After an address space is completely full, the next > smallest address space will be used. >=20 > Signed-off-by: Charlie Jenkins > --- > arch/riscv/include/asm/elf.h | 2 +- > arch/riscv/include/asm/pgtable.h | 13 ++++++++- > arch/riscv/include/asm/processor.h | 47 +++++++++++++++++++++++++----- > 3 files changed, 53 insertions(+), 9 deletions(-) >=20 > diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h > index c24280774caf..5d3368d5585c 100644 > --- a/arch/riscv/include/asm/elf.h > +++ b/arch/riscv/include/asm/elf.h > @@ -49,7 +49,7 @@ extern bool compat_elf_check_arch(Elf32_Ehdr *hdr); > * the loader. We need to make sure that it is out of the way of the pr= ogram > * that it will "exec", and that there is sufficient room for the brk. > */ > -#define ELF_ET_DYN_BASE ((TASK_SIZE / 3) * 2) > +#define ELF_ET_DYN_BASE ((DEFAULT_MAP_WINDOW / 3) * 2) > =20 > #ifdef CONFIG_64BIT > #ifdef CONFIG_COMPAT > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pg= table.h > index 75970ee2bda2..530f6a171a2b 100644 > --- a/arch/riscv/include/asm/pgtable.h > +++ b/arch/riscv/include/asm/pgtable.h > @@ -63,12 +63,23 @@ > * position vmemmap directly below the VMALLOC region. > */ > #ifdef CONFIG_64BIT > +#define VA_BITS_SV39 39 > +#define VA_BITS_SV48 48 > +#define VA_BITS_SV57 57 > + > +#define VA_USER_SV39 (UL(1) << (VA_BITS_SV39 - 1)) > +#define VA_USER_SV48 (UL(1) << (VA_BITS_SV48 - 1)) > +#define VA_USER_SV57 (UL(1) << (VA_BITS_SV57 - 1)) > + > #define VA_BITS (pgtable_l5_enabled ? \ > - 57 : (pgtable_l4_enabled ? 48 : 39)) > + VA_BITS_SV57 : (pgtable_l4_enabled ? VA_BITS_SV48 : VA_BITS_SV39)) > #else > #define VA_BITS 32 > #endif Please, at the very least, build test things for rv32 if you are going to change things in mm: io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_S= V39' io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_S= V39' io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_S= V39' io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_S= V39' io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_S= V39' io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_S= V39' mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39' mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39' Thanks, Conor. --0svxelhh/GmhJGt3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZMJkJQAKCRB4tDGHoIJi 0mzpAPwJWPSKvd4h8Mm2l0MHa3fl9fuzK7BKyFcMJpsby/MFOgEA/1VnfZ0R7Xf9 N3Mv5qgorgiDhx/vTvbCdG/fUFEpCwk= =LPTS -----END PGP SIGNATURE----- --0svxelhh/GmhJGt3--