From mboxrd@z Thu Jan 1 00:00:00 1970 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 D73C0C001B0 for ; Sat, 8 Jul 2023 01:12:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 780B18D0002; Fri, 7 Jul 2023 21:12:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 731966B0078; Fri, 7 Jul 2023 21:12:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 584D88D0002; Fri, 7 Jul 2023 21:12:25 -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 3246A6B0075 for ; Fri, 7 Jul 2023 21:12:25 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E57771A0182 for ; Sat, 8 Jul 2023 01:12:24 +0000 (UTC) X-FDA: 80986669008.12.5429F39 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) by imf27.hostedemail.com (Postfix) with ESMTP id 1F9B94000C for ; Sat, 8 Jul 2023 01:12:22 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=YFsN5teo; dmarc=none; spf=pass (imf27.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.161.50 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=1688778743; 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=HbN8vPNRnpC2rsql2yMQGj4/q3r+GbD6Fgm8kHqgv+g=; b=BGPiRZt/3oh1RKJqyFivGxq8VuHVURzQQ9Zx0wkFMU8t5Wy3KPmbkdAdcc/4Zus9X54z0M Bt7pLML76h+9Dypk7ErzczHh4USp0a14d9L75wFNgvNmUsnewjgT5Vjcr0Tz5dxS019aUy QLCavDhWwCvVYU5F3r+z/jMDRSErdgk= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=YFsN5teo; dmarc=none; spf=pass (imf27.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.161.50 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688778743; a=rsa-sha256; cv=none; b=Wu+V8eGKsFVdBx+Ahbw8TbmQ1e4WY3jQ25qvcayikj0v6AMqMwpnsHvhgHc3ZGD5YcW68I UTT/f9F6eozdxDlFNLejPUc50aXGYX5TMTC/t6fU366zAJKhC6KYvuCBW8CdKjVlZC0uOA 2HtTYtjSRF7hVlxq23KasU+s+w8D/yY= Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-563439ea4a2so1834044eaf.0 for ; Fri, 07 Jul 2023 18:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1688778742; x=1691370742; 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=HbN8vPNRnpC2rsql2yMQGj4/q3r+GbD6Fgm8kHqgv+g=; b=YFsN5teo2Xz7zOmpo4/u8q+vpC9gfozaUxki8nVKZv9U3t07rRrfE2F4D/Mpc5IR6Y g2mhkupBGRVRoam4tBIlKDHh9QI3CglQEfd+e5rWKmh2SSW1KWTgyeQZWx33sFhEiL/R zgEzQmy2w6g0b6bkpsyL0pXxNONEUqIbqM5EyF7yTZ4nd+QmM5x5KgzeZtipCgrkcwup nNVAWTBHg56PkxtsUwaVwvwNubSbZIkurOLzlb3ihhEr/nv+HyjB0A54Sr6SdIfOKJ3r u1doM0X8jjfji3no8jcXuswWv7vTaFA/xQIWTftyN61BawJxTM4bORzaV5IG40o6TLK3 Hpeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688778742; x=1691370742; 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=HbN8vPNRnpC2rsql2yMQGj4/q3r+GbD6Fgm8kHqgv+g=; b=G30pxfRvQ1k2/md5kwUDW+Ea7pzwfP2qX5jRTlz0Mo5ZDg3gpL0PiZrlq96lUQcduV k2901Cq7gSLUVqQm03atykJX11u+DjGixNC7DYOzdacqCIhUtW31WRBykR4wUMwpArfM IiYYONyoQBtn5W45TyAam3SNMOP3gqYjvcKXYQrHyJOq87UWANwToJKlN9zNunxWSp7m RZG4ddloIjUOBw12tyGokjxTeQiK5hSlrnXtbksPWFYM2OilS5rUTvnLwXn1rPIdDOF7 IVxRWU1jb69HlYALIphdi39Baw3gmnojMpArLjmDGAXW3OhtNwljoM3iRyxzfzIp6uuA JVaQ== X-Gm-Message-State: ABy/qLZ9WMOSqmw2RJ38n28A439LPliehKccPIvOSSepIJnivwnChhDE UbnVVhRCtVD3KJ2T10etFxWlgA== X-Google-Smtp-Source: APBJJlGdindojK5i23bHPXGUqY/0vPqfcqx7SQxTQvxyGmC/pEljPyl1GkowwHsZX51mLjvN1LEySQ== X-Received: by 2002:a05:6358:2925:b0:125:a552:4389 with SMTP id y37-20020a056358292500b00125a5524389mr7496248rwb.22.1688778742292; Fri, 07 Jul 2023 18:12:22 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id x24-20020a170902b41800b001b87d3e845bsm3830654plr.149.2023.07.07.18.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 18:12:21 -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 Subject: [PATCH v4 4/4] RISC-V: mm: Document mmap changes Date: Fri, 7 Jul 2023 18:11:35 -0700 Message-ID: <20230708011156.2697409-5-charlie@rivosinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230708011156.2697409-1-charlie@rivosinc.com> References: <20230708011156.2697409-1-charlie@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1F9B94000C X-Stat-Signature: qczu41kxtadd7eohhu84thmb3z4is78k X-HE-Tag: 1688778742-52999 X-HE-Meta: U2FsdGVkX196o0KSnqofxMP1v8QX0uSAmvurbvq9pWgFYXRr0zKV/mWBQ3bga82eWcTORSrbFohLL1AUWsgXqQuIbae826wglbDfwv4hMtmcFsrU0EPjUIqUvcvo15xKVp0uQd86ofRufaM4jJUbObjQJ47dY6+nY5lLNg91o5ZDBOUVuP3nD+/4jUGkHpVq7qYxF+fz4rf8Mu0FnN/57360Ome7xOat9Sz16sRvaYIE/oVlvsaIeMIfJVaHkBmn5ji8CF6LdJg1wdRyw65aJea16W6ZpbHxQj+voCOK9EC/nLyD2fbN5aISo5mDc8obnkwdoQJ3CqnB5eFQPnKTiBQnyrFW3VI+Y+TZs+5GkiK0i/js6k3k7eoA7TY3jsBU7SJQ3oMrCvpSvPJcJvH90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ender: 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..8141addbf888 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 other 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. -- 2.41.0