From patchwork Wed Jan 31 01:07:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 194422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1600488dyb; Tue, 30 Jan 2024 17:08:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IENAYtrSDFBbX7isNqNNiu7OxZyS4jKuDdcnZ2gApfHbWD690vYLUfRs7vYYdeJeC4yPSpk X-Received: by 2002:a05:6830:3113:b0:6dd:efd1:763a with SMTP id b19-20020a056830311300b006ddefd1763amr73326ots.31.1706663323893; Tue, 30 Jan 2024 17:08:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706663323; cv=pass; d=google.com; s=arc-20160816; b=JFMmhoyQEHoYDx0ir3L7HPX2PJFAX7iXGnQ+ezgsokz+8snsZBMW+/jKRujT+YvWwZ gWL+UhA5i0eAEsVQWus9yTr10Xg7l+Wn77C+/PreF+dokrn54xb20ge0/G1QC/cXi/GI NdfIPSrk+OW+QDKVB6DI+5aDSXYOCSz5FCFH0cXA060pAsQLJIU9i8OgmiNhWd3MHg07 6SjNHpbo+xUxjDxTpy62T6cE9cN1y7s7UmEF1Z8/Mc3Ze7nPUG4FIUm8OLcq+aTm22zF TfQDOpNdVGdYtvLb0TYmKdz5qFY+tbkrZjB0bjueN+Q6ytuHcOp1zm37wIjIwrVkO7TW hqrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=GGh1y1t0UhB5LcXiFRn0m1YgEny22RmTe/CDN12WiLQ=; fh=O3hZTfgLTiU+PpJJSGgH0qe9xyFlcRrYYGwCFWooQQM=; b=lzN+JfcO1VSlKHm/nb+sesTkmHCqhUqE383GCvd90YWVRYzFxAhjRsnJu4jL0Y0oBT xPu8Vr098/Dl8Z4mESteNX5wS4CJe/FxJtAZwMmK7KScAq5PwgcfnSK4+g47Oi4ZZ0zl YdcPc3QUWT/Rq6q+HB7ga2j7KM7vDv1ebVD8pClBRlP0hE2GfhaZBoDFLzt6Rp0nJxdD 5XnzDET1zMOUrAgvwQXVzkNobQT97njrRf669h1A8GUPY5CLTSoRhYvjkTCS0BR3qFQC 7XAdPFbScoiVoH7ABWv6TGw2et4VIURwUnS8KbmxVqX+Hw8krGzxWFS7xZ1x5P5fYgaq eo2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Yu4dJrGi; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-45570-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45570-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWW6SgXCB1FmRzjvZf6MUJHHttMEgFeNyvR1g5FrjAQ2M9wj8s4KAsVyPX+VsL1P4CE6SoJbFYmi3t5Dj4GtemCgeUwAg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k9-20020a63ba09000000b005cee179d5c4si8271485pgf.230.2024.01.30.17.08.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 17:08:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45570-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Yu4dJrGi; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-45570-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45570-ouuuleilei=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 001CAB24961 for ; Wed, 31 Jan 2024 01:08:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 643D6746B; Wed, 31 Jan 2024 01:07:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="Yu4dJrGi" Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 E09F0185E for ; Wed, 31 Jan 2024 01:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706663230; cv=none; b=tDyne3nrH4u2iKIEohmK8+JPF88FfdJelL7HTa2eNcuSs3SUTg1bWtLPra2TPMC5Es2skjFiU6E/sCrxVJH0klPW+xG51jo1jJEXhNqCpa5cnNMMbu6GxlKcJ5PR/zCu6WpSwP8jP6XVfgdmY5TLI+QaTkRWhLlzC5X+xL92sS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706663230; c=relaxed/simple; bh=2lxtSNzBMdkYqwC90W41TvLPqjzE8CkjIf8iMq/P7L4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U2224qoxsb8OVoG5dk9xFQTg783CsxhAjZJqB8MS82MToJAvoHbLyQ87ypaAzU1JrPYnxgik0uvL8myPbse2DUAmwsu1rD62tnQ9dd/BGVEDp9U03PQWe9PmgFsy56MIlj2wPk6bqrAKb9XQics7KaIf1pRzI/eXWp/YIYnqT0E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=Yu4dJrGi; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d746ce7d13so38370105ad.0 for ; Tue, 30 Jan 2024 17:07:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706663228; x=1707268028; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GGh1y1t0UhB5LcXiFRn0m1YgEny22RmTe/CDN12WiLQ=; b=Yu4dJrGi0IiDCFrpiqOLpDobeO92AFXkezCwPWsw/oaztxOemXJY57rq0+tk6HeDWn SMvK/q+uW8H416VONvYwknTIiUxb0L5Qo9OiGr8lO9mbrg6SjjZI11XDWqgoqLBPZOJk Y0j/tlIPvwlzRjCUi7biS6r2pECwzg3YEeYZelC1RW6rG0p87fpYpfd8qKKcccHKl/7P CvBiJ2CdsTudiTl3Z4M+QRRtB+EIXCAzmX8shU8OEka5yt3oTfpBC6KZj5ZWUyfshFlu ppMexHdpGFXYccRrCFTH5kfjt9sE2sX7hgORhXC8DyRjnI2tc3dfAaf/OH1wx6q6kRxG NvQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706663228; x=1707268028; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GGh1y1t0UhB5LcXiFRn0m1YgEny22RmTe/CDN12WiLQ=; b=bX1q1FHnKuL/PDWWT/KHya4ovuFNaOqlXvwpx3aSmRrU0yk8tjX/jUCoFK7w9AeUdR i36EOpDymS/T/BQp85sfWow7diuVA55o8zICenUQaKBHrYbEoQO0XP6gUW/joLphCtwR qR0QfPbZ2uuEkViytSoNb8tafMN/YsPs1Kb82J6ail1D3O9JwhmQzLxvWIfBzXNo0iCx 1o6aeOEsksxPKp2c5LbXfpsRfdgyFTqmsd+QtfZcnev4aNwENufOC+raX3eySrghd5mf /GghnmCapKaZcquIsvBtUNKv0xbmPBSTPdIHql/kKUZVXtKLzyH5Pkeplv00UWUFOfIK PnSQ== X-Gm-Message-State: AOJu0YxOucO1JehRDN5BPeNBB0YaCL0HVj4DWekW1NZRDhTDPrHih/Gg 5zx8nOKHIjtqrHEAlVEoiWBCMScO8Ox26oJxjbRfrtNNrafafzT/q5cial+YFco= X-Received: by 2002:a17:902:ed94:b0:1d7:310e:1e0d with SMTP id e20-20020a170902ed9400b001d7310e1e0dmr263865plj.32.1706663228198; Tue, 30 Jan 2024 17:07:08 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id r12-20020a170903410c00b001d8d3c276c4sm4970822pld.35.2024.01.30.17.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 17:07:07 -0800 (PST) From: Charlie Jenkins Date: Tue, 30 Jan 2024 17:07:02 -0800 Subject: [PATCH v3 3/3] docs: riscv: Define behavior of mmap Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240130-use_mmap_hint_address-v3-3-8a655cfa8bcb@rivosinc.com> References: <20240130-use_mmap_hint_address-v3-0-8a655cfa8bcb@rivosinc.com> In-Reply-To: <20240130-use_mmap_hint_address-v3-0-8a655cfa8bcb@rivosinc.com> To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , Jonathan Corbet , Yangyu Chen Cc: linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706663222; l=1848; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=2lxtSNzBMdkYqwC90W41TvLPqjzE8CkjIf8iMq/P7L4=; b=VULcNJMPaGSSibunnHmdY8O6pSGdUfVoHdHqVkSZ/6IDh4hPdQyOg/2Va726eHw2pMLSxc0cG 87Fixe/YDGPCXhl08WlTq3vxGBa82+KW2s0J79eiJ6OVp8GW8Fgr/ii X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789566201516857277 X-GMAIL-MSGID: 1789566201516857277 Define mmap on riscv to not provide an address that uses more bits than the hint address, if provided. Signed-off-by: Charlie Jenkins --- Documentation/arch/riscv/vm-layout.rst | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Documentation/arch/riscv/vm-layout.rst b/Documentation/arch/riscv/vm-layout.rst index 69ff6da1dbf8..e476b4386bd9 100644 --- a/Documentation/arch/riscv/vm-layout.rst +++ b/Documentation/arch/riscv/vm-layout.rst @@ -144,14 +144,8 @@ passing 0 into the hint address parameter of mmap. On CPUs with an address space smaller than sv48, the CPU maximum supported address space will be the default. Software can "opt-in" to receiving VAs from another VA space by providing -a hint address to mmap. A hint address passed to mmap will cause the largest -address space that fits entirely into the hint to be used, unless there is no -space left in the address space. If there is no space available in the requested -address space, an address in the next smallest available address space will be -returned. - -For example, in order to obtain 48-bit VA space, a hint address greater than -:code:`1 << 47` must be provided. Note that this is 47 due to sv48 userspace -ending at :code:`1 << 47` and the addresses beyond this are reserved for the -kernel. Similarly, to obtain 57-bit VA space addresses, a hint address greater -than or equal to :code:`1 << 56` must be provided. +a hint address to mmap. When a hint address is passed to mmap, the returned +address will never use more bits than the hint address. For example, if a hint +address of `1 << 40` is passed to mmap, a valid returned address will never use +bits 41 through 63. If no mappable addresses are available in that range, mmap +will return `MAP_FAILED`.