From patchwork Fri Jul 14 16:54:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13313855 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 0858BC04A94 for ; Fri, 14 Jul 2023 16:56:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5832900018; Fri, 14 Jul 2023 12:56:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE2A1900006; Fri, 14 Jul 2023 12:56:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C33AC900018; Fri, 14 Jul 2023 12:56:04 -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 B489C900006 for ; Fri, 14 Jul 2023 12:56:04 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 43CD71C8230 for ; Fri, 14 Jul 2023 16:56:04 +0000 (UTC) X-FDA: 81010819848.06.CF12455 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf01.hostedemail.com (Postfix) with ESMTP id 5E6A04000C for ; Fri, 14 Jul 2023 16:56:02 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ECP+dufn; spf=pass (imf01.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689353762; a=rsa-sha256; cv=none; b=SeXgm8v3p18bvfTlf7/CmmKeXpNtDOaAk4i/SiUmbOC0fXpQ0O3w9Ku4f/SOtU2ZZSmE27 f78saXcfMSugit/sd+QnrRbw+sBIlcNleX3tKOIGdWSKi86QVSudRZ1ookv8UGzRuFml9Z grpDX+VSIDX6H6dgyG0LIgWnX8haQeY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=ECP+dufn; spf=pass (imf01.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689353762; 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=iY0BqE22+vH8ihdQ5F+U3lQTo4OY0Ve5Zo6wbRWfHfc=; b=VxzMtdNlhIORTd9OFTDPQDrA0z7SLFaH2UXX5YEdUsGSbqoJCijVHOZj9pLYQ3Yj4SyM9Q CUUFduqCuP0YOuCXAluOuIHRSfCGlq+hLGDiSWmZBZ74C4E2OLAJK50MjefIaLuHwgmLfp HC9QTboin2iEVppoLkf0uQ70Sffc4a8= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1b8b4748fe4so13102255ad.1 for ; Fri, 14 Jul 2023 09:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1689353761; x=1689958561; 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=iY0BqE22+vH8ihdQ5F+U3lQTo4OY0Ve5Zo6wbRWfHfc=; b=ECP+dufnQHsYRxuqgPOTnUSVvIo4ePBLAYzcr/uPu+86xHXRbq559fnQxM4loYgYii 9q/1Ih5sS/4Nz4IV5XKxNs5M7eNK2wNCyxQPv1SoVXWcMmwbEpzI74Jdn1u5Cczfadul jSHTTTzLM34mcqiVS7oXLHnW//LVLHHdygX3s6M81zVFp+Lmjk+KCS/Jt+2NFtsSEwsS hM2QAfrxJ4G7EMIqqaMGTDm7wAokuRc+ct0d85q54+SDh5Xc1EJl+Md33rZrNOHTixiq BSKIqdZJu/lQ2SebCzY5jdSZwDdpY3w9ELYszKlZ96Lgs1OHBPPpkiA+q8wz6OTq9PHQ LbBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689353761; x=1689958561; 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=iY0BqE22+vH8ihdQ5F+U3lQTo4OY0Ve5Zo6wbRWfHfc=; b=i1zoANHyKnMbaLq3kWpVre+sLKv+Vo4maaZDtcqQqaCMvrBO6+nI0D/IC94zKENKEM wX9rg9j/EyuLuhTnEkaW/tPQy6bbzD9ma64bgCPzE1p5OfTDw6b/UOOCMG46Sl2YcHi2 A1qvBH9PLwbezg7VkauHhB/K03+DTum0XuBr1RXV5U4RJVMBPHRLfZjJnGii3EIr1Gb/ tvBGoUIiW88Vzj1JwotuMDsd35u/j1PR2lEryyaULfiOHoqVWWVcaiCe5ctZpqclfygs 7dbrv+GhJyGOPSP3PgQYijNK+ZMFR2mOBibtpXp+boCaYFxtN5SIJUP5HVEjUqmH46on AEzw== X-Gm-Message-State: ABy/qLbPF+QOSJu2xYM8kXkW5PFW4hyt8exmSvGGPFI/wV1rE7gMKiU0 UZaz5llMUqDt3BqgOGY9zshgFw== X-Google-Smtp-Source: APBJJlFsvoNdVZTC5wGAHNOb7OEsPFjJFgSI3IvikXJ3ahp3VMzgfUgYU2kfHESUML2FBAHGPHaiUA== X-Received: by 2002:a17:903:1248:b0:1b3:d11c:23ca with SMTP id u8-20020a170903124800b001b3d11c23camr4729934plh.8.1689353761143; Fri, 14 Jul 2023 09:56:01 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id s8-20020a170902b18800b001b694140d96sm8008081plr.170.2023.07.14.09.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 09:56:00 -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 v6 4/4] RISC-V: mm: Document mmap changes Date: Fri, 14 Jul 2023 09:54:52 -0700 Message-ID: <20230714165508.94561-5-charlie@rivosinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714165508.94561-1-charlie@rivosinc.com> References: <20230714165508.94561-1-charlie@rivosinc.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5E6A04000C X-Stat-Signature: 5hzgewtpjz68zb7eeot115gh7kz5w69k X-Rspam-User: X-HE-Tag: 1689353762-829096 X-HE-Meta: U2FsdGVkX18yuw7qoZMAUb12FgCpbt0SE75JnPUUgDB26DUd/35jbUPuklRuWFQthnIUOlBJZKov1QQdYmC3TDE4pWXtSD+uMsICNIpG2qXVbhE2U4YGxe9k9GlE4lV2RZkfvZi//EL7JBlMmBDREbn5csf/zo7ikVQcmPM4VnaRZXi+2VNgphWi5MvozE3DHFdEOtq/T1ai0lR4baalxjusTF/feqTUvCLexkojsJR0zKRJh5WAbRLYJ8MJOVGEf2qSpKnrmgYD6s5phNJKnYY2fGavV59kJixA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YV2vOOo0L1jU0CEhx81OpJA6Dnim8cdiLTULiigq5NQxQKh56sicI3myiAbZ5PDGuG X-Bogosity: Ham, tests=bogofilter, spamicity=0.000373, 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..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 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 call to mmap is guaranteed to return an address +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 smallest +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. 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 greater +than or equal to :code:`1 << 47` must be provided.