From patchwork Fri Dec 17 10:28:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12684225 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 58248C433F5 for ; Fri, 17 Dec 2021 10:34:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D1BD6B0087; Fri, 17 Dec 2021 05:28:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2589B6B0088; Fri, 17 Dec 2021 05:28:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AB176B0089; Fri, 17 Dec 2021 05:28:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id EC3EA6B0087 for ; Fri, 17 Dec 2021 05:28:29 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B21D1180C8534 for ; Fri, 17 Dec 2021 10:28:19 +0000 (UTC) X-FDA: 78926911518.29.FAB26A4 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120057.outbound.protection.outlook.com [40.107.12.57]) by imf22.hostedemail.com (Postfix) with ESMTP id CEC15C0015 for ; Fri, 17 Dec 2021 10:28:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SOG7YtgbSZ2v8UaZvjWHppF9mnIrT1bMtE6fcCIUjeSANQmP2lVMhKwB5CiB+PbMSKrHWMlBdf40vN49BqeGUrWxg8KDFdjhQVL1EkcJH5H8VcPUcWqB0Yl1YoQT9I8JvqXVB9EEGyqplccpbzRCnuvZRtJcUMHQu0oKw0D4jU4w98S8H8V3+0jQA8eAcCmZfttTA2zbIEWeYoL8p9/4PVjVik+4X7uSq8yAOLNKuIgR23kHqprbI3eIKRayuMm0crveL6KYJps9F+H2ezKSIISh0XHjO2xk8mvUTgiAQNDfSJ60XzOk0aHx79rZKq9y575B064HltYEbguTZ6r0XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gGFW1HR24WYAEOnV8dd+oFOXUWflLAKM+E2nFCnaGvg=; b=Sb1Arxv8Qx9q4XZj0L/5VvAfQmG3NPdfDrUwgiYeDW7+0OPHp3niYQs51FEvoHlujrFXuhQ8KWa0r4LQE7nD+aigInnG1eZSBAz42uhsTob40Bdxny8M4sz0C6i2QqqHqkp6qzRfsHb3Ir4S3KdZXsTwcCF+mXifkK6WSU2wUrgam8kN2pChxujAgU+6ZiTf10Dn5Bq/nFCk8MA0+wG1y+oS/ESfWQWDL1IoaksHx8dFZTkWb7A0Zp1CW2Qv4rFVPuTk/4rGN6y9tX2UAqCGjaPv5CnluS399xCj8gK2PF4OEtLxQSFRYDHy0rquyyxpzC1Vkdxfw3NEptX35eHM4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=csgroup.eu; dmarc=pass action=none header.from=csgroup.eu; dkim=pass header.d=csgroup.eu; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by MR2P264MB0146.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Fri, 17 Dec 2021 10:28:17 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::f0ef:856d:b0de:e85d]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::f0ef:856d:b0de:e85d%5]) with mapi id 15.20.4801.016; Fri, 17 Dec 2021 10:28:17 +0000 From: Christophe Leroy To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "alex@ghiti.fr" CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "catalin.marinas@arm.com" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: [PATCH v6 13/14] powerpc/mm: Convert to default topdown mmap layout Thread-Topic: [PATCH v6 13/14] powerpc/mm: Convert to default topdown mmap layout Thread-Index: AQHX8zDOu32cl/lvLE6oPm2rWLszog== Date: Fri, 17 Dec 2021 10:28:17 +0000 Message-ID: <47ca2616c0fad6e9fa5c6598cde7a43e68a0e5f4.1639736449.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 67d92153-a182-47a7-ff6a-08d9c147f0db x-ms-traffictypediagnostic: MR2P264MB0146:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:311; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gzVloqdRBp6C3mk88ncgXdgpm67knpSS+k8+RE6QSwGj+MpqH/mnyPiZ0zSqqCfSOhMag90M0P83qqe1Z7hshrx4xf+RCrZK8NB1S1K5v7lhf7JAGmULntRN/VHimvRlsoI0OwjGhxnQoMkN37DSXZTJ99qiJwZOTC4zN9GhYHbpvkXDEGOPUfXp/tJzw1iH3EOn3GUkzIahZw1bFVxyP5RbgLj6RMa8JU3kYYftL0BSx9oq08TO6jIFRdLi5eC1iSc0tujPM7F1f9r95rBkEMj6YKrtK0w489wfDU8OlvvGaMvyvNodikU1qpW2K5TSuwV8luvPABMO1DQiGlonXkP3s04RM0nOtuxCwQTlX1RqDDeZupImjd5NbjbwolJae+zR6Sopn3J36FO/KJZJyuR0/aOTMQa40GV7pMAtwHbjPjWDYyHP6mFRlOrOx3W5XIu/YBTXDwHVy2C5anuQ41kwvj+U0kqbQTy1wCPyTN5D4/+KShUdRZhU00iB5hfe1W81aOYyGv9OUn7o/GCSV+prQ3P810lRXqJiP6LYKiMv1S6IZhrm9VAQ45+vLJveygftRh+KlZHFvJ+ZNDXqG6c6SITyy5sBa8ZVtJM3iOgHrl7/WvnQsNQ7z2alkTVmpTHxC+goLT4flSz61Lbr+d9eDKHxMFkkuMXmi/Q3PXi0p9GNIVmQRuZ6ca0t+qc51HpBOnrNqS1duJS1T9RX5A== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(186003)(91956017)(71200400001)(86362001)(83380400001)(66476007)(66556008)(66446008)(2906002)(64756008)(38070700005)(7416002)(44832011)(6506007)(76116006)(4326008)(36756003)(26005)(2616005)(5660300002)(122000001)(8936002)(38100700002)(508600001)(6486002)(54906003)(110136005)(66946007)(8676002)(316002)(6512007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?8+xiEO3joalqo24FxfAElc4?= =?iso-8859-1?q?RIpC3DV57PjamO0wcjutZhTuPEU7WmT9iXA70Ry7tYUCDB4Zb9ZHecLM1SI4?= =?iso-8859-1?q?N/7/SfPG3nwLLmr9XRQN/KLuss2CdrdQhESH5asWq7WfTv+67yl+5NPkah7X?= =?iso-8859-1?q?ObcVpDq0B/tCUdOk32s3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49uUTzoGV5ioiL?= =?iso-8859-1?q?VNNNdMAzzvmPvJ6AU7E9w7c05YHluXcc+4AG7uNS0neMIylE4h97kNq+4wgl?= =?iso-8859-1?q?/LCYjNVvg11BwdtQMMfObOOk6fY59frn1c+DC3piOkbaH4PjSUkD9E5BqH6Z?= =?iso-8859-1?q?AwGQfhdJM6RMvoAywR+Uv6He8BzK0HAH4VpfJvZWL6j9ZGrW5t4OuOcB9d7U?= =?iso-8859-1?q?tWdnZIVSauMAfF8YLqT1msn6byKH2LiuWNCp5MPqtSJ/nmZ6Qj+8Uyy2fzBS?= =?iso-8859-1?q?xuFlQjRXKrsiIWwd1gHcvx7jKS4RqltYabwcJeGkR29SPyLL2E4wGwnqD654?= =?iso-8859-1?q?U9VrN+p6lMCRV728PNDWpMxoxTjyrgBs7FeG5T0TV51gf6Vc8c+7mgU2CGz7?= =?iso-8859-1?q?fAfugAD5CzSc92t0g0sKoFgBZC3XUonp5ScJJswEgNv0Ijn5+Sk8oFtBnEPd?= =?iso-8859-1?q?Ll4e0MKl0Aqt+Joe7a/r1NkopyR3QeMT6T90qM5S2Kj2ZbqQWb1ZQ7fyHDHA?= =?iso-8859-1?q?X6wMQL4yjxefH1tw/QC04AeS8onhgBgyQJAdW2EB0z3ycDp/FqVxzaEcqFNp?= =?iso-8859-1?q?f9J/1FIt1Ppb5UFlN+iYoTvhtcxufhhyx/lZ0EcmRjuyZqh/o/vf56oh6OGe?= =?iso-8859-1?q?oynwWMHk38ClG/+koJWkNokOa+Dfh0B2gToUjf1UaKoIQhRf2Relj18kGwQB?= =?iso-8859-1?q?jDK0=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 67d92153-a182-47a7-ff6a-08d9c147f0db X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2021 10:28:17.6331 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dQ1xKuQXIJrH7AgOMNSv2xJ5EMHEiBaPg1eqJv7Y7t74ouYOjEVu0c7As12j2TBzLL77kP5viW6Y0la09gX4if2c8Sjfk9jeq8SeQhMtX+Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR2P264MB0146 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CEC15C0015 X-Stat-Signature: sztxst797erng8tahs485soc4617ri8x Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.57 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-HE-Tag: 1639736898-176859 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Select CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT and remove arch/powerpc/mm/mmap.c This change reuses the generic framework added by commit 67f3977f805b ("arm64, mm: move generic mmap layout functions to mm") without any functional change. Comparison between powerpc implementation and the generic one: - mmap_is_legacy() is identical. - arch_mmap_rnd() does exactly the same allthough it's written slightly differently. - MIN_GAP and MAX_GAP are identical. - mmap_base() does the same but uses STACK_RND_MASK which provides the same values as stack_maxrandom_size(). - arch_pick_mmap_layout() is identical. Signed-off-by: Christophe Leroy --- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/processor.h | 2 - arch/powerpc/mm/Makefile | 2 +- arch/powerpc/mm/mmap.c | 105 --------------------------- 4 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 arch/powerpc/mm/mmap.c diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0631c9241af3..b4ae3d8bde46 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -122,7 +122,6 @@ config PPC select ARCH_HAS_DEBUG_WX if STRICT_KERNEL_RWX select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_DMA_MAP_DIRECT if PPC_PSERIES - select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_HUGEPD if HUGETLB_PAGE @@ -158,6 +157,7 @@ config PPC select ARCH_USE_MEMTEST select ARCH_USE_QUEUED_RWLOCKS if PPC_QUEUED_SPINLOCKS select ARCH_USE_QUEUED_SPINLOCKS if PPC_QUEUED_SPINLOCKS + select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT select ARCH_WANT_IPC_PARSE_VERSION select ARCH_WANT_IRQS_OFF_ACTIVATE_MM select ARCH_WANT_LD_ORPHAN_WARN diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index 2c8686d9e964..873adaab20c8 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -392,8 +392,6 @@ static inline void prefetchw(const void *x) #define spin_lock_prefetch(x) prefetchw(x) -#define HAVE_ARCH_PICK_MMAP_LAYOUT - /* asm stubs */ extern unsigned long isa300_idle_stop_noloss(unsigned long psscr_val); extern unsigned long isa300_idle_stop_mayloss(unsigned long psscr_val); diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index d4c20484dad9..503a6e249940 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile @@ -5,7 +5,7 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC) -obj-y := fault.o mem.o pgtable.o mmap.o maccess.o pageattr.o \ +obj-y := fault.o mem.o pgtable.o maccess.o pageattr.o \ init_$(BITS).o pgtable_$(BITS).o \ pgtable-frag.o ioremap.o ioremap_$(BITS).o \ init-common.o mmu_context.o drmem.o \ diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c deleted file mode 100644 index d9eae456558a..000000000000 --- a/arch/powerpc/mm/mmap.c +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * flexible mmap layout support - * - * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * Started by Ingo Molnar - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Top of mmap area (just below the process stack). - * - * Leave at least a ~128 MB hole. - */ -#define MIN_GAP (128*1024*1024) -#define MAX_GAP (TASK_SIZE/6*5) - -static inline int mmap_is_legacy(struct rlimit *rlim_stack) -{ - if (current->personality & ADDR_COMPAT_LAYOUT) - return 1; - - if (rlim_stack->rlim_cur == RLIM_INFINITY) - return 1; - - return sysctl_legacy_va_layout; -} - -unsigned long arch_mmap_rnd(void) -{ - unsigned long shift, rnd; - - shift = mmap_rnd_bits; -#ifdef CONFIG_COMPAT - if (is_32bit_task()) - shift = mmap_rnd_compat_bits; -#endif - rnd = get_random_long() % (1ul << shift); - - return rnd << PAGE_SHIFT; -} - -static inline unsigned long stack_maxrandom_size(void) -{ - if (!(current->flags & PF_RANDOMIZE)) - return 0; - - /* 8MB for 32bit, 1GB for 64bit */ - if (is_32bit_task()) - return (1<<23); - else - return (1<<30); -} - -static inline unsigned long mmap_base(unsigned long rnd, - struct rlimit *rlim_stack) -{ - unsigned long gap = rlim_stack->rlim_cur; - unsigned long pad = stack_maxrandom_size() + stack_guard_gap; - - /* Values close to RLIM_INFINITY can overflow. */ - if (gap + pad > gap) - gap += pad; - - if (gap < MIN_GAP) - gap = MIN_GAP; - else if (gap > MAX_GAP) - gap = MAX_GAP; - - return PAGE_ALIGN(DEFAULT_MAP_WINDOW - gap - rnd); -} - -/* - * This function, called very early during the creation of a new - * process VM image, sets up which VM layout function to use: - */ -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) -{ - unsigned long random_factor = 0UL; - - if (current->flags & PF_RANDOMIZE) - random_factor = arch_mmap_rnd(); - - /* - * Fall back to the standard layout if the personality - * bit is set, or if the expected stack growth is unlimited: - */ - if (mmap_is_legacy(rlim_stack)) { - mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; - mm->get_unmapped_area = arch_get_unmapped_area; - } else { - mm->mmap_base = mmap_base(random_factor, rlim_stack); - mm->get_unmapped_area = arch_get_unmapped_area_topdown; - } -}