From patchwork Wed Dec 15 06:45:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12677575 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 610CFC433EF for ; Wed, 15 Dec 2021 06:48:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74FF26B007D; Wed, 15 Dec 2021 01:45:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AD506B0081; Wed, 15 Dec 2021 01:45:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54CA66B0080; Wed, 15 Dec 2021 01:45:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id 468646B007D for ; Wed, 15 Dec 2021 01:45:29 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EFADB84CED for ; Wed, 15 Dec 2021 06:45:18 +0000 (UTC) X-FDA: 78919091916.29.ABD43B3 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120051.outbound.protection.outlook.com [40.107.12.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 03071180011 for ; Wed, 15 Dec 2021 06:45:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ntvEBT4LJmqHIEe7Rbt8PnQ/6fvgJCZfYOF0CyNPE8W4Fu1YzswZusQZpiyek0a0pNLw0OEHoDXC8inW0RVlsxnkWyAS0K4iN9szwsDG56Da+HviZVKAQSqSRfIjaq3rtxZjBlGhVeKeA/M2pUi3xX2lWJtMu+WjhVY6GGc3Ad3fF8wDEbw6S/Mbbdv/4oCkGyCTzcHKCvJEsKaEz34oJJIWkS2L2ZSr9w8N+EXDW03Djn42Uwg0/NhOLgdjTz/V3tfiRqIy/fZLDFhGeDhOs5ChiOJQAJ4gD2M5fPjLM4ZC5bf5O0/HfY99phE/WZjbV0L4GxZfGDDZSd+K7kJnnQ== 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=XIFEG2C9ct2Y6EzAudzpbL8L3UNIOrxCU4aYO6pfsHZgJ0PU2Cp+SVyZ8Otsx0jOZJd+kBgee1DcQHFlOmOl6RRNkvLnHBiPOjoONIhh4xJgXsxgfZ5jr1ALagT2WpRbAR9jQLLpfFrGiyvzIUTi8Kk8r+Vee5H3HB8LFC2HzXKRHVWPJcy1E+qwbCisR0p8W1krGvekIyQKIJ/tLSAMENQxGcRHupC2vh8io0xyyLUGkzrmJRRMbJjny9Z0Dgfn8IYm/5/mAzoO80QIfvTwfGhCsZHuJOw7GUe2Yy7hxXfjjC74uNQzt5edyi7c74e3Wio/ZF/K/hnyLEI9IGmhdQ== 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 MRXP264MB0311.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:22::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Wed, 15 Dec 2021 06:45:14 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::fc67:d895:7965:663f]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::fc67:d895:7965:663f%2]) with mapi id 15.20.4778.018; Wed, 15 Dec 2021 06:45:14 +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 v5 11/11] powerpc/mm: Convert to default topdown mmap layout Thread-Topic: [PATCH v5 11/11] powerpc/mm: Convert to default topdown mmap layout Thread-Index: AQHX8X9Qgu4CnQ/bmEeq6LBbICcf2g== Date: Wed, 15 Dec 2021 06:45:14 +0000 Message-ID: <5eec7cc6923729d067b8f09347862408e2ad993c.1639550392.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: 90b879a6-783c-4342-4579-08d9bf9672e7 x-ms-traffictypediagnostic: MRXP264MB0311: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: n72yKB2taiVYT+O8kPr65sbc3VTjFXVwq63ts5FZ6ITnlzwPpQ1B1a/mSUcZJLB85ac7TgfxakGGDdwawkni1ctvgig01faox35bWeybsQ5CqTc4TYpSHK2a/XACPrFJu2sZk5CykUSHcJAPcvgTfMaZyu6AY3yD4JNf8hYMx3ErjPMv2xPwlIFhysDJbVY2kjObdCB+30wvXQDEHtsCPMjvwEqTVgm/xjpZ2xLJpxpBKrRi1hMOydXUSwSoxfN7AADeAdXIFdYLfMC5t/k29AWSoAHUWi+fXmE7ShrmhObZ9Xxz1DWUSbMrH8QW1DBO9EoyhSqyHh7ZTru9pBV39wLec/aFVrbv2UDqSfm1O6KV2XlET9OImH0MRVFVgRk8wF2wpkh/jGtlvG1K4spUrg4h9/hwWU2IPxX2WoJlU9KuN3Emf9P9yP8TkSvoOo1YEF/vXqHIsaXUVK/lSIvtP63kQobgbWiPMgA8F7rrcFB2AjXtFStizBqSkSupBJgK+CGSSbG9lZXYdgmyrBjyhhALfJEr5HrycKHkgfEKcPO76WJ+D68wdjGZtH9y+7X3fMj+/R3ykZMfCgscOIXakuaFCpKImGfWKaDD1YmXSpWa21haSOMLEyX0LOgpkhDpo8H2g02VF12CRzbJ0+ZIDIYhYHHwBrBdF1rlM9D1TVvQ0KOUJSD+qM1ICYdSj3sdvE736lREGAlZERmvunaHLw== 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)(54906003)(36756003)(86362001)(6512007)(83380400001)(2616005)(26005)(76116006)(8936002)(71200400001)(66556008)(66476007)(66946007)(64756008)(66446008)(38070700005)(186003)(110136005)(122000001)(38100700002)(316002)(8676002)(6506007)(7416002)(5660300002)(91956017)(508600001)(2906002)(6486002)(4326008)(44832011);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?g4ufxBQ7oJ7emvP3hxpJ0pp?= =?iso-8859-1?q?143doKfqy7oV2PC7dYp8KJ0OJETLyygSbdQpMUI9X61+gl2AqSWOtiuhJ10l?= =?iso-8859-1?q?cBAaHG7rz+2LH9Q+1RLJ7aMKzphCrErELpf89ezrNJnbpBwn0D4XHMLrkKpK?= =?iso-8859-1?q?g8DyOFMoa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9bpo5W+j66CnYzgtgCnTb?= =?iso-8859-1?q?3b9HjiYoDbIQu4zQarlAnKNRH6WH03FUJY/wr+VGwvbujfeYvgKTTpWxM/hm?= =?iso-8859-1?q?x53BmjM1wOJ7ty52IDjFoHwd8ZUU96IxXgveXjKzali4ygjh5OySQj7TvG0+?= =?iso-8859-1?q?29DLLgf4zYsMpFUprbN0VIE8L+tKSEXsK0HLH5UyBrS2qsYSUeEwTiEsHPVW?= =?iso-8859-1?q?Vp7CzTs+JstIiEz3bR+aA2D/5Oej1pNMUTpzBRThdPlufNaz0NJFlrElkY+7?= =?iso-8859-1?q?BwRCgLPad9iSyBrIcKjGkqWR4ml/2nWDrUXpk7sg+S1Y2P5vJnO1OcjQ98tP?= =?iso-8859-1?q?76+C1OJr9l/OT+pgmwcAuX+QdGi50ub5c98Isy0DBuev3W/LPC37SRf0z880?= =?iso-8859-1?q?TlusMkEp31FV9ljLOXaRb6PFl5nTbl/eiyF5sGe1q1yieOyu6LZgris2REmq?= =?iso-8859-1?q?9IZN8lbnru8AHZdKX5ixsJxL7WYRnWXslsP0BM4jIHMVWO75uZ/BU1uPR8Fd?= =?iso-8859-1?q?+S6Fzo7wPXHrvzKYWfCmaufLyU9JOBujQSwAcOiiiRrmE56o3J4C7EUHGOPm?= =?iso-8859-1?q?3HA8O9oHOpumIQKzsWg0/xaGSJXT9QKMgR0WIgVIyX2HDAROmRxi/mJrQ2Y5?= =?iso-8859-1?q?/ZaFSqGj2Icsmj/s8AGnqzPlj9rxF4RPTRGn6c6ZhhTF9hj9kKOLjZ7zLTED?= =?iso-8859-1?q?m/5o=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: 90b879a6-783c-4342-4579-08d9bf9672e7 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Dec 2021 06:45:14.1154 (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: N08R0KTlVWtvybxRkU292ReBRz55Yiw9GPwuuWNdQPm4i9eJRIK37pIHCQHBSG2nTczlVHISAHzp+ABHOCXIvTniIYdPFHNg7YM/+UektaA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRXP264MB0311 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 03071180011 X-Stat-Signature: mrqon6r5ywe1m6zwc1te7biq8ptk611m Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.51 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-HE-Tag: 1639550715-26358 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; - } -}