From patchwork Wed Jul 26 16:45:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13328365 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 BEB6AC04FE0 for ; Wed, 26 Jul 2023 16:46:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEDB36B0080; Wed, 26 Jul 2023 12:46:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD58D6B0083; Wed, 26 Jul 2023 12:46:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85DBD6B0082; Wed, 26 Jul 2023 12:46:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7784C6B0080 for ; Wed, 26 Jul 2023 12:46:38 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3B3C5C0351 for ; Wed, 26 Jul 2023 16:46:38 +0000 (UTC) X-FDA: 81054341676.19.D0FA769 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf23.hostedemail.com (Postfix) with ESMTP id 3B14D14001C for ; Wed, 26 Jul 2023 16:46:35 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ctlEmW7D; dmarc=none; spf=pass (imf23.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.169 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=1690389996; 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=gcvGxWKs0ioHSwaNFVtuDJQ1B/8SpZlsoy8QXz36r7I=; b=RhqFg57BvKl6fNbzr/B0XywyPma+HGuRk3UQYXqf+YX8MJg8nJj+0/E1Vl37tTzHQ1ktzJ oTML+hUiGye2Rhyw2dauqmaHOTtoqeiFHm9CvGIYMXyjYoNRzKU/ycd936XSh2jEcwqQ+W K9lJ2YU4fVIJfEnDgo1MCiTq5agUhNA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ctlEmW7D; dmarc=none; spf=pass (imf23.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690389996; a=rsa-sha256; cv=none; b=vDew09F0L7cE4esMOdF+6g7YhSyqB+QH+vpY+CrXswrHeKH2a58J2SvDwYHX58dVbgEDzj qJp1VZ/HyxASE68Anz+Oj70caIFgSb/5l+gRDlCSNiCXv0ZbJse9dplOc8iM2a4/OnEhZ1 jAl87Q5/KvnHbAUnEOgFFWxt9jrSmYw= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1bbc06f830aso8629015ad.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=fsYaY3huSa/xAr1RfOXebLxGetD4aOUCGeGVzX7DXVGQqb14hSRKXu4YxLpqEuroVZ os6qorNTdHpi3ONYaPvE3aIVBKoYX3r0edaOmkswb1DvTGFOScASQB1+3o66KTz2GVtL gF+QUcoiQygvuxjvIYXxTxnY9As4UTX6QpJlUT1AYNWB/wTFw+gIdYigBEGwvUGRPGkd orcH1hDF9HKptcVsfCNK+PtwfnlRwSvb5K+BI0gRJvCHd05XxFa+cQ+mAXzfYO2JmQAz KS+f0CzNZriteeC8v/YkTmoQK9R8iNfHnNgc0/YU3OELNiVyGBCXv4bi4bUhM1a4qlpS BhEA== X-Gm-Message-State: ABy/qLam6gUKHeSNMb99PdOldTz2nkNQX/3m0pSVc7+M4rT9odFBAJLh pFKJG/uP4doe0tGk24FOBPJSOw== X-Google-Smtp-Source: APBJJlHYD5X46sfJHvjFJ8cY7MrqSJBPdDrgEnmRM7T9AiO1YpDySEyimp6MxA9+6dubMdyjQlpBgQ== 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 X-Rspamd-Queue-Id: 3B14D14001C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: mo15mqcstsatshwriu8oyws46nriuhnc X-HE-Tag: 1690389995-972502 X-HE-Meta: U2FsdGVkX19LjMZHRY6Bs7cuyAO0WZaiHpMTgXSbZv7e+1M80fD248KyfJD040ui0xeyyhPCvGdPF8Bp7MExj7xf8hJdBG1V0fkUe1G5LvOPb+xLlIOJwbsiKZlYFAsNm7Jx5sbT921EWyrEJNrm4t4xqRwfjnpTxbdIZ0T4M/7gwRat4m8JhMRB/6d+do/zzktIqigMOrOELPktBKmog7VIOFo8snRibHBKqzb+Wt7xI1kSNnCp/tdlFdWGorKFKT4Tpzvu9REKR3ycHzfKbtX/RO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zq6KwzHVR45l0uE+2ORASuJ8yIP1fXeFuMLjLqjaMyNEJ+E2vOmOZXuawW7658eqQFqgHQ14oM/m5ojioSM X-Bogosity: Ham, tests=bogofilter, spamicity=0.001265, 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 --- 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.