Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1321225rwb; Wed, 26 Jul 2023 10:38:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEc9FKudOn32vUgtyZOXX6OmSIonqK9AbX4OvBV+bqMZ0/9grOTKm7nrdFhOK69pBIb84bf X-Received: by 2002:a05:6a20:9189:b0:133:bf18:ef7b with SMTP id v9-20020a056a20918900b00133bf18ef7bmr187228pzd.24.1690393089028; Wed, 26 Jul 2023 10:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690393089; cv=none; d=google.com; s=arc-20160816; b=N+m1vC1ghJHLEs8H1Oe9NXoqr+iq91PKFBhskiTgU1HLpM4fe5gvKCGpLBvzdEHf9f pRZK9krYkDXW6vC46NgjumRWRe1XpVHTGPVu/TuQNq70cf6ULHNnOD9M1sY3Ak9VYMUW YG+kSBMcHOxoHQMmg2ST7Ya7fbuqaIWC0iqmGOPeEn/MLSazvGrheMn6305VEJhM7Pjp PKs9v/QYMMSDTcDyBn3UqFO1NnwRMHEy4VHI6iq/dN+JMeqtOymY/fyFNtSKD8Kl/Jb+ k3oXATy6Hcd1P2dZEp8sCZNrBpGhTg3oBuRUIn64gcp7bwIsU7sMc/SIsfa6vl4+6cL4 HOYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gcvGxWKs0ioHSwaNFVtuDJQ1B/8SpZlsoy8QXz36r7I=; fh=7AUu9WDHec3ojD+PBWP8kj3GITT/pOnwiCBaYopXpyU=; b=extMPmXNgIu12CkGl3AqdPtGrNoALHYu59Jy9uPpukm+hO8MZauvkbvelcoHfp/tSu pEwxy9ClW2wme+g6ZASFmkEm/AMcYj1uVY+K1IWF2O6TSyMzshTtYv06nXmCk59GvWx0 4G447hji2do0+Ou/kjH3t4NGZZ3fbv5u/s+VKc3Z1EpcDM+x/dQUU1Jx/NRXiu7nhwSn jpuOqefKjOpFuo6O/yX49gfSg/HKokeVSMuwSovR96vNhWj4I8MSF2RwBu09vz3ZL2zr 5dph1YPuLPwYzOvOea6czliAeXJbxeH81Wd3By7Mwyy/xyb1JQHQv/Dtf53VrkWNWVeW NC1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ctlEmW7D; 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 x64-20020a638643000000b00563da455862si2169634pgd.311.2023.07.26.10.37.55; Wed, 26 Jul 2023 10:38:09 -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; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ctlEmW7D; 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 S231939AbjGZQq4 (ORCPT + 99 others); Wed, 26 Jul 2023 12:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231721AbjGZQqo (ORCPT ); Wed, 26 Jul 2023 12:46:44 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88EAD2709 for ; Wed, 26 Jul 2023 09:46:35 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bbc06f830aso8629005ad.0 for ; Wed, 26 Jul 2023 09:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1690389995; x=1690994795; 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=gcvGxWKs0ioHSwaNFVtuDJQ1B/8SpZlsoy8QXz36r7I=; b=ctlEmW7DMTMNY+Sp7acXqqDtGLdfH554pjXRJaq8fLvxFb/RtQTWgjya5aX8frZUG+ kWLLX3V5bkPJ8D9sRUV/MwHTEJpB9RCwH6/ndhkksdQtRuU+HRr0zUfscDgxiFSHZA9+ yIU0ZD4Tam8mQ2WS+5pLZ/c5X4RhjfmHJo3MwLkOOIWTzwMnMBP8Q0wn+W52egZzi2xU AAyOixs1odiPKZLEKGezwwzYUkbE2yPosL+ri5v70wHRzK4oQvk1fggscCcK6icuFnGe uL29fxGA2FdvaKyJUxHyjHp+jMTQA1xrvEzeIai5Rjkq71aK2LAAFsldGh/eFZfk8xRM s+hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690389995; x=1690994795; 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=gcvGxWKs0ioHSwaNFVtuDJQ1B/8SpZlsoy8QXz36r7I=; b=UnyS+c+DWsie+HqZk6qBnm52o0k6cKwoFJ0uMAKBALjxnbiAlTzuAK+eBVrLg4uJjL 6nM+i0SyNk5ieMwXXhTRNljvFkMeu46Fc6qo956f4GriYQHg1z8W/LyByIloSSzJGVHg e/X/fFB6M5Va86Co9Z25ktkUNPVrZ1ePsVoBYTjPdK2Xut1OhcBxA0LB3qbmaeUgZLQx nbz4WqOm4SZtfXU61XLs7/jznA1rx3WwYMwMwBoylibeC2E/bhYj3gDrykmg4dhFxoND YRm5nnFkIGs6MEzv4/ppghPCW+k3tu9G3GzWp/641IRm5haXpdn5XITxP/qsFVYCvT0d udKg== X-Gm-Message-State: ABy/qLYPd/Zq2qUNJ432CPIvrcZSE7+NlnTcwqbU/CwDxSoum+i1Ga/y hskq7ZrXTna5aMnqNMCOzme1JA== X-Received: by 2002:a17:902:c943:b0:1b2:676d:1143 with SMTP id i3-20020a170902c94300b001b2676d1143mr38193pla.15.1690389994874; Wed, 26 Jul 2023 09:46:34 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id h5-20020a170902f54500b001bb6c5ff4edsm11628870plf.173.2023.07.26.09.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 09:46:34 -0700 (PDT) From: Charlie Jenkins To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.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 v7 4/4] RISC-V: mm: Document mmap changes Date: Wed, 26 Jul 2023 09:45:58 -0700 Message-ID: <20230726164620.717288-5-charlie@rivosinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726164620.717288-1-charlie@rivosinc.com> References: <20230726164620.717288-1-charlie@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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. -- 2.41.0