From patchwork Wed Aug 9 01:51:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13347312 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 CD853C001B0 for ; Wed, 9 Aug 2023 01:53:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF2946B007B; Tue, 8 Aug 2023 21:53:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E54B96B007D; Tue, 8 Aug 2023 21:53:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C57C18D0001; Tue, 8 Aug 2023 21:53:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B442D6B007B for ; Tue, 8 Aug 2023 21:53:15 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8219780E0D for ; Wed, 9 Aug 2023 01:53:15 +0000 (UTC) X-FDA: 81102893550.28.A2EC4C6 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf02.hostedemail.com (Postfix) with ESMTP id 962C78001E for ; Wed, 9 Aug 2023 01:53:13 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=FPpY5cIU; dmarc=none; spf=pass (imf02.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.177 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=1691545993; 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=2tar+fwRF9EwexnZBlGXBQ+bino7OPSUOa9FVKEDgW8=; b=TkYHsbJ2J1lrNniWBK54yHY9AoQ/gtUpumU5dnVwCTJErlKrQIexJwTtyr60GkDToa2dFR NA/9OI63F1X8lqQz1/dONIoiNuiixs35WkPjWJOBsFTVh3KrVcoDIPPrHNON0Xs82WBCEn lcn8QE4HijldSzCUO7Wb7Pueh4lmoPM= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=FPpY5cIU; dmarc=none; spf=pass (imf02.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691545993; a=rsa-sha256; cv=none; b=rIcUS+30aBt31zsrZhW38ZdrgsXEmPAb7ojdvpztDg3g0oY552RlXj974PU3HTmqlhWjpA tL06SitANKyktdOS2Y2zAv1Te2Fxk2k4A9JobeqoEYBPxEM8tpTsFQOXklsRCSTMOyldND Oac5cLZ/akfHHhlSxD6k4b+wv8xA3TY= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1bc1c1c68e2so40592685ad.3 for ; Tue, 08 Aug 2023 18:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1691545992; x=1692150792; 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=2tar+fwRF9EwexnZBlGXBQ+bino7OPSUOa9FVKEDgW8=; b=FPpY5cIUXnip2ZGbpSphNOYtcmoz+9UqNCzoKTIuGrXSltzFcKRrlt8IZVpkHLRqCx OnkTugPfEWDKKQRJ75G2J1aJXt6PH8fts5QVkJJs8njOPLx6pNBBDKHzo/kPhqxS0sx3 1HU8/tEpAVmLFR+F4zwPNJwDwa/GS5jdzeVtMhkd3NlduxYlQA9dfzjF/ys4sjj6OEtk sjDMhjLy6jjBKzFs07exQfX4lKo012NsKC4Zu68gj0Uv/D7Nb/c/EwcN8oQMkTg6va+w mYmQCyjU8OGyh+PyGz8lSNWVUIf8yU596h/YkYk7J+SNhMSNxobFIMZoGtxQE5T5cv3X /BDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691545992; x=1692150792; 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=2tar+fwRF9EwexnZBlGXBQ+bino7OPSUOa9FVKEDgW8=; b=IsyrXPb4e7keoCnPIeBBu6J7ZlwGPnNwv+8WTRslTlLTNn++B78S9XJhVE3D9ZKT9l l1LmSkx30bmnCO2Tpe9+Caqj3Cy+7sSf8iRJSwj7Go3Nb4tCliC0LudsJk72Qr4+eR+h 6hmyV8KiXjeTqZUvMP5YmAbaZsrsvR21gq8u31Ya/FqV009t1+IJRb1xHBMFLSn3CQu1 dLLXA2tDzWOdhInoZAu8rdkST+TzbwmspVXvnKGdV3ZSHeN3lM8uACkha9jXVfjV6ECw 9vXps5fpxRty/n8F2QhieAJ2wVu+TwS6DS8AcU+b8L8JQhEX7RqAsLhk2s+v89Z3+M00 7RPQ== X-Gm-Message-State: AOJu0YzaLZm5dzp4eZQB40BULo31rLVW9r1IFd7MeRMrxxbua51aDY87 hlpkdYjzGxwSvyOURqzYo6pxKQ== X-Google-Smtp-Source: AGHT+IGZcbmVCa5ZDQZDqMBC5RXy8ZlAEnBSQVfL2GCWuQwF+OUfXTklfpU8ydkeXzNNensTQj2vcA== X-Received: by 2002:a17:903:1207:b0:1b8:6850:c3c4 with SMTP id l7-20020a170903120700b001b86850c3c4mr1594061plh.22.1691545992539; Tue, 08 Aug 2023 18:53:12 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id bj7-20020a170902850700b001b87bedcc6fsm9657591plb.93.2023.08.08.18.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 18:53:12 -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 v9 4/4] RISC-V: mm: Document mmap changes Date: Tue, 8 Aug 2023 18:51:10 -0700 Message-Id: <20230809015110.3290774-5-charlie@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809015110.3290774-1-charlie@rivosinc.com> References: <20230809015110.3290774-1-charlie@rivosinc.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: frjrf4sqrbh1xahhsh3qx5bx7ukb7cn7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 962C78001E X-HE-Tag: 1691545993-811122 X-HE-Meta: U2FsdGVkX18LYnDG4l1GiIYb1TeRfqZy7XWPacVEUyzDiKJFkalKBgTwL43GG6F16pqag3jvQjDbnaJ/EM9gBwEi2MybeJFEzMQMItemY9twzLfq7tr3MKCxaRFRrrAp+WBDIHreDLliWNCPC7Qa9tbKaNlwOznYy5PDOt+0dJExkJqxskf9n2HQGDQjaHqb/xPgoqgemCNC8v8h5zbYI7BiUeeh908nmWTPgaLW66Dr3UsWZUynQhtQcO5oIrAGyovvvuKesrpyDlrr4LAPAWNwW5IDvg8grQ3d5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hkCB49oQxtH7CCJrDVflqOWJMVSxZzdJD3uVqHHWXMuSctOngKU4biNefuNjLFX881hQvYJxBlNct1uxfPUGyEWB X-Bogosity: Ham, tests=bogofilter, spamicity=0.000377, 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 Reviewed-by: Alexandre Ghiti --- 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.