From patchwork Thu Sep 5 21:15:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13793000 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 F26ACCE7AA0 for ; Thu, 5 Sep 2024 21:16:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F0EE6B0085; Thu, 5 Sep 2024 17:16:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 752826B0088; Thu, 5 Sep 2024 17:16:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A54D6B0089; Thu, 5 Sep 2024 17:16:19 -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 3ABB16B0085 for ; Thu, 5 Sep 2024 17:16:19 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E0D16A0BAE for ; Thu, 5 Sep 2024 21:16:18 +0000 (UTC) X-FDA: 82531942836.10.16248C2 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by imf03.hostedemail.com (Postfix) with ESMTP id D6E172001E for ; Thu, 5 Sep 2024 21:16:16 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=uQHebL7z; dmarc=none; spf=pass (imf03.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.53 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725570977; a=rsa-sha256; cv=none; b=EkDJC07JUz5htfVi2bo8Atf4y3Pkn7aQVJ1FAWXL8aZ+FtHjr9gB+0bMAoa9IrDy5cyMWW FNd21skPAhS0bn3UNXAibH2qVftA8Z0TIb9qoP+xb2xXAKSWxRnUpPijVl3dtSuD+UqIfR bJeo1+s4ex/vIEueIFTXe2AM/ZjoTg8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=uQHebL7z; dmarc=none; spf=pass (imf03.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.53 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=1725570977; 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=f6U8xmtXOad/vlvI1PiwvXKTTO0WQVhDEUoOSf42FlI=; b=Z8oCjpvmHmTPjHOBAnTve6dlsBAt7gLB1as1jE3dGiBTQY6JVWrg+kXANkZYhk2Gb/di0g w8HtflHwYxw9rjBuylO+TA3jwNBnQfnbd225TgLlz8Daj/dsXIcGERks5vmE7RopGRsi26 Ooj6XZxrMK0CVJCiEGJaxJgtDYScwRs= Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-70f6cb5518aso807647a34.1 for ; Thu, 05 Sep 2024 14:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1725570976; x=1726175776; 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=f6U8xmtXOad/vlvI1PiwvXKTTO0WQVhDEUoOSf42FlI=; b=uQHebL7zRoDZspOaLlbEMxx7WH0sL8Nh4bgvcq56sk2mlvvszivLqK92FdC5LCboFZ VtsRveuhN7nXaFId+bNQaMo79vXGzCX4iWW0BX4CenUFTyvS/T2nVGIdB/2rn96qVCxH h4RHeR3fxEE3c1U9kXuv7kEyvtYNKDYoizU9h1T6Ry9NfxWi7svd0WWyaMOqFLtR0+RW VTl8OKfYa7G6qD9AX7v4fIrlPe5E/Re4eE8RaMLw3crPlVSN/CSqE5n4zmv3T1rW3nLv 2YhZkYNBAKSHVwvW1dfFNWyIKP+LxHmBxba4rktvn2loXxmRztWHEzU/vZaFyZ46CHbu NmYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725570976; x=1726175776; 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=f6U8xmtXOad/vlvI1PiwvXKTTO0WQVhDEUoOSf42FlI=; b=wolE+wHqCnybIEGzQAXP7oDO+2ZtUoSrEE03fIgooRjJcSZUqCXt/PhcZ7m2OtYe7g 4liJSqHMogicQagdiomMv3sIitwdKL6jnTDtj1EHGiARUmU52024JRnRNzRmzVcWrfwl uiFtsGrByTvVOFc6OauE5zUqM4VBoAFiY53zL6fiZae6i6nFasMzedvb8HWLVaGYYBbj cG6bEUPA2dgd5HbLzIBkxAUD1jwEHEXYdjjZFEeqQDAWNwqnsJ+dfXP/WkSSBwdWWR0y HAgR8+dRBy9JFyZV7PlZ9k8tgI0pfR0mUUYm6W/Aq4vruGdP51I0Def4G0mKhrCwQP/p qsQA== X-Forwarded-Encrypted: i=1; AJvYcCVsSmZde9v8wa6WGDgD3kOuMX7rsH7mBCpkOrRiqSHMDMnsGFtXh10DCDffgcIMACSxmae//U+vvA==@kvack.org X-Gm-Message-State: AOJu0YxCXGWJ7bPhhN0kmVZB4/7+SWfgwq7OzJZZgL1afCE7QQHceFlZ qIhbMe/7lYNGNF3t4JaHN+7jEnBHrFKlB9JbdStX7WumkmbyrRkpWW7XXjSHCTw= X-Google-Smtp-Source: AGHT+IHmMPDz3EnCCj73XeYdf9AhtZ+Ct4KejhsVi5dvIA4rh768bjpktZjdCxUayXeGPhLE3R+w8Q== X-Received: by 2002:a05:6358:4287:b0:1b5:be34:9ad5 with SMTP id e5c5f4694b2df-1b83866e08bmr73366455d.15.1725570975653; Thu, 05 Sep 2024 14:16:15 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d4fbda7abesm3775746a12.61.2024.09.05.14.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 14:16:14 -0700 (PDT) From: Charlie Jenkins Date: Thu, 05 Sep 2024 14:15:51 -0700 Subject: [PATCH RFC v3 1/2] mm: Add personality flag to limit address to 47 bits MIME-Version: 1.0 Message-Id: <20240905-patches-below_hint_mmap-v3-1-3cd5564efbbb@rivosinc.com> References: <20240905-patches-below_hint_mmap-v3-0-3cd5564efbbb@rivosinc.com> In-Reply-To: <20240905-patches-below_hint_mmap-v3-0-3cd5564efbbb@rivosinc.com> To: Arnd Bergmann , Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , Guo Ren , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , 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 , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Muchun Song , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Shuah Khan , Christoph Hellwig , Michal Hocko , "Kirill A. Shutemov" , Chris Torek Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-abi-devel@lists.sourceforge.net, Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1348; i=charlie@rivosinc.com; h=from:subject:message-id; bh=B2nFsYQPUa93R6MPC6rybC4BjlmBU89eB/xyA3tmSh8=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9ot+em/OZQnfrnX8ed38Mt7a5qeTLghH2JpoLVOM/lWE E9Dee3VjlIWBjEOBlkxRRaeaw3MrXf0y46Klk2AmcPKBDKEgYtTACbS9pyRoX//nRvvVlydp7Xm 8/1ihzrxA51eb31tEvRWPpi166jgtMMM/2Pui4Sr/NDPPh503bbDcC77kZANfKUH/kz3LrfLiU2 exg4A X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspam-User: X-Stat-Signature: 8byc4x6yffx8pqansniaypkez3a7nody X-Rspamd-Queue-Id: D6E172001E X-Rspamd-Server: rspam02 X-HE-Tag: 1725570976-398181 X-HE-Meta: U2FsdGVkX182N7VGCiHAJZfdHMZIdGuwsRIJ8zF7jNcFRlasntB76Xj2kHQdeRwdOExVWj/bYfk0EeY+24f4EBUoGJdKydRxmBS8DDTD9APjEj8DT3u+avii3t3+ryYuEiaXlszyw8deehgf7pNkUX2U62Oc7x3DBzopYxD2MroabiMP2mbqmqZIJxGPSoXH6i/+e1S8IaNFIm497dVhO+HANV6eBmgknkj5zfPeup05/ni0uGUvBh2lTI+z+xXgYAIwTE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SJey//X6KdzuXqhzw0aqvfIOkh7AFMcHAvcA20dUwOjhbX7IPWDn5KLsRu1NPrNL5VsDAQt/Qmfy6tq3pN30yOcWQ3dI1u/z0RAjGy7bA7SIiM77RCgaBzXhuRmJ1Yw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000013, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Create a personality flag ADDR_LIMIT_47BIT to support applications that wish to transition from running in environments that support at most 47-bit VAs to environments that support larger VAs. This personality can be set to cause all allocations to be below the 47-bit boundary. Using MAP_FIXED with mmap() will bypass this restriction. Signed-off-by: Charlie Jenkins --- include/uapi/linux/personality.h | 1 + mm/mmap.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h index 49796b7756af..cd3b8c154d9b 100644 --- a/include/uapi/linux/personality.h +++ b/include/uapi/linux/personality.h @@ -22,6 +22,7 @@ enum { WHOLE_SECONDS = 0x2000000, STICKY_TIMEOUTS = 0x4000000, ADDR_LIMIT_3GB = 0x8000000, + ADDR_LIMIT_47BIT = 0x10000000, }; /* diff --git a/mm/mmap.c b/mm/mmap.c index d0dfc85b209b..a5c7544853e5 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1766,6 +1766,9 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) { unsigned long addr; + if (current->personality & ADDR_LIMIT_47BIT) + info->high_limit = MIN(info->high_limit, BIT(47) - 1); + if (info->flags & VM_UNMAPPED_AREA_TOPDOWN) addr = unmapped_area_topdown(info); else