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 7F129C001DE for ; Wed, 26 Jul 2023 13:52:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C273F6B0071; Wed, 26 Jul 2023 09:52:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB06F6B0072; Wed, 26 Jul 2023 09:52:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A511C6B0074; Wed, 26 Jul 2023 09:52:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8FD4C6B0071 for ; Wed, 26 Jul 2023 09:52:24 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D8728140C90 for ; Wed, 26 Jul 2023 13:52:23 +0000 (UTC) X-FDA: 81053902566.14.EA4AAA4 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf08.hostedemail.com (Postfix) with ESMTP id 9930A160003 for ; Wed, 26 Jul 2023 13:52:21 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=oljGFhSa; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690379541; a=rsa-sha256; cv=none; b=CqgO/HRIfZqc9SAzN3z2WPyTGeTz9eV+1SvLcyMj1kTw2KK7AWFMLpkoVkJmiqwornJ61G Xocgsm4lDhMemGhYMvJxqWQ9ixn6XHVv1SrUKzU3jZpiodF6uXgpWIBMmz5LoUozLALuRg aHNDiBizzs84Th1HXSNXK4Ve+p+OKuU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=oljGFhSa; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690379541; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ey/D5M5CPmKQzId6+XsuiPGSyzaXamRUEWGT1BcC7g8=; b=XlG0TeJKOsG+rqaGDHDDWe2pJdm2JH+D7Pp8YrCcTVexGjON/fsCjz8MtysvxIDe/6mnJE E36mLexnGAxdvIqidbUW7iIOL9FaVVJbq0ZL2POTOMWbC85eB7y/HYDf/ZNy8Z8cAgtnYQ RH6LbnxHPKbfaKEp0WdI14fs2n0l34g= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-666ecb21f86so6298718b3a.3 for ; Wed, 26 Jul 2023 06:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1690379540; x=1690984340; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Ey/D5M5CPmKQzId6+XsuiPGSyzaXamRUEWGT1BcC7g8=; b=oljGFhSavZjxkXX9CucTy5gLK6qGX0I821ndm/pPrymKSKvJ3P/6/lBeLNfqGQ4Prz yG8vGsi8TbRKYjWbNGsB7yiDHaa22xpMOxU5nHjrXLOpOpFIaRgQgmi30rvNMGGaQlnA aPogyoGDwEByaH6x2bu+i8DUJ8aQuv5RYESZZc2lxWmys95qEqie9+VLr28t9jXKQoGb ACUOHsx+Kh0P0USxXLLtGjTtYmJCoHLrvO3TngfJVNsHF6lP/Mjr03UuslceDWRR7aFU P220Nkr1pYqcfa9oPNp6sOExUOn8A0YJcEA5TAhibvstRj/Q8VU7/V3AREKD6GV4ila3 mM1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690379540; x=1690984340; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ey/D5M5CPmKQzId6+XsuiPGSyzaXamRUEWGT1BcC7g8=; b=CPL06nN0FZzLaz3l2BcNJVmGiixqAIVgK62dDgNMjxhncu3YJr290EuOr5jQyfltFQ fc68ftUCtdJaMysYqjFX08rgZS8DzGlt8BTG+YI700QJytqkW4OvNOgII9gYWWd0NdaL 6N5549whKB23hdHU9qsg5Iet7bdMb4CyIMcasGRoGTwzsX/BNLYS1FACgb+/3RSj7nMP N4v9bQyHU9ASjUzimctBVaGO6eGJ98zhlH9M28eA5fHLqdug4DUQNjz0IENCDnWfVfkY cuvAhkHXfiB4yxZVQdVSzEu4gtHF8YXqO+J58SjnouVcy6d0Fohbz3xuUbvbf6KSUJYb d80w== X-Gm-Message-State: ABy/qLZj+nGS9B8YdecG0YD3aLfJDUqkkeidJjJkj8X7hQefcurYwE7M k06hC5+5N7t50ukO5bVpEVB3NA== X-Google-Smtp-Source: APBJJlGGggspPA6ImxibgpDOjxq8NwN3+9CEYkMOcJSUt5QiwCOV4FVffsYERBKNj9SOSpMuSGApCw== X-Received: by 2002:a05:6a00:234c:b0:686:c7be:5259 with SMTP id j12-20020a056a00234c00b00686c7be5259mr2598630pfj.32.1690379540161; Wed, 26 Jul 2023 06:52:20 -0700 (PDT) Received: from ghost ([2601:c0:ca7f:e7c0:14ff:979a:dd27:29d7]) by smtp.gmail.com with ESMTPSA id d134-20020a63368c000000b0055be951145csm12722952pga.36.2023.07.26.06.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 06:52:19 -0700 (PDT) Date: Wed, 26 Jul 2023 09:52:15 -0400 From: Charlie Jenkins To: Alexandre Ghiti Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, 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 Subject: Re: [PATCH v6 4/4] RISC-V: mm: Document mmap changes Message-ID: References: <20230714165508.94561-1-charlie@rivosinc.com> <20230714165508.94561-5-charlie@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9930A160003 X-Stat-Signature: oy7nghnydo86ju1hy6sah9zp35qc6toi X-Rspam-User: X-HE-Tag: 1690379541-38601 X-HE-Meta: U2FsdGVkX1+wy6MfHSUrScWdEECVN873RyMUAGlp6kNCxOLdeCgMIPiTPm4Ug5LFqpQYUiWNpvxcLCPwzRY2qdVa8r8ULELQ9+VakOdMD5CH0KjJbzoLQA1k0JiWUl4MzuJXPyvnKtTQFCl3+llHl9DVLu7DZP6L+L20885mSxF7vgD2QXW3Li03ivYZpieUqZ7qeZylpPmUZzgZQtRxfZvMzdFX59CpD0KvOo2nsibtpUhLgk5oJ5X/VOuLXCPOXB5oBEwNZFe5QD1M29CgXutiYv7qlREkYwG95GwQPuoYuuCAhjpH72nQW9NsurujtT0o2S7r35qytk4cynl/xAzdhMponFm37bw/Fl1BigTmiXTpbNWxyVb10UYTciNwI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ham, tests=bogofilter, spamicity=0.000065, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jul 20, 2023 at 08:59:12AM +0200, Alexandre Ghiti wrote: > On Fri, Jul 14, 2023 at 6:56 PM Charlie Jenkins wrote: > > > > 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. > > Is this correct? Shouldn't the hint be strictly greater than the > address space it targets? In patch 1, you state that "A hint address > passed to mmap will cause the largest address space that fits entirely > into the hint to be used", it seems contradictory to me. > That is a mistake, it should have a hint address greater than 1 << 47. I will fix up the wording here. > > 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 > >