From patchwork Wed Aug 28 05:49:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780620 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 83EF2C5472D for ; Wed, 28 Aug 2024 05:49:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEE506B0089; Wed, 28 Aug 2024 01:49:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9C2D6B008A; Wed, 28 Aug 2024 01:49:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3C666B008C; Wed, 28 Aug 2024 01:49:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B4F2B6B0089 for ; Wed, 28 Aug 2024 01:49:36 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 721A9161CB1 for ; Wed, 28 Aug 2024 05:49:36 +0000 (UTC) X-FDA: 82500577152.08.5BA4EF6 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf08.hostedemail.com (Postfix) with ESMTP id 76806160007 for ; Wed, 28 Aug 2024 05:49:34 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=NtqiHepZ; dmarc=none; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824103; a=rsa-sha256; cv=none; b=7bP5NdzqTC68edkJXxHXpzHjuTW3GqzAc9iJVJbX0UYkeFpei8CeXXQnaTm7cWd8+AcHq3 3dQrNJMwBSqWe39KUYQmRespl61GIhOL3XsWP7+iKxxVqwFr5tu+o/Fh1O79OwWJjS0Pml 7Z/u8Np2JjKumbKtWYxKiEtmHa2u8gE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=NtqiHepZ; dmarc=none; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.174 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=1724824103; 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=moiMY/9kOk6Xzt0Khn1FkF8wyTL4BDNBgOSp+BMugag=; b=fQ1rZVB2be76I9U4XFaIPURPNnHvmxFHaIusyIQgeBA8CS760BVByT+ZGcKXz2QjnT0x69 QkzRlGkIvFl5fGrXWBY17sPJXvwr5l/UdQZJNu7Ir5Q0JTzhArFoDJxhuhhrGf8Eekex1A g65m++POUrhG7CTJBr9pd6iu+gH9esU= Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20219a0fe4dso62940865ad.2 for ; Tue, 27 Aug 2024 22:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824173; x=1725428973; 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=moiMY/9kOk6Xzt0Khn1FkF8wyTL4BDNBgOSp+BMugag=; b=NtqiHepZMNG2HegPNMXUXu/mW1UI1sR15n/WrBka9HM9YeL7NAFrZ/R3D0TYNnq5I3 KdRABvakf1xcSTMLqEqCxdaS8pE1biCUjE2SNDxB99d1c+yUM6mMLeYBKEPvqoXrFMdP 0uSTjUGf8z0U8uyT/fVXyDUKiLNO5PXpBVtuuIYFY3cjePMSDa9zK+ElpFLnF6MCZFkm L6v2DUGaW1njZ9nlrV6HVkB0ZyiJmmzlidOb/JU7Um0jnshkQ1jmilwScXnH4BvuGnpO s+wDIHBDKNmOeIRv0ZMvMFFTwOqRW7ISfuoIQ+HugrL/ry3CO5eHTaE9JlQ3Im9uwaKn WA1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824173; x=1725428973; 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=moiMY/9kOk6Xzt0Khn1FkF8wyTL4BDNBgOSp+BMugag=; b=wqDzkLK/zsjeQsTQpcn2XhJaMqVzt929dXI/RBBlXrr/iO298QxZDINaq/JL24k6Wn 7ybpOb7G0wUn7ByGuAycJQWRQHO4w/trOUKF9af1oPx4jcAlR/lSowL/wsGbi5wqXfNs e06mIQ0oLuR4MqZWYyXlQZcPmSDUfxugQtpk93CMM9M/IgdCr+k41yukuqxAj9APERd6 mpvKCnhVyoxKY3BpUwWSPMyqRTiXouOQanG4Rz2xjsodk4LUjOwmqpco9Zpfy+9gVScF HVlXDCR2lQiYkHmPNMB9dHxzaIUNwz/9bypPjBp7FTGlJIh+Tqi/yi3ZrBKX0VG5+99Q TMGA== X-Forwarded-Encrypted: i=1; AJvYcCUd88EjYnigjrb8GnI4wjaQ1hOaBY/ZmEAqON8765SvHVOdRZpQsKqrWv8yiNClLe7GOFb89hbeqw==@kvack.org X-Gm-Message-State: AOJu0Yw9rRTC2JvTXxaaBswqE/MGsVXRDulAu0sa2pKkLPIxNn6aXIrM kiT5oX6JuFE5ANwQZGDm9whutxzsSiXyGQA5n9/tR+EoRA7ztjWhpM/Bwnf8UHA= X-Google-Smtp-Source: AGHT+IE+xcDspGauSp7IVmRnQSeJseOyw+wVLX4elXR4/BGbU1fHY0MaCzZG4/pxtEucaF+r97Z9DQ== X-Received: by 2002:a17:903:124b:b0:202:4079:1c19 with SMTP id d9443c01a7336-2039e47589dmr164242605ad.14.1724824172722; Tue, 27 Aug 2024 22:49:32 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855df0c4sm92092495ad.157.2024.08.27.22.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:31 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:08 -0700 Subject: [PATCH 02/16] riscv: mm: Do not restrict mmap address based on hint MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-2-46ff2eb9022d@rivosinc.com> References: <20240827-patches-below_hint_mmap-v1-0-46ff2eb9022d@rivosinc.com> In-Reply-To: <20240827-patches-below_hint_mmap-v1-0-46ff2eb9022d@rivosinc.com> To: Arnd Bergmann , Paul Walmsley , Palmer Dabbelt , Albert Ou , Catalin Marinas , Will Deacon , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Muchun Song , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Huacai Chen , WANG Xuerui , Russell King , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , "David S. Miller" , Andreas Larsson , Shuah Khan , Alexandre Ghiti Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kselftest@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2260; i=charlie@rivosinc.com; h=from:subject:message-id; bh=YMF9irkRUC4sRvnkdcE8hTIaJNmeFPHDQEKHg4RlOyw=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XbEGN52ULpq4/39venW688upWgwFDj9spqW3rOd57 Wdme6Ooo5SFQYyDQVZMkYXnWgNz6x39sqOiZRNg5rAygQxh4OIUgInoxjIyLPq831JpspB17kOr jRV1b1+9OjXz6TVOvZStd2IFbrHtWM3wV9buiFXmKu3sWVt1RJfzLlfjNmD+lbK6aQ3rc0+mG/t jOAA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 76806160007 X-Stat-Signature: z3xgg1dgtxnrr7unafrbzdxjbt4xxyni X-Rspam-User: X-HE-Tag: 1724824174-390674 X-HE-Meta: U2FsdGVkX1/D3NBC1K7TFD/HK4LutTkhi+Qc3pa9QHk+rZYQwmwu6pLIcruWBNZ9/pkgP0RbaaWpZouXs0qA3IGyzBBHzuQW2FWMx12nsxF9X4ARSbCzZrkpPtg9XYJAztqCypTfMf1MyNzm+zEgTAVXaaBpD/SiJ+edmhCtnnw/q8QKphg1gRaGs++zc6Vs1ENx96AEmPUQXRsJUdm0z4yHzma5cxz1aFmv7kGiU7ArevolPkosPLWFXvYKRKkwgY/jfjWgFowiGh+eehTlqdgA/jwhoJMEwrPmtpQQB7aAUZSD+2RzoM9ZtuuEH8/9pnPLd6YLewIpB4FQceQZNc8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ze3c9eRNCf+SDnMJjEeZVfvt X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 hint address should not forcefully restrict the addresses returned by mmap as this causes mmap to report ENOMEM when there is memory still available. Signed-off-by: Charlie Jenkins Fixes: b5b4287accd7 ("riscv: mm: Use hint address in mmap if available") Fixes: add2cc6b6515 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57") Closes: https://lore.kernel.org/linux-kernel/ZbxTNjQPFKBatMq+@ghost/T/#mccb1890466bf5a488c9ce7441e57e42271895765 --- This patch is pulled from [1] for ease of review of this series. Link: https://lore.kernel.org/lkml/20240826-riscv_mmap-v1-2-cd8962afe47f@rivosinc.com/T/ [1] --- arch/riscv/include/asm/processor.h | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 8702b8721a27..1015f2a49917 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -14,36 +14,14 @@ #include -/* - * addr is a hint to the maximum userspace address that mmap should provide, so - * this macro needs to return the largest address space available so that - * mmap_end < addr, being mmap_end the top of that address space. - * See Documentation/arch/riscv/vm-layout.rst for more details. - */ #define arch_get_mmap_end(addr, len, flags) \ ({ \ - unsigned long mmap_end; \ - typeof(addr) _addr = (addr); \ - if ((_addr) == 0 || is_compat_task() || \ - ((_addr + len) > BIT(VA_BITS - 1))) \ - mmap_end = STACK_TOP_MAX; \ - else \ - mmap_end = (_addr + len); \ - mmap_end; \ + STACK_TOP_MAX; \ }) -#define arch_get_mmap_base(addr, base) \ +#define arch_get_mmap_base(addr, base, flags) \ ({ \ - unsigned long mmap_base; \ - typeof(addr) _addr = (addr); \ - typeof(base) _base = (base); \ - unsigned long rnd_gap = DEFAULT_MAP_WINDOW - (_base); \ - if ((_addr) == 0 || is_compat_task() || \ - ((_addr + len) > BIT(VA_BITS - 1))) \ - mmap_base = (_base); \ - else \ - mmap_base = (_addr + len) - rnd_gap; \ - mmap_base; \ + base; \ }) #ifdef CONFIG_64BIT