Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2979516rdd; Sat, 13 Jan 2024 09:33:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+4ttIV5SbzHCKZ95XCbeQPaXoNrlftzw7NCK4j9iByLAyzvNDpmXFvL7bFJdlOdzqZmsb X-Received: by 2002:ac8:5fd3:0:b0:429:c7ea:3c60 with SMTP id k19-20020ac85fd3000000b00429c7ea3c60mr4086974qta.17.1705167190581; Sat, 13 Jan 2024 09:33:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705167190; cv=none; d=google.com; s=arc-20160816; b=PWwhZof1H2HGEkNZUx/qg3C8AysnuRaX6z/0dMfZ8UlP1LMRW4Nrt+vciru6kiSkcS xZMY9vlBeRcHhJgr0LYAOgDO4hxPiVH5jiN0fezcU8Zqpq0uWPgQj0i3/Wmc5vNf/5h8 8PAMYUiVo62P8MVGOctyca1pehS99g4inJIyEpC3r6fbji1HOw2hPfPHiu/HbaP+VjfD niYPbEs3B60KgZNm9sHUn0A5ikF0RT2zivmNOu6ahu3/sKN6bk3onzKS3hSnhEzZwSaH cEte0pCxAmjFNs0tQu6tLvJ99M03U47gonKwW3dcxlaXbStmTKnwfVTtRt4kheGw7bxp 0JJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:date :subject:cc:to:from:message-id:dkim-signature; bh=9n72WKKKGYhqMdswP9Jj7VEaJwHs3IyzRS4xEll9rYI=; fh=ozYF2wS3aziLSpSbQBosSV4ckgHnNkhJ3rWDgOHLJoI=; b=HSKxVaDgb7PV2lSYewrvuQd5N3z0tTnSWJXZgspPDVeLxOFg0eJPyoBeWyXPVXzlAb QCP8+9qfPUX7D70LIU8QTCWfboGJzUx1eD5LT2kvzLc8c1L7XmODKiDJpBf/a8rpw1fd LX1JCZiLzVD0QCLnrdS2Qvwydxq/7KkKHxzAdB0f7WJgBcY5WnfRWyq/4zwtAvrT2i+u 0W3kA4cyDzuDxRLI54Oq7g7mWP7mS/Kk8GhKbL9+ODCGl23lJS9T/xcUFh2UdQ2VPRDj pMUL4SmP12B4gsvhFw2aSitSM6Z8V6h2gkFFgmgBBLBfgka0Cs1Hi8vwg8vmttaU9R3x Kkdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=ukzssRAC; spf=pass (google.com: domain of linux-kernel+bounces-25342-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25342-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a16-20020a05622a065000b004299165c22csi5277538qtb.467.2024.01.13.09.33.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jan 2024 09:33:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25342-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=ukzssRAC; spf=pass (google.com: domain of linux-kernel+bounces-25342-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25342-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BBF861C21248 for ; Sat, 13 Jan 2024 17:33:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2DC2753B8; Sat, 13 Jan 2024 17:33:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="ukzssRAC" Received: from out203-205-221-191.mail.qq.com (out203-205-221-191.mail.qq.com [203.205.221.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B7185663; Sat, 13 Jan 2024 17:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cyyself.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=cyyself.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1705166867; bh=9n72WKKKGYhqMdswP9Jj7VEaJwHs3IyzRS4xEll9rYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ukzssRACnz3BFOQ4m0PrtOBC+c3ULmzJzKNt2HiTP2zC7dzmPLW+FHncUgy76IUE4 bBSFdgBVxfqt3ilig5ltgbGZKNlqBnwvrADPa0YP4lfB4HrJGDn5rUl3BbiJvb9e3P f5Md6MBUvXZU9MQybaI0l9rZ76Crk8hUiMtlUkkE= Received: from cyy-pc.lan ([218.70.255.58]) by newxmesmtplogicsvrszc5-1.qq.com (NewEsmtp) with SMTP id 6B9BD474; Sun, 14 Jan 2024 01:26:57 +0800 X-QQ-mid: xmsmtpt1705166817tpw8s6zxo Message-ID: X-QQ-XMAILINFO: MpYZqmNm/7vMFQChzuZcNMPEZCicAYxwA3bgPt5oBo3Izruh5SDSD1/vjfZIJe 7IBevBAJJvXhgU9B+SMnjtsigosK99wXz45XosSRmglerB4jvY07z2ypp/fWsmUwQLZ3rc4lgw08 0I7c4e9ssoe0Ldzh7aDfnOwg3ItEwflH/BF3rnY12bJD7xRo/M9ZSFqZABHgOKsvejN9E8BhUm2D boo2oTfkaKEQcLeunqTCbSyoFYN07nmPJtRl8ODOOCFEIFDrcTWZHY0wX7tuAYx6PuS1SJSjXYS2 bOEVhUBovGWI01NTW0yrPLyhFe33CdafAdJAf1SrjfgmRNyBqHdsDLZz7UlH9vHjFxvMrmU3dy5N 45B3OLgeNOTV6WEfUAL3IRazwMFr8aKB9LH+gkUjByXzXtwcrFHxXmMsjpssUiAlF1duH66p4Avr 84W1XexcvjfBXHBgXn5BFW2+ogGmclzTetljdN04BAku6PGLStHt7Vs8LRhxh82ARYq6o+Md+kgL NJxin6UVnpDBzYjg39bVX6PvJK3U699wPbe+uQtu79mMUgZ8WzO3iGxiOmirlrq0y8rVSXD7t5iM GYsxJ8FGK+3+d6K/ILCMvSeHJKdwbCtWTtAdunvZubJwOzaynOeC1geHeMxH34ZZztsMnz79vLpe YGChZ7mLTbp5fUDptY+VCdcdL4Fy7KWDgIBg7MTpy9RLjNazovEqG5960r71+VO+2pza3/A/dviG n0++0sT/QAFpxAF7w8YGMItABROQoWSr+xES2srhGGf311gs4BzoOgOKZhvP5I3hexb4JG++/Bt2 OrIfwjVtIS7Tr5jYRQvXT+uKYpMsexCp3J8Xip53EB0io7BHq+H8zipn5FRMnuzONGJrAQAd9WC+ I81SztmB19m/xMFkY6qEQ5yrj6ENCd3r8gON2zNjMQDmvw7Tdjfni3yzimGkBOehL2PYtcjs/KFk RJDRSTS7yAifSWQWUnc3KxIF9qzMRd X-QQ-XMRINFO: NyFYKkN4Ny6FSmKK/uo/jdU= From: Yangyu Chen To: charlie@rivosinc.com Cc: alexghiti@rivosinc.com, anup@brainfault.org, aou@eecs.berkeley.edu, conor@kernel.org, jrtc27@jrtc27.com, konstantin@linuxfoundation.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, mick@ics.forth.gr, palmer@rivosinc.com, paul.walmsley@sifive.com, rdunlap@infradead.org Subject: Re: [PATCH v10 0/4] RISC-V: mm: Make SV48 the default address space Date: Sun, 14 Jan 2024 01:26:57 +0800 X-OQ-MSGID: <20240113172657.997104-1-cyy@cyyself.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20230809232218.849726-1-charlie@rivosinc.com> References: <20230809232218.849726-1-charlie@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, Charlie Although this patchset has been merged I still have some questions about this patchset. Because it breaks regular mmap if address >= 38 bits on sv48 / sv57 capable systems like qemu. For example, If a userspace program wants to mmap an anonymous page to addr=(1<<45) on an sv48 capable system, it will fail and kernel will mmaped to another sv39 address since it does not meet the requirement to use sv48 as you wrote: > else if ((((_addr) >= VA_USER_SV48)) && (VA_BITS >= VA_BITS_SV48)) \ > mmap_end = VA_USER_SV48; \ > else \ > mmap_end = VA_USER_SV39; \ Then, How can a userspace program create a mmap with a hint if the address >= (1<<38) after your patch without MAP_FIXED? The only way to do this is to pass a hint >= (1<<47) on mmap syscall then kernel will return a random address in sv48 address space but the hint address gets lost. I think this violate the principle of mmap syscall as kernel should take the hint and attempt to create the mapping there. I don't think patching in this way is right. However, if we only revert this patch, some programs relying on mmap to return address with effective bits <= 48 will still be an issue and it might expand to other ISAs if they implement larger virtual address space like RISC-V sv57. A better way to solve this might be adding a MAP_48BIT flag to mmap like MAP_32BIT has been introduced for decades. Thanks, Yangyu Chen