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 22AFEEB64DA for ; Thu, 20 Jul 2023 06:59:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E2142800B9; Thu, 20 Jul 2023 02:59:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96A9728004C; Thu, 20 Jul 2023 02:59:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E47F2800B9; Thu, 20 Jul 2023 02:59:27 -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 6B66628004C for ; Thu, 20 Jul 2023 02:59:27 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 33618C0182 for ; Thu, 20 Jul 2023 06:59:27 +0000 (UTC) X-FDA: 81031089174.14.6B645FA Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by imf20.hostedemail.com (Postfix) with ESMTP id 3F73A1C0022 for ; Thu, 20 Jul 2023 06:59:24 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ZDbx6qAc; dmarc=none; spf=pass (imf20.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689836365; 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=pT1DoIojr0lvslKOunqTR4YXj4PFl+5LQJAMXq3nC5E=; b=TEalPQGUzEeC3Ehkr+X5V62kyw0oWPzn+m8LDdM412aTJ1+cKqyJK39zKnL+lCBtaSj9Xa lmCwIdPmmz4rquBNMK7JQ4qjH9HpyLgNsix2vEUGIkydIvWHjFsXVQc7FvebJir9n/hnr4 i4f10UEEeNbKHkBtJQw3Q90ii06E14E= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ZDbx6qAc; dmarc=none; spf=pass (imf20.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689836365; a=rsa-sha256; cv=none; b=S2/p+FhgH3OsXJNWaBQsfLpTXCSROdaufY7KyEv6rXSnZBusgIbtx2kU0zYjS1k2SVZaTG w4F2XdfKlmnO9l5wHria0EHN6lQb5db9R6+R3srD+qus3T5ePabErrSrMZ9EBzPoxjre/r PNqgpBeDv5RXU8gNIZBFJUSRPGd+OWQ= Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-31441bc0092so337373f8f.1 for ; Wed, 19 Jul 2023 23:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1689836364; x=1690441164; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pT1DoIojr0lvslKOunqTR4YXj4PFl+5LQJAMXq3nC5E=; b=ZDbx6qAcN8P+a9zusWZTkSl9rouTQF/iSqEtve1lkFjxsrKdWPD6dMC2Umr3gK0sIm nkzMw50TbmJwgcQIx++d1ggHjzr6+sA6GAKvbxlNWECwqbhFRvboEMDbjSOMt6CFznjJ O36ADGX1UaNkxZWfL7VJnxC+Cw3dNijMi+5cHTLgKK8SiFsVriuYykuE2k1SMWR22XY6 5WxT4DDw/UrHFcXUA/TDL5yUwwgAoniALRtBlkd8RbObdZKNO0W+L2Z2Ac61fVFTAtPL YHLVKQefTrzGZrXQCVxFRHfphf2SXdfAdIWaHdz9BRl6fVTzOf00WkysK5x98InR9zeP FHQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689836364; x=1690441164; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pT1DoIojr0lvslKOunqTR4YXj4PFl+5LQJAMXq3nC5E=; b=WAAemO92isCT8eQs0KC/L9YboBQFiW/P8kSLJJpO+4oJacmSAu8sk6VII7j/4BpwpY Bs0brG1LnngR4OIVM32ZggO0K3xoDbbqvqefqHrAzQ2sAodHY+PhCaMbiq/GmTgdaR3t 7PPqSPetDXA8OO1Sj4foV/KdJitD4wOGIjO91LPvRs2opSFLup6rFJQgyVSqO6yiznwO m6snKKueFx0v0D5WA1WD3MlhWpdRB3hByXR5YaFT4uHAO7HZIBoVq3dbgaGbn2TeVmej oWduIXScJ7IeqbkvIAVbTcSoo+qjSWQ21b9MwHUXbKe6aZg72CHrHwwGrcZs4Lsrs98P BQjQ== X-Gm-Message-State: ABy/qLanKGEUA+CDconaxeNweB94hS1tOIvfgyimY2xfTi8MSCiJ2118 d/YT6RzM6KQsjW9vfn93LdvKq9U2B9cEeBQED4LxPw== X-Google-Smtp-Source: APBJJlG41skPij9fp8nZyKeEoH9myLamnBgBOCZf3SxF3pb6Xp13yIhuN0hjhRkJju4WSDs1jm0RLUedZXc7rvYty9A= X-Received: by 2002:a05:6000:1c2:b0:30f:b7b4:3e55 with SMTP id t2-20020a05600001c200b0030fb7b43e55mr1436688wrx.19.1689836363671; Wed, 19 Jul 2023 23:59:23 -0700 (PDT) MIME-Version: 1.0 References: <20230714165508.94561-1-charlie@rivosinc.com> <20230714165508.94561-5-charlie@rivosinc.com> In-Reply-To: <20230714165508.94561-5-charlie@rivosinc.com> From: Alexandre Ghiti Date: Thu, 20 Jul 2023 08:59:12 +0200 Message-ID: Subject: Re: [PATCH v6 4/4] RISC-V: mm: Document mmap changes To: Charlie Jenkins 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 3F73A1C0022 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ueuyjpfxj17txih5g9thcmokxrcg84or X-HE-Tag: 1689836364-26508 X-HE-Meta: U2FsdGVkX1/jAFfgbsbS3WpVSn3aqdGRyMFTzzujlGzhF9oxM/mhk3Yx5P8k8fOLWwrXG+tsFemdhFqVdsUW7813EJ2/5yAmNWKUNPmOMndjMzjJPLk/dL5dk3ZczGfDFIT5B8deyY5+dbx/I3SXYtUJwTOdbHmSiy89WCmrNA1uRfL8I21JbtMQPg+T6CXVM3bX6mbPv5+FLGW33BK3KJu4ToJoU4VqhVdj7ITimNNKnpkSo5JfUphTCldGOKkdSgKnof1bTSxGxY3eLodSyIzImlRK/puV6a5gAFLDWvIWYzI8sWzAD/43R4cC6bWRAwJvi6wMww35s1PwzJ37QuUvBs0/n11CJ2zcFzb+zF8Id4ClykeAuxa7HSafD6Xb4iz+z80anp2XYbQOfQTyJboDTNOjHZG4eXgVZUx6Erofb3jIfJhU4qyHrImZyCzyl1wWxFT9SlaUeNC69/50/39t+Gi7uvPSDlK7KYqQekUzMvWkZeD0DnKx/XJMXhxO1egkTZe4gYtQUNVPJtWlu5qyEr0Yrkevy5SrnU8s+eLT+g2Yx8rXVPVyxV/+XQ5ogXxXsfWSG5TNiDBQyoYKlZzchNEourUQOmIDeXCs4V9nvPXq5AW1sbwLSPlfdWumBQsG9AixsZ5JTZhzRo0znGE9n8P8fL/+KvBoK4WIONpxZOcOGpZ5ODi+CEfWawqDNP2j4WeaAb82ACLZY5VbSLCeJoYFS28NVzRufIC51OaAhO3lfHR8gW8iyZ50B6G9pDAD7Gzk3Iu9/tghAjdNSMBsZcKhG3QjPSuZb0KWucO8PPAJpd1QeDfDFIBqVjmZarqvUvSRzcgzy1zURtNeaPZehGBYX39De3NVIFW1rsF805RpIABDK/znd5qGaKhHAMiSH2G/DYSrSVQvWWa1anDdC9B9NYkIPreCK87vtZC8Na5sfVfRCkMmeSzEbZy8BT2uUZwsHiEv8uzzmNA jxyFgdNu hcUSW9/6S8M9mjuVBqReOe4/ww3tW0Peo+Deu8fdN4re/TwkFBLZzki74ONpbQQcVnsme8SMGr7V7KP+IiNWXyB9pffbSH71wN6iSUVmHy9/Qg8STCz6bamLbqm6Dz+0gcTWnrC43hQx96fiEWmAqgBP6oNRUnKbHc2z7yjstA0L/uZX+AekrZLUhbRX1gKCICDpzAuQTTwef0PNjJdiMLuTLNrX6lgo1jiAzz1OrVFsa8S0XvJS4eRyiAJCd+qElCqESwwX9P+VVfR0IeABTxvJFyX7pQD/1sAz1kp8gPCySx7P0bZ+BNXsMar/ILCfsVq2exzRdTHD/cf8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000560, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jul 14, 2023 at 6:56=E2=80=AFPM 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-l= ayout.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 addre= ss space > +smaller than sv48, the CPU maximum supported address space will be the d= efault. > + > +Software can "opt-in" to receiving VAs from another VA space by providin= g > +a hint address to mmap. A call to mmap is guaranteed to return an addres= s > +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 smalles= t > +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. > 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 g= reater > +than or equal to :code:`1 << 47` must be provided. > -- > 2.41.0 >