From patchwork Tue Jan 30 19:04:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13537854 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 6322EC48285 for ; Tue, 30 Jan 2024 19:04:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45E948D0002; Tue, 30 Jan 2024 14:04:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 40BE28D0001; Tue, 30 Jan 2024 14:04:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2869B8D0002; Tue, 30 Jan 2024 14:04:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 13D418D0001 for ; Tue, 30 Jan 2024 14:04:37 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D7AE1C0C18 for ; Tue, 30 Jan 2024 19:04:36 +0000 (UTC) X-FDA: 81736903752.28.D0C653C Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf21.hostedemail.com (Postfix) with ESMTP id 10E1E1C0012 for ; Tue, 30 Jan 2024 19:04:34 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=DmglAOiz; dmarc=none; spf=pass (imf21.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.181 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=1706641475; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yR39BQnx5CuM7HVAKBGyTLeOeO2w4fzgWq8LHVFIrGc=; b=VW+K49M31VwuRd/wvtP7b7X6guG71vGDnSt3YdDPJjV1RgmKf57GLMaMWEBK5OhL2bfqc1 rUq+Q3J0JZM3XgomY2dti8k8S1hcQOXmYvZEt782kRRdwX1pdkURxdTV4KW7bkVuOr3rH/ gkYcV7NTM1L15lfTG7Gz+hGYbmp2I/c= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=DmglAOiz; dmarc=none; spf=pass (imf21.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706641475; a=rsa-sha256; cv=none; b=zwWl/ei4H9DMNCnew/XmLUWnt+1WyciODGRMAmSbqP/xm4AMiwQSSkQZaHRDYxZYRZCmiK 6ePjbGap3Kv8OXNYGjutFTWERKsLIoG70VGhrK/HDutJsRJOrZqWh2w9Zht5hwnOGSnSLV o1VpjjsI982vNXLN3mwrijmQSC6Ya+0= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1d751bc0c15so36775905ad.2 for ; Tue, 30 Jan 2024 11:04:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706641474; x=1707246274; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yR39BQnx5CuM7HVAKBGyTLeOeO2w4fzgWq8LHVFIrGc=; b=DmglAOizbTh94yyZX9mFpzhVpiqLejt4YzAmFV2d9LXJOcCRP1yFRYkTqc8XSCKMfa 8oyqiiELaTXsJWL96vUO7wyX1DVy/vDelwI490XttECmCM+baoTdMnk8HOhEPYoF9gZe sJFtes0HNyiZxmiXMgtrelXo9KSmxLXGNpQsLN6TMbs7Yeh4s4luGdeb0SLXQk1DtO66 li6xFtcbUBGisLP5C2q5ZojMxMP4w2P4+6ttakReEjNQbxpYbvoMmsoa5+C7FyrDrBai rZPy2v+hZyvzqzzZIYAPsyQrSZdJ9vCSIAaDyurZak3OmI/yvLrGCqigZfS6fwOnbzo0 47kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706641474; x=1707246274; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yR39BQnx5CuM7HVAKBGyTLeOeO2w4fzgWq8LHVFIrGc=; b=UHTL/T2McP7cgYgklxFUYdW8iLY2M6HVW1bBdlfU1znECb6wu6CNGIEnCm0CLSblpH aNqDiB0FVa/26az1nD2lVgBBzmblnCTmJk7cB36kXbyz9Od8Try6nEAKF4X9o8/MJFSR 4v9IoPh+17kjyGzgNm0y//QLtn2HtdYBDqftm03I1dW1Id+5cnYLIi0BM8AtLtmpPJW2 rF4bKXhLM4dlT08e6tAVkBBY4Rc14iFws5/3Z4DNxl33K9hNsXK5Jd+OFk5bwZ+sjjnw 3j1O0wlG3OBZ1zKVi9hjJBl7AL6QAUAmdpskzp7+aOI0T8VNx0+eCZQ9awQ3nTfGRiLv wIJw== X-Gm-Message-State: AOJu0YzM/ucdKw0g//eDd4PrngIjk/1mxtPx9FNqKxaGKFa6AmRkI/8g 7+THUIPIMn+Z/FXVBZkcsgKjNJMb5HJV9o9vbZpAUxubML9OAEg6T+icefs6huE= X-Google-Smtp-Source: AGHT+IGj3hm3lZxg8Tv1mA9a7NdziJNVi1CzW076g8O+NcVAU25Ai6hKEgTL594gTw3Fe+w4FPditw== X-Received: by 2002:a17:90b:1d82:b0:293:e466:e82b with SMTP id pf2-20020a17090b1d8200b00293e466e82bmr6560721pjb.38.1706641473865; Tue, 30 Jan 2024 11:04:33 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id f6-20020a17090aec8600b00295c3bb9318sm1196541pjy.54.2024.01.30.11.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 11:04:33 -0800 (PST) From: Charlie Jenkins Date: Tue, 30 Jan 2024 11:04:30 -0800 Subject: [PATCH v2 1/3] riscv: mm: Use hint address in mmap if available MIME-Version: 1.0 Message-Id: <20240130-use_mmap_hint_address-v2-1-f34ebfd33053@rivosinc.com> References: <20240130-use_mmap_hint_address-v2-0-f34ebfd33053@rivosinc.com> In-Reply-To: <20240130-use_mmap_hint_address-v2-0-f34ebfd33053@rivosinc.com> To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , Jonathan Corbet , Yangyu Chen Cc: linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706641471; l=2717; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=nYPj/fyg4PYV9oZH+Numr3TDNqlT2v60F+fZG4ppm6A=; b=8TpBPUYlMpe99Wy4MtFO+G5FMsAU594qBMLjaPbbTQaF/l0GF2Rgz5PEarXQGUC7U59m+QmVJ rouYGXoseN8DFOk/KglyX6LbcysJhd8mJLV8BDu96je7w6S40qMm4Tt X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-Rspam-User: X-Stat-Signature: qwx1q5ozgkn6d99hoi81bh5kbd6a6yar X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 10E1E1C0012 X-HE-Tag: 1706641474-890799 X-HE-Meta: U2FsdGVkX1+2THH8t4DAEQQzG8nAtFD7S50sJHXKP0YPBkGCbi4B25zQRMB6JhQwo68ZYlUohSOZLNS9xChhQA3XTIHEdJhOJdmNeb2OQ+b6MX/99JSMJIU7EYfYsyeTp85ZwYOUgwteo2vDc0//KlJfq2Wa8YkTbiuz9Sf8NCAxhLkkCNABTPV5gVZT2fya/5JAeKzzGEqxymk1uhrNatbbU+3Ns/EmTj0LNlhtwLWuG32vbxEp+ZssqjnkCbZCvsAcTl1oHS1ufixNV0/qL1A5a+jqWADPKkGbe4+A2Uf5pvdUx0bv7lNO3+pIfmVzGsxiMDs6SjfrKxyUgJqssFZznEJaJgQ7UtlZfJwX5MkheE5f1IB1boDwLt2xCHQYFj3eP2+hbRNC7lsmcjUTA/uqi9WVvSB0HCX94t7isUMVGdG44pyf2hRdlLYcGcIwGy8rL3ctt5W4DTYEMpWiQUGtV3S6QHTpNvnxe3FzJjzq2txbjKtrVv8cyOX+7CKR1rGn9G1F9oE5zVx/bJKOnF8TrhwJC2mImH1TKCo3UAfO8zNzMVb7HxuZrue2lE76WQW21OCCbGatjVS7MyHRBL8zU1Tinq/O4T9sFzK7bu2drPciiyrmAmt1gMU1BHaehC8DYjtE7AxuY7OfgjZuQN42m2mpJicsBMwPbwpzR+O62i7h3MfigLrHA/2QBfqswdvjeDpdayraYVIkpZXTc19coUNhH45PgGnW+EmVFApXPxTWFHG3b62Ga69s9z4LPrxUIxZzwFZgQVS8SE1orBX+1IDJaObLxKUnaQHHrscl6w3i6+/VO7hrx34upB2dU++1A+0dTrxYxhYWr6/4QoejhsxuMUP1Au7kSDcUHUqEhlwRZxCnEEyP0h1OUB+9L1E9xYD2bg5UqlhKbeRMQVhLX9/qqU8+Ar9bc1+c2XnCMhlK68DNsr4+P3m+kuUpuXEE0D3v2xaKjha2D30 SuvKMHKb ARC/Ao+Od7hlT3OTjl5PpH/Sk5e23skDSJ1LyeIdDntgtl5bfpC0Iz+XD41pqftPg/k1ygd+R0cVV47U5dfw79kULU/Plv8tXMzGPF5KAOjWsCbNJnBtZ6IwvRp2kRnc//4sd X-Bogosity: Ham, tests=bogofilter, spamicity=0.042357, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On riscv it is guaranteed that the address returned by mmap is less than the hint address. Allow mmap to return an address all the way up to addr, if provided, rather than just up to the lower address space. This provides a performance benefit as well, allowing mmap to exit after checking that the address is in range rather than searching for a valid address. It is possible to provide an address that uses at most the same number of bits, however it is significantly more computationally expensive to provide that number rather than setting the max to be the hint address. There is the instruction clz/clzw in Zbb that returns the highest set bit which could be used to performantly implement this, but it would still be slower than the current implementation. At worst case, half of the address would not be able to be allocated when a hint address is provided. Signed-off-by: Charlie Jenkins --- arch/riscv/include/asm/processor.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index f19f861cda54..5d966ae81a58 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -22,14 +22,12 @@ ({ \ unsigned long mmap_end; \ typeof(addr) _addr = (addr); \ - if ((_addr) == 0 || (IS_ENABLED(CONFIG_COMPAT) && is_compat_task())) \ - mmap_end = STACK_TOP_MAX; \ - else if ((_addr) >= VA_USER_SV57) \ - mmap_end = STACK_TOP_MAX; \ - else if ((((_addr) >= VA_USER_SV48)) && (VA_BITS >= VA_BITS_SV48)) \ - mmap_end = VA_USER_SV48; \ + if ((_addr) == 0 || \ + (IS_ENABLED(CONFIG_COMPAT) && is_compat_task()) || \ + ((_addr + len) > BIT(VA_BITS - 1))) \ + mmap_end = STACK_TOP_MAX \ else \ - mmap_end = VA_USER_SV39; \ + mmap_end = (_addr + len); \ mmap_end; \ }) @@ -39,14 +37,12 @@ typeof(addr) _addr = (addr); \ typeof(base) _base = (base); \ unsigned long rnd_gap = DEFAULT_MAP_WINDOW - (_base); \ - if ((_addr) == 0 || (IS_ENABLED(CONFIG_COMPAT) && is_compat_task())) \ + if ((_addr) == 0 || \ + (IS_ENABLED(CONFIG_COMPAT) && is_compat_task()) || \ + ((_addr + len) > BIT(VA_BITS - 1))) \ mmap_base = (_base); \ - else if (((_addr) >= VA_USER_SV57) && (VA_BITS >= VA_BITS_SV57)) \ - mmap_base = VA_USER_SV57 - rnd_gap; \ - else if ((((_addr) >= VA_USER_SV48)) && (VA_BITS >= VA_BITS_SV48)) \ - mmap_base = VA_USER_SV48 - rnd_gap; \ else \ - mmap_base = VA_USER_SV39 - rnd_gap; \ + mmap_base = (_addr + len) - rnd_gap; \ mmap_base; \ }) From patchwork Tue Jan 30 19:04:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13537875 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 07BA2C46CD2 for ; Tue, 30 Jan 2024 19:11:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8098A6B009E; Tue, 30 Jan 2024 14:11:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B9246B009F; Tue, 30 Jan 2024 14:11:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6811E6B00A0; Tue, 30 Jan 2024 14:11:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5A1E46B009E for ; Tue, 30 Jan 2024 14:11:07 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2C9D2A213F for ; Tue, 30 Jan 2024 19:11:07 +0000 (UTC) X-FDA: 81736920174.09.A82A1CB Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by imf03.hostedemail.com (Postfix) with ESMTP id 3169420012 for ; Tue, 30 Jan 2024 19:11:04 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=TSkhKx2a; dmarc=none; spf=pass (imf03.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.160.175 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=1706641865; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f4k3XgG6Vs4V2eymg6847wUAtUHshLOeTHqeR5jZPT4=; b=Rm6inP/w2Hqmpamuk+slUd079gvSKGC8Ct2lvrGm2rF+TSqljKRql2NK0iImiqcTvJZjwP VDTcqXk+EmLQUn86GN2UZq8+d/7TX8b2LONOZhrU0Q52NKlA005TTICk08pb7E0fVUZfNl inZNJDJEtIP6i4dDdZAu4yj+LOTny2M= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=TSkhKx2a; dmarc=none; spf=pass (imf03.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.160.175 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706641865; a=rsa-sha256; cv=none; b=xBWmZQfUJtdKt5DrANj8tEScSPsKbIh/0iDKav3tSfzi5dNf678PVp7IFzXC+QMGHnmgVG JI/4UoHjXxAhvHWeiUfdz3nU/ZSviohxrERum2TcizX7XXNx7ydBtPgnj/H3OOES6S9S9g B7/+vo0Rdnv4V2SD8mIxlH5jxdt0+BY= Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-42a9f4935a6so934441cf.1 for ; Tue, 30 Jan 2024 11:11:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706641864; x=1707246664; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=f4k3XgG6Vs4V2eymg6847wUAtUHshLOeTHqeR5jZPT4=; b=TSkhKx2aoRj2YYXeUvTGhUw//F/voyY7gXWAeSTEk4R1DDHtkSjNACzl7ueF6/M2MV t4BogeGpVvfBBZ4xl4fgmlZGihzHgjK6ViRPfjyhK739UdpplFFhTzzYa4Ohozuto0QT lVUdkaPAFEsx1cktIy6XIZAOL4whyedXqF21OyMtmd3C+d1zZoVncDBWpzdG0uTArSHc uCBBQH/Hiz4eLcTHKSWV5aNWhGouMBvH1YzR7ZlSgCId2iMUS0zbXFn5pNqkorLuGxzq MHKdIvKGFGsvG+OLGcWX73tspRsylBXshoym73DUE49FqjT1JFGDJ06LP2yzWVNG9kL5 uQqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706641864; x=1707246664; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f4k3XgG6Vs4V2eymg6847wUAtUHshLOeTHqeR5jZPT4=; b=eeNdXzvvr7blLwsLZ7sJubX/P8vVINLGWd/MvaxGaxo50/Ltz0DMq+kTqn2uikul5d j+yF2gSujfG7y+aW5FFJ9mwoCm5IoThzmqbCUIekUcoc+G42pUsHMDhYZQ294RFz/nh9 nqRdxUZ8gTFmvEeUhCCdIqQDmC6QM1PoTZkQbzi6q7kY70LyI1/dLsjaqtG78mT//U7b AQWD1mOCoeX3iD3W+jaAouLrkVBgnIK3uWjiMJ8Mr6XTzYRXfS5rgWWta8TDdTysLQnU 8qkd9V4OEy7xgmo4buRh3joJVO7DcK/fplukHfLQUQVjOTJb91fje8FGX7jusTydnboc 7sfw== X-Gm-Message-State: AOJu0YwzjzWGb+FfY4pZnQJoWs0gbk0zL4Dz6Vu+48JsGohT+GCGtp4k pNy1gQPkqQHiBpnFE0cmXkIQA+oE259tic4rF22c1ovhgZYFzkK1Sy3/xj/No2wG5/ImUIbP9Re 6 X-Google-Smtp-Source: AGHT+IFgptya8Q1OvyF+I3gPETTKvinxvv5APyOAribhmdoFU4/DBbXE6gQ2fksCvo6oajrQfoMLLw== X-Received: by 2002:a17:90b:38e:b0:295:4b25:212b with SMTP id ga14-20020a17090b038e00b002954b25212bmr2367613pjb.4.1706641475147; Tue, 30 Jan 2024 11:04:35 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id f6-20020a17090aec8600b00295c3bb9318sm1196541pjy.54.2024.01.30.11.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 11:04:34 -0800 (PST) From: Charlie Jenkins Date: Tue, 30 Jan 2024 11:04:31 -0800 Subject: [PATCH v2 2/3] selftests: riscv: Generalize mm selftests MIME-Version: 1.0 Message-Id: <20240130-use_mmap_hint_address-v2-2-f34ebfd33053@rivosinc.com> References: <20240130-use_mmap_hint_address-v2-0-f34ebfd33053@rivosinc.com> In-Reply-To: <20240130-use_mmap_hint_address-v2-0-f34ebfd33053@rivosinc.com> To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , Jonathan Corbet , Yangyu Chen Cc: linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706641471; l=8041; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=FRDzzVwyS7nuVapUvX+XBqyYOrJdFna/LWspy9EPMlc=; b=rSHBvYDxfdS3K26d2oaN4+tX7NILBW5lAv4B0A2eQz8EBV0f0LtHqjJKt61QbdAbheOm3eOie DHnjVcEZiPTCMJdRG/c7TW+3+fDluHKlANMAtpDO0C6sTPtDfef+wRW X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3169420012 X-Stat-Signature: ne56koocob1jgjgma1n3yjdpf8ojyofj X-HE-Tag: 1706641864-627805 X-HE-Meta: U2FsdGVkX19q8Pl5Ys3ImGKM/nou7ZirWVObLzi3SFB1dX7ghnIGaSchThKxK6dOkyun6gqN2NKB9kbWnNAXiolh4WeRzC0Xl8L76o8CsTtrxcRtR0oDDWpGw6nMy3/G44hG/IGSc3twfqo36s+AocO8GaWyDeptrTaoJ/oxDR0BjDe+0+clLlFzsxeWUN0EeQ56PLop9UP25xaIRCMjxIwf0XzV2eqkbDVJzeNOTYdMPWBXmrr5R86950B/TIplDD9e4jhx+ZCHmkAld/XqvewZ2BAjpOjWTIkSVZWfn7FvAflPU3hyMo9wZxrkdy+q7c02/C0HBenIFSQTXlN5b2EaQ2FCFicViVsbGFZmGqvLvkKETlydMzdvMUdFkMIX2ySKWjqr2rT2GYOXVprE9DpHWkbB2eST1YV/xyMYYCKiLKldkUSWXu5EU7vgv+R52dp8AZZDKo4OMwN3c86pOY3e0rapWWF8+A/nFMgpRatOaaEPVQ3/r0g/jHdjYh1cc1bZGm0l/hzSpS3u21OKdKNR9oD2hDiI6DNnHzjD/oz3YbXnPpwGqCf3aLkw9vGu1QStEEy/jNi4ApoZG0mCtBzoR2Vu+IUwXzraNqbywfcuth/yNSziO+EoxpH1qOT/qoIXZO5ygB27jlICvIdZmORnxgOf6+6Xju7WTBTRwKWCfw7GZd4yy3FbMANQMZaRvcO1H9SKeg8jLePmb9X2OzkGr3wvV3bEsJw96WdCaUSneGyBY9gYXxotp2z2BPlvpfRT8RTYhD0zYGNkEpxSQ46H3qzks1srJTxSQrqMuOIHKBxskFyk50b6FJC1uHAmG13F6eP60ZC1R47J5KxWP+lVHj93iAV/1E2y1jhMDUJv5fMlZgRdP7XdW9weEJzwiX6UEhr8jSy2YIpikzUj8EVNmFaQLph5qyX6zWfH+rqTRV82bchX1kMKVVRrKwRLk1k9mcH9jKP+wkUgM/y CUvMf7iX ouyJ2yT68tW7Fz+dV5e5bIdzTVBwRs1ZDL8+8qyBTuafPkMJwMRAgRi9Oc6QLWcZ3cUVJ+Ei0VQEl64rAn4u9ci1TFyFi7/bQKrQxgCdG6xiRZwW/jlIOkq7BfJI1KdgxlhRx/6A5QQgfxsO8onC54AT0uaE3op1zkVrYWZscLGVad0ax2W/JQGda0mJYRR/rv9trI5B4osdpqdByR4o3DTMAjlIPPRml5NX/ownazvAYhBMa5NTeGMJKAg5+h5UKkO6VgFnNxZlQxd3AP/y2nE7qysR/VCZia+W1e1N7iabhYfxzWoxhXgXmFenikd/cD1RLz1PGA6m2+AQx42SorKu8xkk9vzkxLBmO+nHI6tsordRnfDazVjJkw3Qf2Wuk/5OJPsCAyrpu7PmSruYWBnhQB+9vh9nvk24ct4f8c6r6Ipo0+G8U2XWcf82BUDTVAReWB9Rix3PROXU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.004917, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The behavior of mmap on riscv is defined to not provide an address that uses more bits than the hint address, if provided. Make the tests reflect that. Signed-off-by: Charlie Jenkins --- tools/testing/selftests/riscv/mm/mmap_bottomup.c | 20 +---- tools/testing/selftests/riscv/mm/mmap_default.c | 20 +---- tools/testing/selftests/riscv/mm/mmap_test.h | 93 +++++++++++++----------- 3 files changed, 53 insertions(+), 80 deletions(-) diff --git a/tools/testing/selftests/riscv/mm/mmap_bottomup.c b/tools/testing/selftests/riscv/mm/mmap_bottomup.c index 1757d19ca89b..bad8e854263d 100644 --- a/tools/testing/selftests/riscv/mm/mmap_bottomup.c +++ b/tools/testing/selftests/riscv/mm/mmap_bottomup.c @@ -8,27 +8,9 @@ TEST(infinite_rlimit) { // Only works on 64 bit #if __riscv_xlen == 64 - struct addresses mmap_addresses; - EXPECT_EQ(BOTTOM_UP, memory_layout()); - do_mmaps(&mmap_addresses); - - EXPECT_NE(MAP_FAILED, mmap_addresses.no_hint); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_37_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_38_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_46_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_47_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_55_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_56_addr); - - EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.no_hint); - EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_37_addr); - EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_38_addr); - EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_46_addr); - EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.on_47_addr); - EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.on_55_addr); - EXPECT_GT(1UL << 56, (unsigned long)mmap_addresses.on_56_addr); + TEST_MMAPS; #endif } diff --git a/tools/testing/selftests/riscv/mm/mmap_default.c b/tools/testing/selftests/riscv/mm/mmap_default.c index c63c60b9397e..a3874778d795 100644 --- a/tools/testing/selftests/riscv/mm/mmap_default.c +++ b/tools/testing/selftests/riscv/mm/mmap_default.c @@ -8,27 +8,9 @@ TEST(default_rlimit) { // Only works on 64 bit #if __riscv_xlen == 64 - struct addresses mmap_addresses; - EXPECT_EQ(TOP_DOWN, memory_layout()); - do_mmaps(&mmap_addresses); - - EXPECT_NE(MAP_FAILED, mmap_addresses.no_hint); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_37_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_38_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_46_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_47_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_55_addr); - EXPECT_NE(MAP_FAILED, mmap_addresses.on_56_addr); - - EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.no_hint); - EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_37_addr); - EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_38_addr); - EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_46_addr); - EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.on_47_addr); - EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.on_55_addr); - EXPECT_GT(1UL << 56, (unsigned long)mmap_addresses.on_56_addr); + TEST_MMAPS; #endif } diff --git a/tools/testing/selftests/riscv/mm/mmap_test.h b/tools/testing/selftests/riscv/mm/mmap_test.h index 9b8434f62f57..93face2b3118 100644 --- a/tools/testing/selftests/riscv/mm/mmap_test.h +++ b/tools/testing/selftests/riscv/mm/mmap_test.h @@ -4,60 +4,69 @@ #include #include #include +#include +#include "../../kselftest_harness.h" #define TOP_DOWN 0 #define BOTTOM_UP 1 -struct addresses { - int *no_hint; - int *on_37_addr; - int *on_38_addr; - int *on_46_addr; - int *on_47_addr; - int *on_55_addr; - int *on_56_addr; +uint64_t random_addresses[] = { + 0x19764f0d73b3a9f0, 0x016049584cecef59, 0x3580bdd3562f4acd, + 0x1164219f20b17da0, 0x07d97fcb40ff2373, 0x76ec528921272ee7, + 0x4dd48c38a3de3f70, 0x2e11415055f6997d, 0x14b43334ac476c02, + 0x375a60795aff19f6, 0x47f3051725b8ee1a, 0x4e697cf240494a9f, + 0x456b59b5c2f9e9d1, 0x101724379d63cb96, 0x7fe9ad31619528c1, + 0x2f417247c495c2ea, 0x329a5a5b82943a5e, 0x06d7a9d6adcd3827, + 0x327b0b9ee37f62d5, 0x17c7b1851dfd9b76, 0x006ebb6456ec2cd9, + 0x00836cd14146a134, 0x00e5c4dcde7126db, 0x004c29feadf75753, + 0x00d8b20149ed930c, 0x00d71574c269387a, 0x0006ebe4a82acb7a, + 0x0016135df51f471b, 0x00758bdb55455160, 0x00d0bdd949b13b32, + 0x00ecea01e7c5f54b, 0x00e37b071b9948b1, 0x0011fdd00ff57ab3, + 0x00e407294b52f5ea, 0x00567748c200ed20, 0x000d073084651046, + 0x00ac896f4365463c, 0x00eb0d49a0b26216, 0x0066a2564a982a31, + 0x002e0d20237784ae, 0x0000554ff8a77a76, 0x00006ce07a54c012, + 0x000009570516d799, 0x00000954ca15b84d, 0x0000684f0d453379, + 0x00002ae5816302b5, 0x0000042403fb54bf, 0x00004bad7392bf30, + 0x00003e73bfa4b5e3, 0x00005442c29978e0, 0x00002803f11286b6, + 0x000073875d745fc6, 0x00007cede9cb8240, 0x000027df84cc6a4f, + 0x00006d7e0e74242a, 0x00004afd0b836e02, 0x000047d0e837cd82, + 0x00003b42405efeda, 0x00001531bafa4c95, 0x00007172cae34ac4, + 0x0000002732f06b2b, 0x00000012cbf8fd0b, 0x0000001fcc6af0e8, }; -static inline void do_mmaps(struct addresses *mmap_addresses) -{ - /* - * Place all of the hint addresses on the boundaries of mmap - * sv39, sv48, sv57 - * User addresses end at 1<<38, 1<<47, 1<<56 respectively - */ - void *on_37_bits = (void *)(1UL << 37); - void *on_38_bits = (void *)(1UL << 38); - void *on_46_bits = (void *)(1UL << 46); - void *on_47_bits = (void *)(1UL << 47); - void *on_55_bits = (void *)(1UL << 55); - void *on_56_bits = (void *)(1UL << 56); - int prot = PROT_READ | PROT_WRITE; - int flags = MAP_PRIVATE | MAP_ANONYMOUS; +#define PROT (PROT_READ | PROT_WRITE) +#define FLAGS (MAP_PRIVATE | MAP_ANONYMOUS) + +/* mmap must return a value that doesn't use more bits than the hint address. */ +static inline unsigned long get_max_value(unsigned long input) +{ + unsigned long max_bit = (1UL << (ffsl(input) - 1)); - mmap_addresses->no_hint = - mmap(NULL, 5 * sizeof(int), prot, flags, 0, 0); - mmap_addresses->on_37_addr = - mmap(on_37_bits, 5 * sizeof(int), prot, flags, 0, 0); - mmap_addresses->on_38_addr = - mmap(on_38_bits, 5 * sizeof(int), prot, flags, 0, 0); - mmap_addresses->on_46_addr = - mmap(on_46_bits, 5 * sizeof(int), prot, flags, 0, 0); - mmap_addresses->on_47_addr = - mmap(on_47_bits, 5 * sizeof(int), prot, flags, 0, 0); - mmap_addresses->on_55_addr = - mmap(on_55_bits, 5 * sizeof(int), prot, flags, 0, 0); - mmap_addresses->on_56_addr = - mmap(on_56_bits, 5 * sizeof(int), prot, flags, 0, 0); + return max_bit + (max_bit - 1); } +#define TEST_MMAPS \ + ({ \ + void *mmap_addr; \ + for (int i = 0; i < ARRAY_SIZE(random_addresses); i++) { \ + mmap_addr = mmap((void *)random_addresses[i], \ + 5 * sizeof(int), PROT, FLAGS, 0, 0); \ + EXPECT_NE(MAP_FAILED, mmap_addr); \ + EXPECT_GE((void *)get_max_value(random_addresses[i]), \ + mmap_addr); \ + mmap_addr = mmap((void *)random_addresses[i], \ + 5 * sizeof(int), PROT, FLAGS, 0, 0); \ + EXPECT_NE(MAP_FAILED, mmap_addr); \ + EXPECT_GE((void *)get_max_value(random_addresses[i]), \ + mmap_addr); \ + } \ + }) + static inline int memory_layout(void) { - int prot = PROT_READ | PROT_WRITE; - int flags = MAP_PRIVATE | MAP_ANONYMOUS; - - void *value1 = mmap(NULL, sizeof(int), prot, flags, 0, 0); - void *value2 = mmap(NULL, sizeof(int), prot, flags, 0, 0); + void *value1 = mmap(NULL, sizeof(int), PROT, FLAGS, 0, 0); + void *value2 = mmap(NULL, sizeof(int), PROT, FLAGS, 0, 0); return value2 > value1; } From patchwork Tue Jan 30 19:04:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13537855 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 D1CE2C47DA9 for ; Tue, 30 Jan 2024 19:04:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E95228D0003; Tue, 30 Jan 2024 14:04:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DCFE18D0001; Tue, 30 Jan 2024 14:04:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD4678D0003; Tue, 30 Jan 2024 14:04:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A9EEA8D0001 for ; Tue, 30 Jan 2024 14:04:39 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7CE021A0403 for ; Tue, 30 Jan 2024 19:04:39 +0000 (UTC) X-FDA: 81736903878.15.0CD21BB Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf13.hostedemail.com (Postfix) with ESMTP id 741992000B for ; Tue, 30 Jan 2024 19:04:37 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=tnjIE9TO; dmarc=none; spf=pass (imf13.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.170 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=1706641477; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GGh1y1t0UhB5LcXiFRn0m1YgEny22RmTe/CDN12WiLQ=; b=ma9gQlZhmeHTLvUNNM9YPdwHU9gRx+tA5obewIDFkmDiZ3LVrcFdCDt+pVPgx4RziZE7Iw KkuS++W/wY2yafeSkbFoOzNQ1FukxOICZFTVeJHhLcAhbC6qc7IBLqrSG0OdpK448Kg2Qo yNxvLwAvdFtFGCcrvkVUNwzDppy0h3w= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=tnjIE9TO; dmarc=none; spf=pass (imf13.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706641477; a=rsa-sha256; cv=none; b=H5gCKEG/bwj7vibXoSE0wDNLEVIzRz5cSsSXcBXYxD+PlPH6f97A+92/q9GKZ36+aNVO9q fNyfw0Icd5aedRaCOfb2PKqCATbPRIUOG+3eUXgFa+9iTt9k6xWUPLK9r3e4kxxZhQ0Uxw nfB2ja3JQCtzjY1cqAa9oCGM8kaGlt8= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d8f3966982so12580055ad.2 for ; Tue, 30 Jan 2024 11:04:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706641476; x=1707246276; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GGh1y1t0UhB5LcXiFRn0m1YgEny22RmTe/CDN12WiLQ=; b=tnjIE9TOBaoII8LqEUs3D6a7QyF6UlvTZCnnxn095JwlnK2QU/DhqBzlXlvMwbVQuj uPPmChYtUW1Vt3ccoq9j7QKyiTYrMba88SI2w7SlR8Zl4s1Ho4iCcs9mKoTEORXw+GO3 W0TLW9TsN+LPhhZx2JJqwHulGdfgGRiWcoydccg0aWUfyAY6Mxyz38YkJfBZqElXwpfF Ek1HOEI/GN1ixRzxCV5iqHUCXa1BXSZNcHlfPsJIOqoHYSD8xhI95AlxmSdpyvelHXrw bJ13AdMV6pMVqvqVtt8ZraZdrPwBCH43FLYS0YAlWB2ovvD66+dgeyGTw2QLWLii616I u5HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706641476; x=1707246276; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GGh1y1t0UhB5LcXiFRn0m1YgEny22RmTe/CDN12WiLQ=; b=s9DmfDnrOwB3hFtQ9Q0DXMvMErTgjSZ3gCORspYGRKxCMBewinQHbZGlRVZ5u1wcl2 uI7AT6lKuTdab27rdSLaSdJcyO5QkOqcrVNiiNg8Fqua7iTSGhug7DI4yEo9zfVKCrj5 xKshjN2Ls/1b0kKvEIAmVWQfQdTvf5ze808MQo+hKoh2vXwk9J8BfYbzAWj1+dDjMUX1 agDzxcmIYMo7KT0y+eeJSX5y/vplYOhWlSLECkDdQEfOVaxzbxq+FY6FXyNV+QHTGsuP nBS+3qSwg+8doKaNzCgLRl9HqGlZ2LrmldL4BSgHkc7m7s6uzrroa44pGRe8T7GTqHOd kYKA== X-Gm-Message-State: AOJu0Yx2mICTVYC/WsWYRlyvngebavwR4jOrBolkhWGMUozgBsUQErnK /Q86xDdaetZU/ol/IOkWyKZZ2JB6rje2apzbbnlQ2Gq3Kb+R3BU0DQ092q7wBA0= X-Google-Smtp-Source: AGHT+IEVbIgYt6XNaKR6BtdW5/KffpCVH/pv+Lo7pyQOi/0UoKVRKbnu4oD2c+g6OjEIw8FcF7U3LQ== X-Received: by 2002:a17:90a:3dc3:b0:290:6878:db67 with SMTP id i61-20020a17090a3dc300b002906878db67mr5117026pjc.9.1706641476461; Tue, 30 Jan 2024 11:04:36 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id f6-20020a17090aec8600b00295c3bb9318sm1196541pjy.54.2024.01.30.11.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 11:04:35 -0800 (PST) From: Charlie Jenkins Date: Tue, 30 Jan 2024 11:04:32 -0800 Subject: [PATCH v2 3/3] docs: riscv: Define behavior of mmap MIME-Version: 1.0 Message-Id: <20240130-use_mmap_hint_address-v2-3-f34ebfd33053@rivosinc.com> References: <20240130-use_mmap_hint_address-v2-0-f34ebfd33053@rivosinc.com> In-Reply-To: <20240130-use_mmap_hint_address-v2-0-f34ebfd33053@rivosinc.com> To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , Jonathan Corbet , Yangyu Chen Cc: linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706641471; l=1848; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=2lxtSNzBMdkYqwC90W41TvLPqjzE8CkjIf8iMq/P7L4=; b=94N9u6Dy7xw5qCDQS+0vjMBDMNCSUN+BRd4o21tz6vC6lNovWVUFsgXKvGka/gJHpv0qpikoL uaW/c0J2VbkCXqP7svfJ7tYuinSlvY7wIe5t7X3qvAN/WmnM2V6JlUj X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-Rspamd-Queue-Id: 741992000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: wwbc6fdka7iq6mbs7c74ouon3ohthtwd X-HE-Tag: 1706641477-569077 X-HE-Meta: U2FsdGVkX1/2VBSsUXoe+GAaX3BhCvE6zV1e74kQPcKoCIXVVdgG4Mk+KZCrNDa6LNIkASt5h9Hm9tq4C40viowreNRDGvYXVKDXa7fFMQiCCOrUYGYk7KptRZXo/rfeqawVnPvlV5y1wsL5EFf+UfNU9VESKPGJkm0EXpjZRwLfEYoRWsj2qLRUySqnlGA3kben3cS163qrGt1LzNFGQXp5E0ZxRVyOIPgO9ao2OieB1AhZKrqguPgz779SQe3dQM6PiogxhwGvvPHKk699X7mTFYaPVsXa7QDMWMz/8g0294gISBNt/GzISS8/IN6GRUWIN4RksRVa5/6Peiko4e+kwF62+FyEHAkewX6Tj0sd6RSSz3Jc6JS4bY0uLsOI01TsKmqFSs/bIvmkvICrd75QBy5A3ZTnwDoyspVNFN8rcQiXiU/0dbmss7Asbp+JxDB6tc/DBOwGTfZzy+GiD1QdSfeW5fdvJ1tdn1bQsGmnGkY1dv8i1u3n+AE1oqjYDLw1qDobRprE+TZifc7+l9V0JvBIz3RysYD/FBC1YvqEbiVRZBwhMLxUe0nIrAYT+FCLXoK0Cn57JUGGKV3lIKpNjNnve4iLnMHxMb2NL7+y73gkNb5/urRrui4m4wf5IxznhDpruWeZsEJMvBWq2UAlN9tcd3War3grkZ8RkvGrQ0OC+qn/wS6JMbgRNMn7Lr4wwJJeLLi33XcwdtVnfm7OLPCb0xBJ1BQdj7wVpir/KkpVhy1nFRDJxesKrBF3KxeWSHGSR0GF5ITf7ilPlAivqaO+5dEaoU60qzDryz9NHwxBMKOlppn4ZS+Q3smbhNqtFcmmeHvsAxF8ZNm1f7niBp4fzs1besdOSxDJm+JLuzpBhj0HdbfCjhG6dq92HglA9uIHxYPRgkT6ppT6SOxhZ54UT4lMSE+G7xkuEJdalXx594qXFQK8d0S5S0ZssbXchK7H5ddyNmQS/jz 4SuyQZ71 BQm0aNY5l8KiKANZWR+yLp6mN5rLKHj5dYJpndY3u+D8BYNdA6ih5DSl8aLN6fKCpjGadaRaRMDL9x+iiLv/CSxy9uoTLi4cJRQa/+xDqRX54x+E34Hq3NBMgW+U/W9WrwgvYIIBJuD/Ww77sw1agnhXujRiAfkS52L39XqeLAvt+McnW8nEcFDftbGyn6PL6u/S5sg+mvs9YLL9HxD5/96l+YpAa9envSi9Y6T9NqxFUPbYVsIo84XoifRLk36hsTgegT4FulCzx1wcfpo1nsZjovrd4qR/2w4nDGSkgQButgnX5sjdlKnXJ4SVflUzIGq5kwkkD3M3vAaaSGae9xqC4nOpfRLOgzb5Fb+Ifq4qJq5pBFT3Vb6qxOL/IWE4Wfp9eQ4OnDWgTA/7oq00CeySTu9cOGOcDOGy8gUVrR5XfUDcv4u6GmgTII+DZJEIBJfcVWI4i5Kn3dOQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.216725, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Define mmap on riscv to not provide an address that uses more bits than the hint address, if provided. Signed-off-by: Charlie Jenkins --- Documentation/arch/riscv/vm-layout.rst | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Documentation/arch/riscv/vm-layout.rst b/Documentation/arch/riscv/vm-layout.rst index 69ff6da1dbf8..e476b4386bd9 100644 --- a/Documentation/arch/riscv/vm-layout.rst +++ b/Documentation/arch/riscv/vm-layout.rst @@ -144,14 +144,8 @@ 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. +a hint address to mmap. When a hint address is passed to mmap, the returned +address will never use more bits than the hint address. For example, if a hint +address of `1 << 40` is passed to mmap, a valid returned address will never use +bits 41 through 63. If no mappable addresses are available in that range, mmap +will return `MAP_FAILED`.