From patchwork Tue Jan 30 00:37: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: 193753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp917939dyb; Mon, 29 Jan 2024 16:38:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw2kTlGqRWdkqL0kBT28fEgc+dWscBPNg6y6qamsDsKQVUfN20awxXmytiF/LzaFuNh58T X-Received: by 2002:a17:90a:d255:b0:295:8926:df07 with SMTP id o21-20020a17090ad25500b002958926df07mr206392pjw.23.1706575121092; Mon, 29 Jan 2024 16:38:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706575121; cv=pass; d=google.com; s=arc-20160816; b=tVHFxB8+DIwevHs0K5sq3X+3mKY50ACNYu363C5l1a7i1wuJUYs3i2ZWauWrSoOm1e IYfSzcH5MgcYbpw0Aew4tyZB8lndyaX9JEZrhopQqocbKfTK5zw9RS08PpoZ3UusPp3H 8dBo7fMvxZYYr3+ml2C7jekkSqpNoadzY1Uo41ufLgqA33DKoKpfS59e0NMkwt7dHjrC bFeal78gwprVDhWCIjoiyz2oqA1rJ8NccFE2Oy8znPoFg1vKsW6DT0OBKE5CAF0/U/jH bU0RRh9xWqhE+eRPxO1aV4tPjrxG580x8On/95tl/ll+G6qdC8/dHyjlH3g4TAACWhOE T42Q== 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=tLclIlyU88Vzn3up1knLemRita6WFLG6yunDoupoLaw=; b=u2OabLqOKi8VaVu+amslE+8+rMMruJeWg8ZM4OiFs9OZr2c2ETr/cFOl7r9doTJHcW HJOK1nTtH8a/XUWt+djja4VDf43LMoLRsZMSnLENK4LM7uzQSpvts6jUxX3qQ+dG8KcC Zg5p+5j/VCYhh59tPNXro8EeA1e5PlcLwHAGMH9thuMH0xi3FT7/vJDhfFn2LqdTpTvB i2NOHIxadFi61303nClF4GY3OxPTRFiICmX9FnR+Xd9xl9etYv0zJUZfwpPCYuGp57MV fCNp0GmL7Ly8M8UW4z5S97j4TEaa9WVbktYniBLoXCexVKRedoS/kXOWycTjfb9mYt6Y tKlg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=PLaCqzj5; 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-43682-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43682-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 138-20020a630290000000b005d818072f2esi5917113pgc.874.2024.01.29.16.38.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 16:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43682-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=PLaCqzj5; 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-43682-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43682-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 687CD281F09 for ; Tue, 30 Jan 2024 00:38:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CB58374CC; Tue, 30 Jan 2024 00:37:12 +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="PLaCqzj5" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 BBCBB3611D for ; Tue, 30 Jan 2024 00:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706575029; cv=none; b=WQCYmlKG+8W4TBKS/pOALDclocFbOO32N2fUvWv/zOTYBlXJ/felmGrnFOqGzGqwU8hoav7hG7Hk+46Ru0tVUNnXNJb9CTuLLt1eM7gKhYRDHVzVZ0BiYsZignHMlapPSJ9/CBPC0UA3BNfiFNI4mewS/Dnw9jOgtaNlWyXb5Ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706575029; c=relaxed/simple; bh=2lxtSNzBMdkYqwC90W41TvLPqjzE8CkjIf8iMq/P7L4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d53mExzus5gUAIw3tDZJJlweJY8Z3YyZdZkJxAOw32Z2B0kWc+awIGWSk+TJv0aMvOR42zRz4PLUE8GdZY1KXSBrG76pOp2h2cLzIsfHnGBTKS1zMq9Hkkx6YojPM/cVJUYhKbLBr5Uf9f3mvJHhM8qr/vTS85hZbcCXukRk4Do= 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=PLaCqzj5; arc=none smtp.client-ip=209.85.214.177 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-f177.google.com with SMTP id d9443c01a7336-1d8d747a3bcso11783215ad.0 for ; Mon, 29 Jan 2024 16:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706575027; x=1707179827; 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=PLaCqzj5KKS80QsD9xfutVJAfGZdQuCFzhm9Gc2jtQ/2sWXLNdiEFBuaokF7WVBn6i 54EIsCqvdaGz+fMdKrX6DJPDoqo2Zkckl9eW9ufk0FhmQPSZqkv8GlWA619Ztot1clUy wpDApZvJ5KTC+JYZ3ojBgowCahm4OKQaGYkkVoNdWYIk2+K+apfcEA15xLN3JA1MIRDF /Oiu6ftN4PCXxJC239+cbar7CCzHuTLhuEZOAmaHoGeuLSD1AJ97JQ/3/qFbGZbqCLd7 PSB6A5gNa9bteCw3HZJVv+G8BsYWYSinfYEESfMO014wpz+9EWmDOtUJfxMxLq3Pk+8a n3vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706575027; x=1707179827; 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=IF6it0JQjaSnR/addCSKB4PyW3Fb4h0iR2ya6KWa5VVe0rXRkjK0eIZjtMpOyTHq1j +CXomm8kQLUkSiRvG4FjHhy2p+PJbupe2X6kzKW2nwspM+YlE4KL/MrTuQv+ngLEPmqu C/23pMIWCry6EnhKvLqN1iFyBYP+YBeaqwTU56+Utdl+6TAEESjPvjquUHpJg0bjienH QeMJc2sY2Yymo04luZbOBW/EBP/YCzb+aRpmn0i61N8fyf7qjMsBNKEEtGwCj6PjhKVF Q37I9iu/YWywRhafUh/dgv4oD+qXIk4vVbCPaLC1Q2kNXnT6CjGtcmuryqCu+JAxR0M+ 7ZOw== X-Gm-Message-State: AOJu0Yx9zV6DRR4vpda510nPJnLFimf2nQMS8mYyZdn+BhI7WwQ7uIFV FYOick71cbFNZLoqBpZ38wcMJymTZMG/AfCr7uFm0nC67zZWHIIagjfDZAGcjtU= X-Received: by 2002:a17:902:aa85:b0:1d7:c27:2d3c with SMTP id d5-20020a170902aa8500b001d70c272d3cmr167643plr.6.1706575026971; Mon, 29 Jan 2024 16:37:06 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id jb9-20020a170903258900b001d8ca3f5e3fsm3406375plb.295.2024.01.29.16.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 16:37:06 -0800 (PST) From: Charlie Jenkins Date: Mon, 29 Jan 2024 16:37:02 -0800 Subject: [PATCH 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: <20240129-use_mmap_hint_address-v1-3-4c74da813ba1@rivosinc.com> References: <20240129-use_mmap_hint_address-v1-0-4c74da813ba1@rivosinc.com> In-Reply-To: <20240129-use_mmap_hint_address-v1-0-4c74da813ba1@rivosinc.com> To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , Jonathan Corbet , Yangyu Chen Cc: 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=1706575021; l=1848; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=2lxtSNzBMdkYqwC90W41TvLPqjzE8CkjIf8iMq/P7L4=; b=QPhNUZqLeF06ra6K2PNPRoG2n2KtsSvNFDvTmTdvBMXOdHUuJmeRUi0njObakAeeuV1OfWo9q etNa+1gFzv1ASKXjUaBTpqtMsyWVZXNQhlsEPcntfZJU7CZKds0vnLR X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789473714038024104 X-GMAIL-MSGID: 1789473714038024104 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`.