Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp1808984rwb; Sun, 6 Aug 2023 03:31:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEe9S2oLGvmES1pLkTB8O3jqrQ7boShO56jaVmFHxuwxgyEceUNADW02zoaRBHicMI2WQ6y X-Received: by 2002:aa7:d6d6:0:b0:522:abc0:2f1c with SMTP id x22-20020aa7d6d6000000b00522abc02f1cmr4824236edr.42.1691317905081; Sun, 06 Aug 2023 03:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691317905; cv=none; d=google.com; s=arc-20160816; b=pvaNTa+wc2dOcpyyVztUePJEusH0gd7fELAEAZR3kcBttJtoxIuBrWH5BZkCJuEUj9 lIamD0Ivv+mcKA87vdiTBCQfWjaWrNPu0UW2MGvO3dkuKuVQ7LKX35A2Gn8Ide/dQETE 78hhaC+0B7r0mY2sRmXUalbNkdQ/BGa3lDdtx6//lTVDDIW5O3T6jXz6d2HPrOuUq8vI eLAYRlviIZ6XCi6nrBXRGfa1JOKxZs7Ta7FrWO8lUjQ/bPuF67oUqmR2fxmJATJ0S5PD OxOjr02AtrB0ht8uzHW4UdqLXnRtAa2Xy+P/mAsWSFlawt8FUbE0K0SdBjnTcJTKcINx qaqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=ZGlK4YAV9XUXhQORVCJcgLK8KROZvCaIxsQnNJb9HGE=; fh=Lv/S1lu6EzejjjnmdNLfDaf0OlLSYClfIRigeMBp5fA=; b=AyEfc/7u75Y2Hnc/dNRDV8LhBx30pRGfsV3POGb2CXeP5rDbBSXNYzQiwmYHh48J0p rPF6UiXcaTbqoi9XfncqdRkg+dGjkg4DcR7qQZQRonFDqNhur+2hU61oXeJGfAuZKjwd r2vhyCtwgNREaujxZdRCi9KiPtuqm2LwZtRbzFOfYJx2vQF1adLUVF53id8pvNzY74Ec /vzX1wzkY+F5NQNh2HcqPmQsNCS24boR/k9sXsRuCFD1Ax2NmRU9I672LzbNjy82UBMn B8p6YhsKAfv/lb5rPXKQCvZpV3Tij+svS47z8gXSr+gkLnejML7uTUTfFnS6fdZtewuR Z06Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020aa7de83000000b005222717c469si4124540edv.260.2023.08.06.03.31.19; Sun, 06 Aug 2023 03:31:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbjHFKJD (ORCPT + 99 others); Sun, 6 Aug 2023 06:09:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbjHFKJA (ORCPT ); Sun, 6 Aug 2023 06:09:00 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2517A131; Sun, 6 Aug 2023 03:08:58 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4585960004; Sun, 6 Aug 2023 10:08:53 +0000 (UTC) Message-ID: Date: Sun, 6 Aug 2023 12:08:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v8 4/4] RISC-V: mm: Document mmap changes Content-Language: en-US To: Charlie Jenkins , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: 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 References: <20230727212647.4182407-1-charlie@rivosinc.com> <20230727212647.4182407-5-charlie@rivosinc.com> From: Alexandre Ghiti In-Reply-To: <20230727212647.4182407-5-charlie@rivosinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/07/2023 23:26, 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..69ff6da1dbf8 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 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. You can add: Reviewed-by: Alexandre Ghiti Thanks, Alex