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 8155EC001B0 for ; Fri, 14 Jul 2023 00:15:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 127998E0008; Thu, 13 Jul 2023 20:15:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D73A8E0001; Thu, 13 Jul 2023 20:15:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E94178E0008; Thu, 13 Jul 2023 20:15:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D6AD78E0001 for ; Thu, 13 Jul 2023 20:15:11 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9E38B1203D6 for ; Fri, 14 Jul 2023 00:15:11 +0000 (UTC) X-FDA: 81008297622.11.BF84A4A Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf21.hostedemail.com (Postfix) with ESMTP id CBEF11C0020 for ; Fri, 14 Jul 2023 00:15:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=xExIMHzL; dmarc=none; spf=pass (imf21.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689293709; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iY0BqE22+vH8ihdQ5F+U3lQTo4OY0Ve5Zo6wbRWfHfc=; b=eB6INveydNCOHt51fRLoVtFATxcG8rkHKTyNqL8YrVUmsrD5M0rAqn0kGiiHI07633C6/+ oo8rAvartWXjk0p8z1CLTaFG6Isvpz6ODCM4WIbjGs3kBC8bs+DLmlzL4qZ40FnqCzX/7K 2+Nhwov9Ik2MHKZz1UZKWdpbRKzSXEw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=xExIMHzL; dmarc=none; spf=pass (imf21.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689293709; a=rsa-sha256; cv=none; b=kDD9S7sGKQdkEwESd28NW/1D9uTEdHBawLr+KgF1xuoEuVBXVIB/t2vwDEf6VonkIB6pwb acwOD0a6N4GxY1c97nyqEe/k/qqSGXqiKjxr55KuV+gYmpw1lPUghdmENKkfKP5gKNcPTK JEk5bL4zw1mrumHKAEd074WjGqB8mpA= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-666e6ecb52dso927669b3a.2 for ; Thu, 13 Jul 2023 17:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1689293709; x=1689898509; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iY0BqE22+vH8ihdQ5F+U3lQTo4OY0Ve5Zo6wbRWfHfc=; b=xExIMHzLTtkjN2LFQngS3OX4jDs1xLdIX7r/tiDx0kppQfQRkPMYGwyfuGwrBTa86a XoaNrcUcmG5pmtq3t+bqbkNwiHPqfObctew9lUGCvXVSRZ5ZMzwxuDl5bh0kXZqCOeN/ 2KOkMuhJYkV6QfPobPU9mX56qewrBddlJ17DJjsRmikAwwn6WVy6MHjfUpM665kqgqnx 8Vd77tSJfClsrB+dbBunC3han9WPucnmhgEbe2AxB1x5RWqedcL/TQmo7JAbJuXl1Q+J +JuGlcjr4IzBotD3ZK9zOhKx+93UelIHVMWCiiWjS83cS6p52MDULRTAs1+X2jnehbH9 5cQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689293709; x=1689898509; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iY0BqE22+vH8ihdQ5F+U3lQTo4OY0Ve5Zo6wbRWfHfc=; b=Pw06XIxuCF78bXh3yLoShRaPxD21mIFYK6Y8ReWudiCn3asjEmXzsun+CFFiRzzjmt 2V6/JYLDcrnt9FEerF5xLDcYEY/4O3kBgi109b1JCFz90bZkE2ud8h+ZZbQS27Y2QC5O 5jFNCn0yFhEnKVUWBdsqpyfur69VY+1ofUCdibHIvNvyV4RsyJ45nBfbFW2OJUeYsAVK gws3y6XdtpcM6lO1g2ULwcsBoz2EfS9GHB8MOn4Nl6B28//3Ll5mDuZU5pT08GmAX6ui qjVGNE+zrW/VZSyeFkXFpzGeGHE1kuNzdXo3snNOTGF9AjVGGk0UKvCxOK2HcCVAgaYe MA2A== X-Gm-Message-State: ABy/qLYgIsMmUgCgAJjqxyOPO40ShSi+xgN/vve71SPj9vz8i/n07kV9 WamcMPbzUVx6++VHWe27TOB7vw== X-Google-Smtp-Source: APBJJlE/NehJK/yZ31QQ51ruFcoOUZ8Dr5gN8omHKM50vUTZXpJ3oVnR2nhUcvBJtDwEUljTcHiqAg== X-Received: by 2002:a05:6a00:2d84:b0:666:8cbb:6e0f with SMTP id fb4-20020a056a002d8400b006668cbb6e0fmr3042793pfb.3.1689293708687; Thu, 13 Jul 2023 17:15:08 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id x25-20020aa793b9000000b00673e652985esm5938107pff.44.2023.07.13.17.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 17:15:08 -0700 (PDT) From: Charlie Jenkins To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: charlie@rivosinc.com, conor@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: [PATCH v5 4/4] RISC-V: mm: Document mmap changes Date: Thu, 13 Jul 2023 17:14:03 -0700 Message-ID: <20230714001430.75798-5-charlie@rivosinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714001430.75798-1-charlie@rivosinc.com> References: <20230714001430.75798-1-charlie@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CBEF11C0020 X-Stat-Signature: 4xer7e6ntqdxkk7g5jnpzh1ehmh9gfuc X-HE-Tag: 1689293709-419706 X-HE-Meta: U2FsdGVkX1/k9TKgyVIqnqLt+rc+TRmj97fGBnn6ijzYCjBynq7VcNzm/1i3E6aL2Z0j5ueY1823Q4PHxgGBB1ZcoZBICgqkJbH6CZyeOgBy1k2IOCfFfW3XEPs0ddYuFSJT4sl6nb6UrCW/SBybEB7NS5JZFln/suHmiLSKMJL45yvxZFILUEAOpgqHwICHcZJ123dGnUAdYTDvNUabX9pbTdbgqD5ODBj8SsW66/M2/X2bS+OmHfvSjyHTpyh9VDaEtwByqvJXwxpwWWezj/O30TEnauj5eaW6afifhmSWMAikV8gzGUGjG6h/VIdULM0omfQve/5w5fvFJhVAjzBRskh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/9YwU6AfX55h X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The behavior of mmap is modified with this patch series, so explain the changes to the mmap hint address behavior. Signed-off-by: Charlie Jenkins --- Documentation/riscv/vm-layout.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Documentation/riscv/vm-layout.rst b/Documentation/riscv/vm-layout.rst index 5462c84f4723..892412b91300 100644 --- a/Documentation/riscv/vm-layout.rst +++ b/Documentation/riscv/vm-layout.rst @@ -133,3 +133,25 @@ RISC-V Linux Kernel SV57 ffffffff00000000 | -4 GB | ffffffff7fffffff | 2 GB | modules, BPF ffffffff80000000 | -2 GB | ffffffffffffffff | 2 GB | kernel __________________|____________|__________________|_________|____________________________________________________________ + + +Userspace VAs +-------------------- +To maintain compatibility with software that relies on the VA space with a +maximum of 48 bits the kernel will, by default, return virtual addresses to +userspace from a 48-bit range (sv48). This default behavior is achieved by +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 call to mmap is guaranteed to return an address +that will not override the unset left-aligned bits in the hint address, +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 << 38` must be provided. Note that this is 38 due to sv39 userspace +ending at :code:`1 << 38` 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 << 47` must be provided. -- 2.41.0