From patchwork Wed Aug 28 05:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780625 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 9FC89C5474A for ; Wed, 28 Aug 2024 05:49:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32E856B009B; Wed, 28 Aug 2024 01:49:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DD956B009C; Wed, 28 Aug 2024 01:49:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 156EA6B009D; Wed, 28 Aug 2024 01:49:54 -0400 (EDT) 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 ED00A6B009B for ; Wed, 28 Aug 2024 01:49:53 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B9D8BA1D2E for ; Wed, 28 Aug 2024 05:49:53 +0000 (UTC) X-FDA: 82500577866.24.66FB0EF Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf08.hostedemail.com (Postfix) with ESMTP id B973A160007 for ; Wed, 28 Aug 2024 05:49:51 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=1VlX2SuN; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824147; a=rsa-sha256; cv=none; b=N1tctbx4x3Y74kbAu/G97ieh0LsiWDvaXs3q1lE0R4XJitobU+3GyIojpDIL2P7NzGqWx0 GPYma61W/fQfKe9C5X2aF+jGk1IfZkVRdOfSGOp2kA7gtGsXpL1DlpNEoxr8riBKBkBrd0 GRxepXgIwchXl3H3qoAKslGtyKDw7Ck= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=1VlX2SuN; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724824147; 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=01svQ9ue7Mr4CWZ3Wn0HVoOhr4xAPnLaZCO9CnTXUgc=; b=wO5Q/Qvz+yaVD2vnRy4QIZB+MEnjWzrUJgwmGPVoFVO2Epy7cDCg7BHdyTT19MQxWnQIjW WivIbepCG2YYhIjE0ysOrN15dxSiyd22zx+UVAWZovpP9CamuCNIc0uhbtIodByLOlyU4k oZh78vQvUSwwUOpTTsVW1EyFJD41AoI= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2023dd9b86aso50366465ad.1 for ; Tue, 27 Aug 2024 22:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824190; x=1725428990; 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=01svQ9ue7Mr4CWZ3Wn0HVoOhr4xAPnLaZCO9CnTXUgc=; b=1VlX2SuNInfqdTxyPZCtRFkDu6p0d96KBYKOutsuBD33teCH5gDZ4Ao63EuQbQjHeL 8rT5R//Nsxl9X31ur9Qnvq7IexBf02QzmOXkeANUyg+1o3QE2lRIgGC4y06cxrngnFDa vc7i8fAIro0B96M2M4bLCNQERkx8CuAAaZrRxhyzCBh+cf+8rS3qZYfa2vrEm3lNF81p OZZIg0gCi3GqJPGrXHb6+XtFmzNC7dtJWO+gqhnZBVToNLtssndrq8EZDBCm2TAvIijv v1w1XF6VMDHQKH2WP6Zz75fFWQc0dcjWLumuGPRZmfmKG16Ww0RV/tInwyKTYqCm1NFm ArkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824190; x=1725428990; 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=01svQ9ue7Mr4CWZ3Wn0HVoOhr4xAPnLaZCO9CnTXUgc=; b=QBOE8VrynBcHdZY7OVmJGodIQUT6pbZslb8qhwQpcmsDOnhutitCvyRRI+81aHDU2V e2Zg/eCDxuOde8eBtoStehKIaeP/pP5C4pVhZSbsSbG8oWw5tHKzw72EihQwNvep59BX xvdIY43ePbFgpR52YtyhCYN4NNCCHjY6Eb5+CZ2e84gdlGrRY2IZgOSexdmRjHaQfOKr iAoemp4tPOCMqEvUTetNYYqV+LJcme6C5YLHRytzAMU8SLzROk38UcYEaQdUVpZXOmvc xzzbyMoMEPmwVdZcZ7WEOWy/vjHpToF7kb9dt5szS59OmLQqk7rDXAuD76Aw3NSJ4Wlk HzEw== X-Forwarded-Encrypted: i=1; AJvYcCUcljKZWZtLYmkq51k5qu9cYxdtFAWROgwgbJBwtwv5pOqy6JkjHgxFys1TeGKQuaAfHlYRNNkJmg==@kvack.org X-Gm-Message-State: AOJu0YwtG/bqSpZFGLogX4ok7rSKThz8XbPw0WUeqnPOGp0ATbLN3QM6 lG/zbjUJhjl9+DPrSnCiMcA5Fef5jm9kWF6JBFBjSGRDiEGwiAzr6uKi0nZ7Drc= X-Google-Smtp-Source: AGHT+IFEjwUM/ElshIB7y6tneVtatsCyua8fDLSA2/rXWwDoWBaTV3bT3kKjnxkFupcj6i3KTQazzg== X-Received: by 2002:a17:903:41c6:b0:1fa:449:1dd6 with SMTP id d9443c01a7336-2039e510e6emr137316635ad.48.1724824190164; Tue, 27 Aug 2024 22:49:50 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:49 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:13 -0700 Subject: [PATCH 07/16] powerpc: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-7-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=2284; i=charlie@rivosinc.com; h=from:subject:message-id; bh=efrv8gA6WD0kUzxMoz7FX/k/QnHAbRwwUgR0y2hEUd8=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XfETrh9IO7T/uFjUxMhNQooG1iuWi1pdtJg6YcLD7 VUZ209HdpSyMIhxMMiKKbLwXGtgbr2jX3ZUtGwCzBxWJpAhDFycAjARbV+GvyIzjrH36plzvXDr 3H/Wo2jj7SdL50ufO/vC42XF9noOjvuMDF8DvSaxHlpya2VRHMuNXyrdOxW6nj44wHJxyn8TwWv XdrEDAA== X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Stat-Signature: 1ogacjzsgoqk1skequc5ptnqdt44ft9b X-Rspamd-Queue-Id: B973A160007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724824191-720981 X-HE-Meta: U2FsdGVkX18HbnLlLA8jnXDMjnKXm/q+/220Xnm6DuieTKZktZ72jE0GTwHHOlwcLfp10tijv0Lr/gB9cpVs32KIbrECb2H4+cs9bYpJjJxX6e3G0vKEqNOUEOebtMMRZbVFDcYTyb71eg1pnLS0ZvXVVQokk3LfP7p0y+/E+BLomyOlLjUUrwqkvIcKIPSWUzWxHMk4kZFmy4bA23J2nR8jI1wHWEz8JK4feDCRVG0sOow6r8GuEssGphSS8GZUlLO3ubK1nJB/JQIWoMCmsar63Lr8kgNCTiWNojpYQXWWnLZ9XO+7cxtyo3Mb5+7XPRJAMaWAVOxTjsLC5cySCq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ozm4uxsVBLctphwkycL/EWA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000031, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add support for MAP_BELOW_HINT to arch_get_mmap_base() and arch_get_mmap_end(). Signed-off-by: Charlie Jenkins --- arch/powerpc/include/asm/task_size_64.h | 36 +++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/task_size_64.h b/arch/powerpc/include/asm/task_size_64.h index 239b363841aa..a37a5a81365d 100644 --- a/arch/powerpc/include/asm/task_size_64.h +++ b/arch/powerpc/include/asm/task_size_64.h @@ -72,12 +72,36 @@ #define STACK_TOP_MAX TASK_SIZE_USER64 #define STACK_TOP (is_32bit_task() ? STACK_TOP_USER32 : STACK_TOP_USER64) -#define arch_get_mmap_base(addr, len, base, flags) \ - (((addr) > DEFAULT_MAP_WINDOW) ? (base) + TASK_SIZE - DEFAULT_MAP_WINDOW : (base)) +#define arch_get_mmap_base(addr, len, base, flags) \ +({ \ + unsigned long mmap_base; \ + typeof(flags) _flags = (flags); \ + typeof(addr) _addr = (addr); \ + typeof(base) _base = (base); \ + typeof(len) _len = (len); \ + unsigned long rnd_gap = DEFAULT_MAP_WINDOW - (_base); \ + if (_flags & MAP_BELOW_HINT && _addr != 0 && ((_addr + _len) > BIT(VA_BITS - 1)))\ + mmap_base = (_addr + _len) - rnd_gap; \ + else \ + mmap_end = ((_addr > DEFAULT_MAP_WINDOW) ? \ + _base + TASK_SIZE - DEFAULT_MAP_WINDOW : \ + _base); \ + mmap_end; \ +}) -#define arch_get_mmap_end(addr, len, flags) \ - (((addr) > DEFAULT_MAP_WINDOW) || \ - (((flags) & MAP_FIXED) && ((addr) + (len) > DEFAULT_MAP_WINDOW)) ? TASK_SIZE : \ - DEFAULT_MAP_WINDOW) +#define arch_get_mmap_end(addr, len, flags) \ +({ \ + unsigned long mmap_end; \ + typeof(flags) _flags = (flags); \ + typeof(addr) _addr = (addr); \ + typeof(len) _len = (len); \ + if (_flags & MAP_BELOW_HINT && _addr != 0 && ((_addr + _len) > BIT(VA_BITS - 1))) \ + mmap_end = (_addr + _len); \ + else \ + mmap_end = (((_addr) > DEFAULT_MAP_WINDOW) || \ + (((_flags) & MAP_FIXED) && ((_addr) + (_len) > DEFAULT_MAP_WINDOW))\ + ? TASK_SIZE : DEFAULT_MAP_WINDOW) \ + mmap_end; \ +}) #endif /* _ASM_POWERPC_TASK_SIZE_64_H */