From patchwork Fri Jan 21 08:42:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719498 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 939F4C433FE for ; Fri, 21 Jan 2022 08:42:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30F9F6B0083; Fri, 21 Jan 2022 03:42:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BE5B6B0085; Fri, 21 Jan 2022 03:42:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15EAC6B0087; Fri, 21 Jan 2022 03:42:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id 072036B0083 for ; Fri, 21 Jan 2022 03:42:11 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B52E09369B for ; Fri, 21 Jan 2022 08:42:10 +0000 (UTC) X-FDA: 79053652020.20.CD463CD Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90089.outbound.protection.outlook.com [40.107.9.89]) by imf20.hostedemail.com (Postfix) with ESMTP id 2D8FC1C0008 for ; Fri, 21 Jan 2022 08:42:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hniHVEgINr/dW7UjgJNkJJ36yMXO8qMzy9HOJgUgDZixXwxn57ZVPb2SUs5kOjVYKbyXohKRZcjXxCNf6LGYraj8XUyKL9yLI3DpwQxLUTrq+Q+UYse3HWuYYE27yO9YMmhi/FvZaqW9xBrUKPqVJEbZ1wjczOLXNZ8jrRJG00OO8e7tPNE+HA9wUZSyeoV/INjuV+zxqsMbn2gsrZngu3eENNo3JQKukzWty2FdC8Q+Dp5WPYNEH0kTSjTZd4/MY9c44HEtW8g/g9kDWSecq2LutaujThy5LG4ueCWxnnx+Q77wmM6Mv66iPpjjhh8TfUcq3qkl8lonT6/vGRZZZw== 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=CecWjS/2UZ0IgcjyZ1BNFW6PGMsjPsk8NnvtJJ1/fvs=; b=G/Y51wIGbclaP6EFQD85MsAXiDiiOmaoaH/LRyBDcbqaIqHKmU61dHCBrada/z5IenThPqoQpbwxCGAgP1bXc1rjWssoMOqgMipYUHBJom/BHGaO4/ST630r5v1bmX/OyXXccm1To0Hcyhq+gbb81jJJCQIlzQrfH2xGN5vegfJNHFyU8AWS9ZqeZ+SKpHChmLddEHaOCeea2pmNidHfdCZmTdx1le/NK45OC2JLbaC5qUKolNFqgkoOZKvYTrrt46C94m+tVp61o8F+0ok14MXx5l02XqoGWaEQ02ZkisYy4rSyhp4+QtnbzCjgCIgFMpAv+Yx9euc4OS1HDq9F6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR1P264MB2206.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:192::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Fri, 21 Jan 2022 08:42:08 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:08 +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 v7 01/14] mm: Allow arch specific arch_randomize_brk() with CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT Thread-Topic: [PATCH v7 01/14] mm: Allow arch specific arch_randomize_brk() with CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT Thread-Index: AQHYDqLG97pmfW9CEEqBlISb/pIgvQ== Date: Fri, 21 Jan 2022 08:42:08 +0000 Message-ID: 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: 36ccaa1b-d141-4529-0f6c-08d9dcb9e8b7 x-ms-traffictypediagnostic: PR1P264MB2206:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2657; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mVhkSBl0XA/B0xhE4yNVc9wUgk2YaVU6HWqVItwUGjYilElnx55oovsmLEQ6LlBHGjyedubp2uOnov+hUMmD5sVUIADkz5VE22MLu5U0wi/4o8Sl2e0vW3iSuN4yic4Us1R3cy0M66B3Np/mqSEiPT31oDD/aC4VXwEgeTNMHZ54kAj7k2EOZ7c/te8JUOoQcThhrwb7Xj+f1LjcLbPxzY+y95fc+xOc8giy4/F3FUr/qI1Biy2EC7pXjxuLKHaGH+M5/iKrITSZb4t86TjWgbjMtGa6hasOdAAFQI2eupcbMiYhcRTWIgXVn7cdmH4xjAgrgSBhDL5nIhkUnHrtqmeNFmhsC2sEIK2hkQwNu8yJbV4iYpm0xzg2oqT2I6R0Hwy6krMkU/IXEYEIBr1G/YWLeoFkB9mCjY/PN4fg5Tetwswxrox8iqdUOjI1uzvj/Np30BvMR4+46HkDEzbFLFkG0P7T3kdCoro00rzwxDos5aCftyNc2diEk3+wRo57NGfOVC+1bc46Ko6vteGWdNmDWCf1Y2VkBhirSBd/O5mstiZ/ymsuXo4a+dMvyhwCmb5IJngCiD/McHDtiBjtoU6l81iqMYeNu1aqosYCVWWcZuOoHNiPX/Uz+jWPzYT6gZyV3/KH2Kz5fSZvwyvNCGJKH16SO1uPZm78OWFor9ulveQqUPDTy3obMEe+BA9euuLZkglkCovJAni6vwh/wQ== 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)(71200400001)(316002)(54906003)(38070700005)(2906002)(6512007)(8936002)(6486002)(86362001)(4744005)(186003)(2616005)(83380400001)(7416002)(110136005)(26005)(66476007)(66556008)(64756008)(91956017)(36756003)(66946007)(44832011)(76116006)(66446008)(38100700002)(508600001)(5660300002)(8676002)(4326008)(122000001)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?UJdXKOA9IhibxVi/SCjqTte?= =?iso-8859-1?q?GpdMoH+ru1bnugusxKD4Fs75sphrH0/CW/8EdfgKaW+6DBIYLsrt7OiWKsPV?= =?iso-8859-1?q?OLtNhGOlsS/4lkYPPFOTwrrmjcy3K62gPWkW14jOl8cKpaZUOz7Fwdy+JTZ6?= =?iso-8859-1?q?Oh7rO9zP1thuOvogWouptZLu9rjSGQ+rhHGs3iDHLe8nKlux8GncTW/kjb0I?= =?iso-8859-1?q?rnrpYC+q3pXii3RK/FeJZJSMJQ/x5Khf8qYX3Q/+DdRltrfIw+4QkblhS8RM?= =?iso-8859-1?q?OxeHXqqZ+afAowQA4m+ci8DBzWyPGj6zMMddVUJSHk7er3LaBMwXB1syE41+?= =?iso-8859-1?q?G7FqhfbvRAn24556htWU2uvfggnJ13hjocvr6kx3MiQdM/uibjTd3ol/163H?= =?iso-8859-1?q?Ol7jyp1xaETogsG2wk/V/BJVO9N3Xfl6y17zqvljq0m8NfYKc9mLQaWW25Ji?= =?iso-8859-1?q?IOhjge4iKjrYO6uUwnlovWVfpVqTY5+jgUJdtOITY6Qv4RpaHYDoReyrL93k?= =?iso-8859-1?q?oK4FlJtKqtQo928TzuPEwkg5jmSHrkEEjSZC42kqAX6tfnTcBMU9tr9jZPGO?= =?iso-8859-1?q?f0/1wR1cjflD6qu1M5G2CPA2rKwpKb2FNh991B5rwt23i76+QEzMwSwHUJ8t?= =?iso-8859-1?q?asWtHqVXwGyT3sxpKuah7x+ekbot8F8wApQoWc9vZjoaKP2PGng9qyOHGvUY?= =?iso-8859-1?q?3I9R2b9kKt4xx1RVBT0vbLiG47yLjTisWlnj2FDXOvQW2D3Vvep2f6kxv9JB?= =?iso-8859-1?q?nK48x9G76LBR0lMVqd435awel/nLsHbFxx+2yNtFPV+JrDfuuTbaHm972xHI?= =?iso-8859-1?q?DHZKRRIx5Dp3ekVPLGfspAGrPkQfcADlqnRPb3TEALoQSrL9zHfiPdIgpyXS?= =?iso-8859-1?q?wclYlEWPAmulujGfYs4pZeqCjkClpf4hk6pye9KCh08THeyq8kuCvQPEiiUG?= =?iso-8859-1?q?xjc+hWecoksmHC1dpv+tkR5hQSTWcE3s323ezEUWmZDJkmpVlLF5DvrewQjZ?= =?iso-8859-1?q?v7uPknq0Lz7YbveKaq1UKGoQ3Vpa1TgiTP+6KYIpZLovz9N2J0eIPe1sTkIh?= =?iso-8859-1?q?GTEUGlauQyBCcBTa2UUQyBPu0RneRZ5hPeeFCON2iFmoawFGt6WckqC3H1wP?= =?iso-8859-1?q?xMGGk9CHJuqIT/iQGaUaSik6x7ikMT7gO7ZuBewpcInnhqu/TItcKYW5dEEZ?= =?iso-8859-1?q?JfZgAL4I1UO+YZwsK2jvw+O1Qj6BbfFbQSQl14KEoLi3fP/zCBynr0FLhMbv?= =?iso-8859-1?q?ot2gIu6CWXHK9HTU+fPmp4w4YHK9louDl2j2ik7VtcP9c1k5jM8dP3EQ5ky6?= =?iso-8859-1?q?J/1DfSnQgdMwi6iYkaQa3sTNS40IFNIRxBTpbX2gNVne1yGF1GcGoWIIeGyd?= =?iso-8859-1?q?PtqMmq8HSbJcA0rBTXaLqryWfHeORpoRma68z4rfsYtMz1yfMJUJn2TdGc2K?= =?iso-8859-1?q?bwdHiqHJutjYinByOC95v/VbVg6N7OWxcExmmnuAydaXzg/s2bbexgkuWK30?= =?iso-8859-1?q?RmSeNF4OqT0zTjI1nbIYXS2UuRDaAtuDAUzOxyyUwEIq4fOkU/hRft25qnGy?= =?iso-8859-1?q?FcX7RPnWS5qx4FrUl9OqhWQ9f1BdAUkhhYxX+t1YLb0z8HNqbK8UoSc8PtNV?= =?iso-8859-1?q?PhXj9Cv2HfmmpGqoe+KeyY7TxMy+eent6KF7c+ztetIMZOkFukyTfi6+LPt5?= =?iso-8859-1?q?Z/AFL24TseyYY0uB++E+kWjXY/z/WNEQslQBMDWPQQ0bR8fVgJmGhTMGELCn?= =?iso-8859-1?q?6JkE=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: 36ccaa1b-d141-4529-0f6c-08d9dcb9e8b7 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:08.0695 (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: Yk8XOQq/H64TBm8jZ6Q1AWWvvBiwercDMiHAfyHsoKRuONmEvtoKe86ywh85aBq6BCM7WxnPbYqmVI3IBB8mAPnq4Ce7cBcXUFlZCtvxBis= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR1P264MB2206 X-Rspamd-Queue-Id: 2D8FC1C0008 X-Stat-Signature: 5rambxxamizxqyru7c4mpjgdy9t36tbs Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.89 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Rspamd-Server: rspam03 X-HE-Tag: 1642754530-611677 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: Commit e7142bf5d231 ("arm64, mm: make randomization selected by generic topdown mmap layout") introduced a default version of arch_randomize_brk() provided when CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT is selected. powerpc could select CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT but needs to provide its own arch_randomize_brk(). In order to allow that, define generic version of arch_randomize_brk() as a __weak symbol. Cc: Alexandre Ghiti Signed-off-by: Christophe Leroy --- mm/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/util.c b/mm/util.c index 741ba32a43ac..46d1a2dd7a32 100644 --- a/mm/util.c +++ b/mm/util.c @@ -344,7 +344,7 @@ unsigned long randomize_stack_top(unsigned long stack_top) } #ifdef CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT -unsigned long arch_randomize_brk(struct mm_struct *mm) +unsigned long __weak arch_randomize_brk(struct mm_struct *mm) { /* Is the current task 32bit ? */ if (!IS_ENABLED(CONFIG_64BIT) || is_compat_task()) From patchwork Fri Jan 21 08:42:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719499 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 18A36C433F5 for ; Fri, 21 Jan 2022 08:42:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C8996B0085; Fri, 21 Jan 2022 03:42:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 778A76B0087; Fri, 21 Jan 2022 03:42:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 619AE6B0088; Fri, 21 Jan 2022 03:42:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id 5396F6B0085 for ; Fri, 21 Jan 2022 03:42:19 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 112258249980 for ; Fri, 21 Jan 2022 08:42:19 +0000 (UTC) X-FDA: 79053652398.14.5D13734 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120089.outbound.protection.outlook.com [40.107.12.89]) by imf05.hostedemail.com (Postfix) with ESMTP id 3599010000A for ; Fri, 21 Jan 2022 08:42:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K1vS1iAAsesO8whdpnWr+llG5zc1fx76E1TN3tJtqJK+fMpX9dh7D0IQTlkmYIUO9ql3CHB+1GtGx8bYGUqjU57MbJ+lRqPu+KNmxrdJq4osXB+iNkwk3rIk5+P9uPh+7aOqul9my2K1nKN2J7jkqj+TzvOvRMbkUrmlEsstB0nklKxQgTDuCTzIbmTrfrO8NBSgH0VPxsIcZQFXv2TldJnC2LTrQ2bojKCniK7grX7SE/DeOA5IGzhJ8u2OCgfPlrWzd6INXW3r9/6qoAldlTt1VgOnK4EOCmHVds1bMU2qRz15Pf0Qcf6IbByDbH1WjrY107k2qi/hV1tHhVELQw== 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=qiY1jWq5N+mnYEomtogvvA2McR4bD1uoV3qJr5FQods=; b=GcymXMlDT2qxp1Ob4jLzSTazGw1md/xULL/2iHk2+PRUoJwp19NNHzvVwSxQ280QO5iDjdMMdho9OY71J9vNWZZuXrVc4kEkuzl21i7WRfdWs9cK/sSz43Pm3enVEbt2YDGHIH91FUR/Tl4WnfqIjKdGC+6Xvy+qGZEiYQN3fgbpT1Lr8xHq4bkyGzqqDIQ37yOgvA3EC7T/l9ci0nYXME4GTbnpn8A9EbzE6+TDN1gQg2kTZQ/UgfvhXdBhCZLjTAoJ9T1+pG0PsNjbEMEwuT2ROCz634hsP+OeGtrTM4bPx1/IR+mdSHhHzzbvPSCjJw8KPx9rxTsyaX4dSjGTRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:15 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:15 +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" , Steve Capper Subject: [PATCH v7 03/14] mm: Add len and flags parameters to arch_get_mmap_end() Thread-Topic: [PATCH v7 03/14] mm: Add len and flags parameters to arch_get_mmap_end() Thread-Index: AQHYDqLK5heG4KdaLUGB33l4dVbmMA== Date: Fri, 21 Jan 2022 08:42:15 +0000 Message-ID: <0c8611ef3bcd758c4ff281b92015f447ab7f9b19.1642752946.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: aff836e6-38c1-4786-5340-08d9dcb9ed5f x-ms-traffictypediagnostic: PR0P264MB0201:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3173; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NayZfWn4N+X3Jc6lG+r+A2cS9vVPR7GFXSRlIRtnFG7AtD8iZ/Ung//abiRrlBGUTIc/QcKwX04QXPevJ3LHAFNxCOUYCehLlFTyaGMl8Iv8sKH8ixnz0t7mUMPlNbVATMAUbAop7ISeVecEFLfW6vUPrCtMZOAZImJGORL5hp/gLLeLW3P9CQXGIDHFM7pkl6FiL/P2sVBUXl6rpylryPKDKtPYhBi0Crs6E+LK8kA7AxS987R8qV2cR6FNwNm0ytCU3CR9mwibcOj2MhCUYflHnxKiFo5+/rg8bDW3WWZvYs7lOqllcL0JiKaKa3Ux8k0UbKl9l+EMYUUFdj+8DY+0bd3xeTChZFAZM5diCfgMwKXWNPP4UmV7Bq3nDrT7fV2jauoMskqRb9fjUpceIVtBqR7Pqogxx7YRtp/7ydPGTRO+BIQMZZj8z1L8D7F705ArGjtdtt8cvym0puT2ZqfOVw0BaIizQxi2o5/hzslzzY78X0A2v4JgvLu5YmdjXHs/xF1sc02WBerGUZzbuwkyAkO/nE3FdJ+IWWRx/XswyI/u0xmnRsfu0hioB0b5hQibeYJoGKJaOvF6t6q1vOUzbbStZOZ3uOGT21I8UABQwK0cYlExgXd2DllQbWtlP7kQUDIlyHUKYLvzceGIj4OIPg8OhwNY3L/seXEQqJf1J6bpsq53NUNLgSfVqlmzFHQZN17Nm96g5WJ0QLhzvw== 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?eY+tubdID9Xcakpow3klka+?= =?iso-8859-1?q?E1X4Mg0zUG6cJHGUOniWEbAWTYge4xJVkpNV5cGHJpnA0TseSgm62MMRYo3h?= =?iso-8859-1?q?OIAP7uGCft4Y8ic27ll3HKAewSiM1c/Num5fa9usvW+DIZIExrq0kiIv641T?= =?iso-8859-1?q?xkFdeT/uyjnH8NrvI3Ja8T+V/PcZndl16sUOwdz9KYopR+MVleo+hXQ3sar6?= =?iso-8859-1?q?vhCULns+ipaIsWBnZ8cmWn9hmrg6tmIvqDGk0EAtkilCtAuZfYR8+8jpf88i?= =?iso-8859-1?q?usuHvRLMioZxTqa0zBQi5Ym+Mat2FnDSEKuPM9zOqVBL2Sk7LmK1mTthfu5T?= =?iso-8859-1?q?ltR2OQjPmDQ60vfUehPZOvw4TZcJaPJczmV1uX4gyBwqr+Z4bxM4xV47VnY+?= =?iso-8859-1?q?jLDxNJuJ3hFcGbSQRh5VqIL4ViPZJaQOsXBaNSvs1OJo4dqqt4rG1kiGRcxU?= =?iso-8859-1?q?8IK2QiaMXMfSzRYXcc5IgL0Q4kr/S+hHnGB2FPTL+l4Rmt4kz/P1nPMM+DRi?= =?iso-8859-1?q?1YN1CkEPERNOzhXA82TK8aU4eHUGjrc1Z0D8s/LqSEW8i+6Wd89hohq9UeMq?= =?iso-8859-1?q?7bXffvyqs7VJkfQH4AAVXMye+RG6O9qmL3E6vhQ/Pyvmj6haSpEGXaIiO51G?= =?iso-8859-1?q?DjOAfSFW5ZxwT0uHXQ6KDzSWeI8sOmoewdt/yy9nxDk0AHgXWjSmg01EFAPw?= =?iso-8859-1?q?kH1eOIixBPZ+JYQ0iahx34xmefvrhpnAXl4cP0LEoZEZjApXbDZ7nZ59P/q6?= =?iso-8859-1?q?gJ4wdTim/gIDfH/mNMLOvurOLloTBK8sg//TmJ84X4BYHXKxXV+1eaeSRZ5+?= =?iso-8859-1?q?M8ySura3Nio11jkwpiIUfNDShE6gNn6aYska2Q4qp3JE30wdaUwBEy2+0GvJ?= =?iso-8859-1?q?LcEccyeCRtL0I58D13vrtPjMU8gqw19awGP6JrO/aeKfSgtjFjYtxZpnxOKP?= =?iso-8859-1?q?Bp9M3Yu3GewEbiiBak2ILfajRLgu3F84r88KIUyWz/FPN5SZ5yUBJIyDYtGI?= =?iso-8859-1?q?GdEyl8FygWCAd6FNLITPiTLE5B30TnFd08r5UXAr57LyeMgZmYEGB4DoDEba?= =?iso-8859-1?q?c5jTAXT7Ler4wONfzlS2p+COnoWKncf8diahsP0e7bVyNDumSjLJKaZZIwaF?= =?iso-8859-1?q?/7uZRVrrBQwAtXqOLknzrVl8/1fi2jQVBTJAerimoEtAdOMycC9rxLtFfD9k?= =?iso-8859-1?q?zHKpYy9lUCUNPMQnLsDDEzfiZ6CgyBQ5v13Vf6beLMBjBCnLI6fM4ZH1fyD6?= =?iso-8859-1?q?bWsZJ7W/zC/Dkm5Xzzecs0ClL/B2KRjCUcWaqipJ89QJ5jyDla3WAZDUu43W?= =?iso-8859-1?q?mfrV6MNizAUkmhKt//GhQt6DjtoguJT4jPzeNso+BFj8/uS6E+WNQ9BQar0B?= =?iso-8859-1?q?GziUcR1Z7EC36Uky0c+jE6UCX/KdVt5ptgttqZZF2u0Cii0m8ObMTKbT4hsH?= =?iso-8859-1?q?XZ2NrDMLqBSfAUvvhSprefB4xu3z8WDRzfOT1wg+D+yZwhpcAN+91xU8g+fl?= =?iso-8859-1?q?cyuq+IpIZ7FFb6Oawz0iyMniE6Fi9mrrs6kXsKkxgOgC20J419lR80+hkQVU?= =?iso-8859-1?q?cl4pyUlG3GVZ02+YTWTGcP8pZURpZKP+R0ifj4J5o6MYDYNHRUvWh/abiOsw?= =?iso-8859-1?q?TlGa+UlRoQuDev8h1ad63FJT1s3Pp8qvGjI21lofemeI5UhNLpOq41G+26E5?= =?iso-8859-1?q?Cgwy+WLSeFchmqIsABxoBZNK7b2UcgeGqc02EOK+9wkE9ti0Pzz8Fp1foH81?= =?iso-8859-1?q?P5sk=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: aff836e6-38c1-4786-5340-08d9dcb9ed5f X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:15.8831 (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: 4Y9N0OkziZuTanFLWza800cxWCttcULPNkKkdzY3e6G33xM0NiCsAbRN7Z3d9jE309uneAtt+AC+j8zKMIu5jXHthixsapGU+svz0UZXuLA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 3599010000A X-Stat-Signature: 45zt5fi1im5cxnfgerba48d7xzaxbhqm Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf05.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.89 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1642754538-146679 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: Powerpc needs flags and len to make decision on arch_get_mmap_end(). So add them as parameters to arch_get_mmap_end(). Signed-off-by: Christophe Leroy Cc: Steve Capper Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas --- arch/arm64/include/asm/processor.h | 4 ++-- mm/mmap.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 6f41b65f9962..9ceec2bf4b93 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -91,8 +91,8 @@ #endif /* CONFIG_COMPAT */ #ifndef CONFIG_ARM64_FORCE_52BIT -#define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\ - DEFAULT_MAP_WINDOW) +#define arch_get_mmap_end(addr, len, flags) \ + (((addr) > DEFAULT_MAP_WINDOW) ? TASK_SIZE : DEFAULT_MAP_WINDOW) #define arch_get_mmap_base(addr, base) ((addr > DEFAULT_MAP_WINDOW) ? \ base + TASK_SIZE - DEFAULT_MAP_WINDOW :\ diff --git a/mm/mmap.c b/mm/mmap.c index 7ac6a07ff382..ad48f7af7511 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2113,7 +2113,7 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) } #ifndef arch_get_mmap_end -#define arch_get_mmap_end(addr) (TASK_SIZE) +#define arch_get_mmap_end(addr, len, flags) (TASK_SIZE) #endif #ifndef arch_get_mmap_base @@ -2139,7 +2139,7 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr, struct mm_struct *mm = current->mm; struct vm_area_struct *vma, *prev; struct vm_unmapped_area_info info; - const unsigned long mmap_end = arch_get_mmap_end(addr); + const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); if (len > mmap_end - mmap_min_addr) return -ENOMEM; @@ -2187,7 +2187,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, struct vm_area_struct *vma, *prev; struct mm_struct *mm = current->mm; struct vm_unmapped_area_info info; - const unsigned long mmap_end = arch_get_mmap_end(addr); + const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); /* requested length too big for entire address space */ if (len > mmap_end - mmap_min_addr) From patchwork Fri Jan 21 08:42:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719500 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 AFBFAC433EF for ; Fri, 21 Jan 2022 08:42:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5095F6B0087; Fri, 21 Jan 2022 03:42:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 493886B0088; Fri, 21 Jan 2022 03:42:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 297526B0089; Fri, 21 Jan 2022 03:42:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id 194BE6B0087 for ; Fri, 21 Jan 2022 03:42:21 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C70E1181CB2D6 for ; Fri, 21 Jan 2022 08:42:20 +0000 (UTC) X-FDA: 79053652440.08.400B497 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120043.outbound.protection.outlook.com [40.107.12.43]) by imf10.hostedemail.com (Postfix) with ESMTP id 309A1C0004 for ; Fri, 21 Jan 2022 08:42:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QCdt/04nCTk0QZ1Lqfq+iOozSToEob5V7YYMyL2V2y00b6Z1xu/jkWuqaDIpxx+1xnQBJbmEgRATK4rwCuIXWSvSKXOLLRqgIexZJlxbIk6tIcdtTg0tOp2NUinoASr5RS7I+fvmlWQwWmfziafPFjWhRm6HQp2Su80qbo2Jwmg7a+0kFbIz9cqPX3ygYSs+C+sor2+FzUiR3oo534OCWYXPAw88bAD/jE7EiD/Ypacq39IfLo6x67JukFwnMvquzix761MxVKtymLG8Vsr9aTxRVu31X6VuXXXdvM86aB2OCNATWTscAQcbPMvmL1RcAPxgyfc3WHjNW8w9NABf9w== 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=lw5N86s3tqPtBgpRDVxozjxEFAMRNf6EE/hUhEFfU3c=; b=XwXn7IIXxNIPcB70SS8i0Biva04wLUKXOGc68QXVeQWE0rMTE6/bjn/B8LLPxUff+XJtXzAAFX13F+8cft4IwnQZY6Vp19QosMWH3bmxo6SEJlrSo9WBynlXPvmHvlSHT9EJ4RqSYfutljxITefsCjFWewS/nUqX2ORKrOgHusPFc+YQ9DLlX0rqRNVKP4cT33Ox7BYUO8VWzh7oJE4hr+lAaxChS//y2oS3Rf1DvIli3mCJH/OuYxxj0RDix7UyWP3sss+urCbW7C3mDbfIPcHYeL4TCm4SWu25kv1Vrs5Ds5eVu0VLBHMZ6GJVb3RJfrjtH7+C5xZoU0e2iw9yxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR1P264MB2206.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:192::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Fri, 21 Jan 2022 08:42:18 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:18 +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" , Steve Capper , Will Deacon , "stable@vger.kernel.org" Subject: [PATCH v7 04/14] mm, hugetlbfs: Allow for "high" userspace addresses Thread-Topic: [PATCH v7 04/14] mm, hugetlbfs: Allow for "high" userspace addresses Thread-Index: AQHYDqLM2DB5nXoCH0elbLgrlKVk/Q== Date: Fri, 21 Jan 2022 08:42:18 +0000 Message-ID: <6c95091eab9f58cee58da3762a4dc4c56ab700e7.1642752946.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: 1c6216db-644c-4901-25c2-08d9dcb9eef0 x-ms-traffictypediagnostic: PR1P264MB2206:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4714; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +RO20GS1c4VhLu9s7YiE5j52zwIg2XymivZtg+nuq8HGC/YljKkKBq2yy/Q6yFHb5mEXah1d2Gzp/bvzpb9f8vq+ltr8gD6vPH63ONZgLwh1d+pjKz5FyOUy4/hpjQMYW3loLD+uxXvr+M0xYXHhzwIQvU3iLfRFBnmUtWEEE+erZ5aqtNaPvYGYkeEEwJkm8YWrISgpg+ZWNgohZ8KVW2sKEbTuIDfHarteUeGRlpIviRqpKFGyjZCCyWoPRiEs0btoAgC+6VS5eQW8jUlifsgKYVjPxh3PlF9tdMDfUKABr5BezXtkcA8W3v/Bwvy0Zlm4J9eIt4K9APbQNw6dZpgMb2fkoZ2EkPm36G3SQ7KV5xeaxoxB1VRyUw7ukLriguCvbm5weXyLqXdEogmQYYVMiw1qXB6igSAIAGB6CQZQ0iBIr9aeXTtpCgBDU8FT+zdvD81HAmAQgpZvDPXh0/yToKsr3p7unmAH1jPSIcAtLZwyoyE39r8RVkzzDFnGZVyh5oRePnBbkaZepRM3Aq3R617COIA+1STAdsJ8fv1qTWl1kXrXbJl0CDtBmfSjcWyQb0y7qCuf2B9LVSR8I2vtOOAp+LMkJY5tugr+cgpWyFsi5f17iE8dMvw0RM9MH1fbEQduTMHCHKVrDPqvGqM6Hf4XbA7V3L2Zz6iapqOtdWha6DjglWSOO3+X8SoZ7TWP7CYvawi6cyu1xhbt6w== 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)(71200400001)(316002)(54906003)(38070700005)(2906002)(6512007)(8936002)(6486002)(86362001)(186003)(2616005)(83380400001)(7416002)(110136005)(26005)(66476007)(66556008)(64756008)(91956017)(36756003)(66946007)(44832011)(76116006)(66446008)(38100700002)(508600001)(5660300002)(8676002)(4326008)(122000001)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?W9vekwVZWTR+cbQo1SvzyZE?= =?iso-8859-1?q?L9gWBpvWRwupVXLAgzZtEfvgl8L0euDsY/jpLlRyMzAYQX31AJNPP1bG63YA?= =?iso-8859-1?q?xSAnVZ6okRm92xg2tNlCLzSoxFmvrJnnDMjWDodvc4VssOwLRgXIs/Wgpo0+?= =?iso-8859-1?q?46KnMKv2Ip2/jBuIr91LL/ZhIlvGOqN9D1gPAuIsMS+oVO9AP+TJANJHdJyC?= =?iso-8859-1?q?ujG7q+awv8J3cXAGbCK6r6I6CtXvQTP58GHzbjzUYNGG3b9UXPFIrppKCgec?= =?iso-8859-1?q?AGjGJ+C9fNcrbVByTOg7i0NL0z+jQV/6gnNQONzpQoYlED6iFR0sJODRlFx/?= =?iso-8859-1?q?cAfWK/P6GNYp3JrR3LF4bJp+gMbHBjrPX3Xzv1gSSwekcc06y9rwxFtxTCgu?= =?iso-8859-1?q?wklnxEAcY0PEVDD/ZliPt21hIC1dufodUElQje+fW1P98UI1+eya8Z9W0Y8q?= =?iso-8859-1?q?WzlXKTIG3/kdjQHS5pWmCyiUSKxcXOQiWbTb7mvaIx2z/nbyktzhwZuTpXcm?= =?iso-8859-1?q?EVElcAX+Z2yH62CwVC1Fquc5lg/GODztMMMeKoLy8np58synaMHZkkxvXhHA?= =?iso-8859-1?q?OQprsAFgY2HmveTkz2KTge6I5q0TEOadLdRhJa2y9TX7jqcV2EgAPjlm4/y4?= =?iso-8859-1?q?0bpyNk4l7k8dPQRtJsSX9cQB8GbKhSfdz78XiRZnEEt5NhB5GWCLFd2CAiww?= =?iso-8859-1?q?eOoqFZ+sGmXaDs2H4w8joViyFsdObP01IiktfhG07FkaWQaLJbM++8rOPE9d?= =?iso-8859-1?q?M9YuIZyrORz7adCQKhcF+29A9u2NFr0s2HhL14SLJ/CDpcGTstTmJJ9NQjPw?= =?iso-8859-1?q?VN2HleGoCaFIJNfX9Pueg2f/wDEKYKm439ruotYVJP0TLZw0Xyhmi+PBHB3x?= =?iso-8859-1?q?YhojIVHwh51ebNzEcZIztutDMlAGz4MrnHpPTBMTmQbG3HXeMYesknfd5N4Y?= =?iso-8859-1?q?En7zgpPqnA+pe7duDwAkcO5Imk5pot2O8HoeOjezC+sQR+Yojb8QVE5/tUgj?= =?iso-8859-1?q?L6hyr33xSTx63XJ3S4vyy6CQcKcJEdMSuncKYJvSGGCdQxvXlemLgdyp9b4S?= =?iso-8859-1?q?Rum2PAebn89AQ88IxDCKsgcfVjStfHJqlhY2HrM7Swb2AWkpGlA/4vQzRr8d?= =?iso-8859-1?q?ZNcoW1lkuF4fyDhqLqeM7TXQbvGE5JcVpVd6opAitv8sUWzsG4mvxFDY2Nm2?= =?iso-8859-1?q?g7xnZK+yOmCIUCpBEQlvO4HZLBnQJOfIeASUkGrdfwJPyh0wyUf/C1bmej6p?= =?iso-8859-1?q?z3btcgRouKyG0RIxmXeOOFrAKGvndeNm5SHS/X1bCiyXOEOYzmzu6UI/of2/?= =?iso-8859-1?q?+D7qe5oZm0GBf4S+Vk7Q4ZIsDqdLk9VG10sR3RDH2E9mm/AOtEJT1wtJs+jW?= =?iso-8859-1?q?iHvaq2G5q+EWiBdQ2CXs4E3fLTVKfUb/IrtC/Y1NU7UAhObj0WImhT04hvqV?= =?iso-8859-1?q?6MmwLtubG8tsHMtA/nvoemNY7IZjNmzR/ee6nSMmJLFoftTCjWAlLhGGN3XC?= =?iso-8859-1?q?ilN6XbbVZENbLpgXWK0UB3i4+kFEz+8N7fuJ5JFmmkXgjXHc6e03JNiEFzOH?= =?iso-8859-1?q?fF1cKqxwxRWIvMKTvClFJKN0EdvkcKbi+kb2IZbDH7+sIE5xAPn0ifmQlxAc?= =?iso-8859-1?q?DtvE2gWx3/g6eAWdwoMPPJAke24ajeoZtpA1TCn831eSM9CFPuJsA2IcsvIB?= =?iso-8859-1?q?+k4XA/zaYDKsQH893zmtjDeQwYxrGKc9EuM0aNsfsihvdw4wFmxFBvKS3A8k?= =?iso-8859-1?q?1suA=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: 1c6216db-644c-4901-25c2-08d9dcb9eef0 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:18.5099 (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: gBfZW1GH8L4QWmsllaah1+kXn3I7doOZ3MCPALacgWkmJfhILrSfeXvs3hIbja3USmD7WOj/CtL0Cis8MsPmGItv4AS1nduNeqAbzocEfRg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR1P264MB2206 X-Rspamd-Queue-Id: 309A1C0004 X-Stat-Signature: se9u16xehsm9ap119tiscjsukf6agjky Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.43 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Rspamd-Server: rspam07 X-HE-Tag: 1642754540-428768 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: This is a complement of f6795053dac8 ("mm: mmap: Allow for "high" userspace addresses") for hugetlb. This patch adds support for "high" userspace addresses that are optionally supported on the system and have to be requested via a hint mechanism ("high" addr parameter to mmap). Architectures such as powerpc and x86 achieve this by making changes to their architectural versions of hugetlb_get_unmapped_area() function. However, arm64 uses the generic version of that function. So take into account arch_get_mmap_base() and arch_get_mmap_end() in hugetlb_get_unmapped_area(). To allow that, move those two macros out of mm/mmap.c into include/linux/sched/mm.h If these macros are not defined in architectural code then they default to (TASK_SIZE) and (base) so should not introduce any behavioural changes to architectures that do not define them. For the time being, only ARM64 is affected by this change. Signed-off-by: Christophe Leroy Cc: Steve Capper Cc: Will Deacon Cc: Catalin Marinas Fixes: f6795053dac8 ("mm: mmap: Allow for "high" userspace addresses") Cc: # 5.0.x Reviewed-by: Catalin Marinas --- fs/hugetlbfs/inode.c | 9 +++++---- include/linux/sched/mm.h | 8 ++++++++ mm/mmap.c | 8 -------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index c7cde4e5924d..a8d3b0899b60 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -205,7 +205,7 @@ hugetlb_get_unmapped_area_bottomup(struct file *file, unsigned long addr, info.flags = 0; info.length = len; info.low_limit = current->mm->mmap_base; - info.high_limit = TASK_SIZE; + info.high_limit = arch_get_mmap_end(addr, len, flags); info.align_mask = PAGE_MASK & ~huge_page_mask(h); info.align_offset = 0; return vm_unmapped_area(&info); @@ -221,7 +221,7 @@ hugetlb_get_unmapped_area_topdown(struct file *file, unsigned long addr, info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; info.low_limit = max(PAGE_SIZE, mmap_min_addr); - info.high_limit = current->mm->mmap_base; + info.high_limit = arch_get_mmap_base(addr, current->mm->mmap_base); info.align_mask = PAGE_MASK & ~huge_page_mask(h); info.align_offset = 0; addr = vm_unmapped_area(&info); @@ -236,7 +236,7 @@ hugetlb_get_unmapped_area_topdown(struct file *file, unsigned long addr, VM_BUG_ON(addr != -ENOMEM); info.flags = 0; info.low_limit = current->mm->mmap_base; - info.high_limit = TASK_SIZE; + info.high_limit = arch_get_mmap_end(addr, len, flags); addr = vm_unmapped_area(&info); } @@ -251,6 +251,7 @@ generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, struct mm_struct *mm = current->mm; struct vm_area_struct *vma; struct hstate *h = hstate_file(file); + const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); if (len & ~huge_page_mask(h)) return -EINVAL; @@ -266,7 +267,7 @@ generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, if (addr) { addr = ALIGN(addr, huge_page_size(h)); vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && + if (mmap_end - len >= addr && (!vma || addr + len <= vm_start_gap(vma))) return addr; } diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 2584f7c13f69..cc9d80bd36d5 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -135,6 +135,14 @@ static inline void mm_update_next_owner(struct mm_struct *mm) #endif /* CONFIG_MEMCG */ #ifdef CONFIG_MMU +#ifndef arch_get_mmap_end +#define arch_get_mmap_end(addr, len, flags) (TASK_SIZE) +#endif + +#ifndef arch_get_mmap_base +#define arch_get_mmap_base(addr, base) (base) +#endif + extern void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack); extern unsigned long diff --git a/mm/mmap.c b/mm/mmap.c index ad48f7af7511..c773b5ad9a11 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2112,14 +2112,6 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) return addr; } -#ifndef arch_get_mmap_end -#define arch_get_mmap_end(addr, len, flags) (TASK_SIZE) -#endif - -#ifndef arch_get_mmap_base -#define arch_get_mmap_base(addr, base) (base) -#endif - /* Get an address range which is currently unmapped. * For shmat() with addr=0. * From patchwork Fri Jan 21 08:42:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719501 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 59D53C433FE for ; Fri, 21 Jan 2022 08:42:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1C2B6B0088; Fri, 21 Jan 2022 03:42:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ECB916B0089; Fri, 21 Jan 2022 03:42:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D93496B008A; Fri, 21 Jan 2022 03:42:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id CA49D6B0088 for ; Fri, 21 Jan 2022 03:42:24 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8358D181D75B4 for ; Fri, 21 Jan 2022 08:42:24 +0000 (UTC) X-FDA: 79053652608.25.DEABE9F Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120083.outbound.protection.outlook.com [40.107.12.83]) by imf01.hostedemail.com (Postfix) with ESMTP id E062F40003 for ; Fri, 21 Jan 2022 08:42:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKl6PA2PhoDixYIc9gtYMeK4HE9hCJ6r/MaSuJ0EtwMu1s3ooGFLWwLrGzckv7YSbg/pSnuTJhVyUn6SHM5S1fwxcln2WbiqczKGCh/w+bupCn390mDVUjzIZ2JrOgHBsTNHJnkaaL3595ITeZyBiJLjQe47vNc4AdqQdMNSIVHmLpcAo0v9+fQGxIFNFrxLePZ3zSMGOqe6XJWsENmw5hht5SoK3lE5+dOIyuyB1lGaXsxT6iYrOPVLwrlQxkb7nK+6bsA40cpkOsIrdS3cDhuzCjZj/xzKr3bIMQ4qQAXc4TPVJ6Yu9IkcEG31ePt/eHgqXywOBE+3B2ubVQKFSw== 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=BMqQpMVPJWiGmTGtq2QUJHhfhL+o8r8GMswJlhxDXUU=; b=fIrmtPgi58wUrz7qmagxiHmi1X3fRaRYEps8WALIbqpMEzeEfWn8YzQbTPMsPCHt8+tfsAojFxbRExS7kvcJ7EyjRl7+9l5NuNtmpv8UnGZxnUmgyPvcjT2Gah2kt4opnWyxhDaSZGvuZ5yvOQZJ1qQr5GfcvopTnn+vxlFjm+X6mn9fdRTeObuCafJCrNGg2omkw60YFXkOnJFC2jBmU4q2PADL8Hz6y9TPqSUYHfDhjugsiox7elCH/eMiK1I8pVg0C/L94iWEKiv287V17YxRLSCpqCwvfonBnu+jA7E6LXWyBM8JGYeyBmGy5XzPeqwdRw6fEuLbV2OViCzROg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by MR2P264MB0196.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Fri, 21 Jan 2022 08:42:21 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:21 +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" , Toan Le , "linux-pci@vger.kernel.org" , =?utf-8?q?Krzyszto?= =?utf-8?q?f_Wilczy=C5=84ski?= , Bjorn Helgaas Subject: [PATCH v7 05/14] sizes.h: Add SZ_1T macro Thread-Topic: [PATCH v7 05/14] sizes.h: Add SZ_1T macro Thread-Index: AQHYDqLOuo8uvB/7ok2rn9L7yMBx/g== Date: Fri, 21 Jan 2022 08:42:21 +0000 Message-ID: <575cb7164cf124c75df7cb9242ea7374733942bf.1642752946.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: bab4360e-7273-4eb4-e849-08d9dcb9f0ca x-ms-traffictypediagnostic: MR2P264MB0196:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:639; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wFNSPQLoXv713+UZ1YmwmWzGYYlpm4/DEcpjIziTKNxOvnh0YUm8IT2gGnFhGJOPoIATBW8gh9/q9rlTG0byU/IH3oeytuLLQ1UbJUNA/yzAR77F89p/JVo0mKk4CRwGgXGpe9Cw2VvG+AVI1Tx8iAMR3Avi6NRDSXeBTvJiDDDHXBufi/5KGaCsbUiJo1ZzLoTmiOsENa/VD6yvwpoi7Fq0f+xKfOueDypYMKd/qCwdQFhoeeOS7ouT2oS/X3Y5+2OghBQhe7tOmST62GrKoqQjHvDNELjEduZE73ol+K/2lV6rTC8SO1Q95ktOp3InmyWIMWFgcIRK5oGZJqRlzXSrAsVp8mdbY7a7D82WeS8KhLKDihKdwOoY1mUn7Pol+N9xn5xZCvcXLi6gzGC9nC6EDTARYwvEMkwR+W3scn7UkHZQ7tyVQ89IxjD/CA4azLgWoflgR7TEwFcimb1t2mKFNILKxCfP/h8nx/BbSmOZFHDMa2cBs9mfbdO1A+BI8NSze2OqrS7YDHUupwaya//+gkRzYouehyMpeanyhkRDHC2uMfQVDdpLDF6I85PI/AiO5OJn1phrj4T7m5m890MfDdrVO2CCNVVuW73v2zoX766WIloAGmHKzdkVQpGHicun741hAWHx7TuKwjo8Maz8wFkwmD9QX0JvxxiWaRcw2BYANqhmNt9+N8k3/Su3fpO7ZgBCD81gZl5YMnDQ2g== 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)(2616005)(6486002)(186003)(44832011)(26005)(7416002)(6512007)(6506007)(2906002)(8676002)(71200400001)(8936002)(508600001)(86362001)(4326008)(5660300002)(316002)(66446008)(64756008)(66556008)(91956017)(110136005)(54906003)(38070700005)(76116006)(66476007)(122000001)(38100700002)(66574015)(66946007)(36756003)(83380400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?wrhATtjoaKsFUAoWvZNm6hwIvyo9?= =?utf-8?q?ZgNwoTIl8qrQbzg/UB0MpXeiebkfsxoBoLm454wBRzVLVDxS7FiNuS9k1nuRf1A5j?= =?utf-8?q?CNClCBck7qo6LadxkkB55JkgSXLX9ZBtqohCFvw31PEkvnmN2ldQ/RJ0xWZNC45R6?= =?utf-8?q?+6UF/uGjwdsuGdaXYjDZBw5l7M8F5KSsApnYeD4OQWLNkpGq0SM19dUATir8acS/3?= =?utf-8?q?OkM8KCMTUX0wPe3YkolsebJdp7pRtxc4myrcZk++dOvFK0NgavMfKXNr6VWJwrDyn?= =?utf-8?q?pGRNSi+abjtIUJ3rja+B8h2jMA/ytJ8X6MBVMpTnKQUiX7UKijRsZXKPnQ/J/OTr1?= =?utf-8?q?6ls5zZ9ZluEuOuPJW7cKBD2iCZIo3NIrKKghCeEkA4qu6jJv/bTyX5Ld9yDUMVxg7?= =?utf-8?q?FGXn42mkWEjK3IMH8y1yFXC9aZ7w1Itft2WlcKOFPbyT9s1pnXrtXnjySjhSWdY/f?= =?utf-8?q?fmcfQ8OAupwTeyehvUCT8c9nMQEN1Azlp4PfaT+P5RAmzvCrlU/E+q4xQm4XQJHyu?= =?utf-8?q?UhqNb1ewtOXE2yIQ09wyQBBAz8+r9oiv6/wejgtNeJ8K7Dv17GwYWHELJ3bDvRyH4?= =?utf-8?q?pjHOJSqpv2Wox3/6Dl4cgu6vh0wvXY4uOuMWuu7WaWWe9/10H6yWEOLdtOBbhM48P?= =?utf-8?q?BIlg69cbSxtj1cXBGbGCsLlkhCuWyKkyfHYhThsu2VvHwAZYS9qQRoe1xVmd7/Ngx?= =?utf-8?q?Y6W/tySjZDyb+jqT+7jsbuOwzqEKPtvbYnJKl1XoKTbP2YitIWwNomt7MReYMUZl6?= =?utf-8?q?satl6nP2/1iH8GUOF8dzZGcGMPX3smRfKZHcU6a8tMCS0XTHyKYmstEyFKi9kHPDS?= =?utf-8?q?a4THg9Ykm64x5mqQMucpjBZYBO7iV4gQiFqEEuExTilyTsHlQvxQ6ewMdUVgZjjlg?= =?utf-8?q?KDXc1pIlA0LwqSiPm17Rf65H0ajj4vPaIN/H2dlratxC0y3wtmD7KmMuJnOASEFv1?= =?utf-8?q?99DeowXXcbgSevS66IoJ6/EAZAWYSKxIz8hOcXpJFl8VUPyYiKPy4MXQg8VmRBHB3?= =?utf-8?q?rbjIJGhSbJyLYRPoOPO2Hhrfz/ZbHCe0wcgiG+ip2oZZ+O0LwRRuJqUgZcqqxiZBS?= =?utf-8?q?dmc47MJtVoYKK/Qg3y/TXSU8ZP4dKifwI3TvG9GUvjmEIw0D6goGVAHCkVDqn/N3l?= =?utf-8?q?SYZCxztOD7TnxQ1fQ5iNCOqEtsSu2G190DcLIJcCtaGNoXR8h8vRl/2TONUffo2m/?= =?utf-8?q?vrF3EGnIYXbtD2EWDzhym8fSv0Zld+BY43Jroi0Ov7XSd5w5/e15klJjUNiLt+C0m?= =?utf-8?q?BR6Dc/ffGlAOatVFsFKxBjnh6rhEOdiVVBDhiG0BwYX7SXjMUk+rwhTOq91xuevqz?= =?utf-8?q?PeV1kDuLDmSwLL+l1olregrmW4A9VIvouSLBeHgJ/XzXgjXTAe0csW5y9DMxToOL8?= =?utf-8?q?EFeJbCCvqldUXfFR72UJw3Hdre/Te6bODvHpzz7GrmBZ3Q/RUAhRHPoxYGzD1pdtg?= =?utf-8?q?yHws0BfmSOXafP2/WO3F2G8yrviZvhxhvDxNal5QzZvDPNOYrxQX/cQzQsy8fuccZ?= =?utf-8?q?g7Up3qQTs//GCG6bz+iUSrbCaKsVdCErLSZXhzJ2maFVafhU0lnWd9qEP0A1xEW/m?= =?utf-8?q?H73pZ7OgtnACGOcuXN8JUIYp8frB9s3DeT61Nwi4km66Eb0MzMzi4U=3D?= Content-ID: <459E0A3096FDB242BFF2B48A7CA01F7C@FRAP264.PROD.OUTLOOK.COM> 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: bab4360e-7273-4eb4-e849-08d9dcb9f0ca X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:21.5744 (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: Bk9aEtwuY3YECjeiZX5T+h25cQWjmzLcMtxZW1qmOk+jEVS/4EGUxj6riCdHjoYylL31CkpnBE1lTXTgNHptEIQEr93vtVOXaKkqscmjptk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR2P264MB0196 X-Rspamd-Queue-Id: E062F40003 X-Stat-Signature: dn4sjcfwxjq7f7zywar4wkg4kr7xtnos Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf01.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.83 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-Rspamd-Server: rspam06 X-HE-Tag: 1642754543-377072 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: Today drivers/pci/controller/pci-xgene.c defines SZ_1T Move it into linux/sizes.h so that it can be re-used elsewhere. Cc: Toan Le Cc: linux-pci@vger.kernel.org Signed-off-by: Christophe Leroy Reviewed-by: Krzysztof WilczyƄski Acked-by: Bjorn Helgaas --- drivers/pci/controller/pci-xgene.c | 1 - include/linux/sizes.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index 56d0d50338c8..716dcab5ca47 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -49,7 +49,6 @@ #define EN_REG 0x00000001 #define OB_LO_IO 0x00000002 #define XGENE_PCIE_DEVICEID 0xE004 -#define SZ_1T (SZ_1G*1024ULL) #define PIPE_PHY_RATE_RD(src) ((0xc000 & (u32)(src)) >> 0xe) #define XGENE_V1_PCI_EXP_CAP 0x40 diff --git a/include/linux/sizes.h b/include/linux/sizes.h index 1ac79bcee2bb..84aa448d8bb3 100644 --- a/include/linux/sizes.h +++ b/include/linux/sizes.h @@ -47,6 +47,8 @@ #define SZ_8G _AC(0x200000000, ULL) #define SZ_16G _AC(0x400000000, ULL) #define SZ_32G _AC(0x800000000, ULL) + +#define SZ_1T _AC(0x10000000000, ULL) #define SZ_64T _AC(0x400000000000, ULL) #endif /* __LINUX_SIZES_H__ */ From patchwork Fri Jan 21 08:42:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719502 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 C653AC433FE for ; Fri, 21 Jan 2022 08:42:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F3EE6B008A; Fri, 21 Jan 2022 03:42:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 57CE16B008C; Fri, 21 Jan 2022 03:42:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F6F76B0092; Fri, 21 Jan 2022 03:42:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 309086B008A for ; Fri, 21 Jan 2022 03:42:27 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E0AF58249980 for ; Fri, 21 Jan 2022 08:42:26 +0000 (UTC) X-FDA: 79053652692.05.FD76E90 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120055.outbound.protection.outlook.com [40.107.12.55]) by imf10.hostedemail.com (Postfix) with ESMTP id 5838CC0002 for ; Fri, 21 Jan 2022 08:42:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LOpmXgkVo/4pjtIONyghiImX3RsfwHw7molWiAfpfCpYmbtJrPhQ65m81ZZj5UnBIaUK59YjPlBs4WOrpxIpQxvsgSWQB4c22BWS2D1YexfV0EWzSdhWh8HHYhv53LbNJGGxrldK9qD4svvJbMdZ6zOYLxP1jamB1o3ldhwwXU6ErMohNJcFLXXvj+DJgFONE82McjINVcp1dRtPWm2v9dJP8fT+mcSnZy8qUR+Lu2jRhUP12gQGvchtmXZz4+kRRkJFIRRzaUEMry9A6OAhcKqbpnlr5b3lb5+Mx+xrZTJa1Gn1aG4WMzxHXVr0mSs/XKaMWrKIbG+9aTyawBqCSg== 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=RiZMm9KXXy+vu3WhUEQeEWc13H9a8TPaQVYGQB2pazk=; b=Q6BEit0Xa6hcwD16Yw3+a2Ib+75+E354gy8AIJ/REiXZ5gdIRz4vjP6UesGUybg/f0lp65tVOKr3Q13T4ETFkFctT5s5zHPA3uSsQhyrTvq6ous6PWC3FPcKIlK+EoUNeer+VkOb0EGFQx6pwsUHX/Efo5bW34jc5wYssAz/4YS7TAv0LeVBtRlrSAW+B/nbBtyC/mDa/54iXYQZ22kkc0FeJ6yBmDxNjxChCY8KzXvRsG8joWlqgDSFD1eUDYptm9IKY9kbGkC92rBNd9hWMZ71VDhH0Fdr31Or/q+dJ5EKR+UyelP5D70UwgPNfTkLa15yyEz4WuGTrUEwnm03aA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:24 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:24 +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" , Nicholas Piggin Subject: [PATCH v7 06/14] powerpc/mm: Move vma_mmu_pagesize() Thread-Topic: [PATCH v7 06/14] powerpc/mm: Move vma_mmu_pagesize() Thread-Index: AQHYDqLQNgMtoK4UpES9C5Vln6QanQ== Date: Fri, 21 Jan 2022 08:42:24 +0000 Message-ID: <44aac3ced0ce952719fa0b7bb924a3be7752c25f.1642752946.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: f38f2648-550d-4339-21ad-08d9dcb9f2a6 x-ms-traffictypediagnostic: PR0P264MB0201:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MIBM3VGcD4LVM6SU223MCLMm+DFCkhDSWiGAP3MWi2YqJOQdQi+nwv6ADO/uizrLzJNu9LOn6fJ2XHvlT37CcPdgdoizIIjX0WJ9l7qP8mRTC5QCY7JbGj2+UnZ/WmMqtBEmdyciPoj9Qwk+UmOs28cAqANWzqyVAkyfIque1fUS44dhPRa3L2QpdXAKYIvZryhFlZEq47Kgd1bW0EGi9orlQOesiLgNOH4KEP+EULTwUsEBZeyxcuvkw0xfywfXNldr0ERZfQJGeLj3uRvffTL3vleehtUnXtcW/o+RASvQOHxe3JEr05DZqzEeE53khhVuyjIpR439o+d8K/Pfoc1erhEw6vicA1owuetjZZw7vSktykb9J6cR/j9hmco9GtIry1mQV8sLOZquqflNM/quWQBa6ekCFMvn34d1me51a3bZrKnwDLealycj5Cge2q2MyftugF0YDzCpww2k+Kv8ZgHrq9vZxED5WacQK3Z0FiktjxXFVFvwZOylTWdcz1V+7wCzwdHTiNvjM61iSaHjeQuojL2W47KlWlKHMayIn7gQv/MgO9uvEKfp74o2LUVEQKda/NqgT70VME0+S6OeQmvKuWnMiBms5koSda8By9lxKkvIL28S1dMx0RZ/8QcNxtqJcDfkGOZRNSCh6lZgqVLtHnjj7Bn8F+2GxxqItIJyFpYf8UPz6/KC9bcn4PIcmIKILjicbVWpPDJ4eQ== 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?vfP5DPE6GUHjc2ZlITrqYqM?= =?iso-8859-1?q?PnBUbun9FJw/ruD+IXrj5NY6P60SgL9/ZVXi3Unkw+RS65FPN1Alza6s5HyN?= =?iso-8859-1?q?5W/QlQ/soQj+Ql2GLzT1+4iazI33a2wc/az6G3S363QbIlTTAC3+h06GdQtX?= =?iso-8859-1?q?MUKgPBVjWBmifGiOFi4UyEjjA68OJqKdltvyYtElRPDDMzByD0RHDpd0+vdd?= =?iso-8859-1?q?0/ojK1ku8T5iBWbdFsfHZdsHBr/52T/Np//qiCdYftQqFUzJCCsmJnQD9cuQ?= =?iso-8859-1?q?YHNbVuv0RLP9cgjsoCX6fc3Nw6BHKMNKM8a98c1eBESPVLnAGyIvus3hSbPk?= =?iso-8859-1?q?qLC4QTwkSY8vy7YiMQoyYKek3ko9Nw5MCuURCqLlPh88pqBA1TBP2N/g2pfy?= =?iso-8859-1?q?UE8qvsnYKUuhQeaavDVrqjhjJCYt76aJTx+GDX09k0n5RnB5o72gkNI/hORk?= =?iso-8859-1?q?ycsuHpUlFAc6g0y/Uz6N24/V3K+MgEPVH52IeYCAQFMQhBuMbcSoJr/mI1Vr?= =?iso-8859-1?q?QQLum3IIppmHYn5k+Nr33WR+neZ7pwK0yQs4NGscLu7WmUhG/wRqSfusQ1Dg?= =?iso-8859-1?q?dEMys9lVpj+bm1iE3DcFPlR0QUV5sKnSomd13iopqu3fluhhJ08cL66wezvR?= =?iso-8859-1?q?OGlg3dtvf5DpKb7n79xMY1el+Qr8yU+HzazUqLEcTCeQg7SqK+tgaOWumsgY?= =?iso-8859-1?q?N9/9Vc7zuAoVBZb3YMpAMCQO01YUalhWaEl0AltSTzCgqAQVdmPOsOfzmNGN?= =?iso-8859-1?q?Z7ifqoa5fecCtZd2SRpEYK+rk/DcKsi2bh8cKrPYlv/l34Gp9vzSVzxuWHQr?= =?iso-8859-1?q?OoCWkVyMongy8EeQqa/BruNYkB+glH4Oj4DozK9U43I2HXbT+P/2VC64ZPjd?= =?iso-8859-1?q?QRLkXeCCo6fOhlkJHGszkaPol7WnTLE6d+mzhmgr424yepmyxKkBGiIa8oye?= =?iso-8859-1?q?hvH61F3Q/6X39tZJSJRe5C7pugMyP49zgOmMoL+V1udL3jbqKt5vIOnUTQFl?= =?iso-8859-1?q?F5FPqux1MCv6jF2ddz9pBSxcvjYMKbMio6TJlohIg1IZqd8dnktJMoEwXUn2?= =?iso-8859-1?q?0UC7lV6Kx0c4ow42Bs9MIdgqFFQvIUUlEiDhkG+KOMop7DZEP1Fk7g636CtE?= =?iso-8859-1?q?s0dvwXytlVfjODgDl714uBW9osS9GWLtd58ioXHClAgfMVt2hJm9yP4HMouY?= =?iso-8859-1?q?/6ufv91DIkPBeYmvhTZ4fRziMMo+kaEZrfgMNZzpyEUX45/FwiA3d5UcX0hk?= =?iso-8859-1?q?p32WZd8bssBX/CpULnE5FxdTd6251DIgolGhh9nLjhFdvx6uhuPBwH30mSxx?= =?iso-8859-1?q?5EGnmnQa+LMYDSdTJkRK6GHq/L/U6f2H/3FqCjNobAfISdCsqj4pxWQGRu0v?= =?iso-8859-1?q?Rkingq/xOlUvBRgdhIF9k7Qe36l++WJDtIiZa2iPHWVoKTnlB+eYUtCrpgg7?= =?iso-8859-1?q?QpEg2AXaCEa9Uo+/DZjUIWwkZ0fpfbHCrrs3rsJrewgXzF3Nbw8kVeKOURlL?= =?iso-8859-1?q?58SNniNPwJa8usBvdPHq5DpIXch5oABVG88Wmx9o3PWNA7SraNNTrrk3ggKJ?= =?iso-8859-1?q?UTWSfAiKS46e6ELjA+DTxJApI7K474j90ptQND/h7C2tbmk2LJoUhX+Edam3?= =?iso-8859-1?q?oHgh/mrxMb6wUhU4yliUsrH/Z/yybBANijddwFPZDx0Psy2EzT0u9xXY2aZN?= =?iso-8859-1?q?ugGq1xNbTKa2zH77/rHUp2EzyB+NdgKyl3aLtlWdU5qeGe9zgfyzgEGGSUWT?= =?iso-8859-1?q?kWnI=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: f38f2648-550d-4339-21ad-08d9dcb9f2a6 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:24.6889 (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: LIwVnoDlj7jnROwwpTM58+Hn2x6xKcrMhwonVWxfTk0kexWutvWdW/j6zogLTTqDiwF0djU0d0MUyoiH/QUkJcYdBGy6WPW26xeQD7GkBLY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 X-Rspamd-Queue-Id: 5838CC0002 X-Stat-Signature: 5x5zbacu7a1rxynqhs4ig6hqxnsfqeyz Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.55 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Rspamd-Server: rspam07 X-HE-Tag: 1642754546-163869 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: vma_mmu_pagesize() is only required for slices, otherwise there is a generic weak version doing the exact same thing. Move it to slice.c Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin --- arch/powerpc/mm/hugetlbpage.c | 11 ----------- arch/powerpc/mm/slice.c | 9 +++++++++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index ddead41e2194..0eec3b61bd13 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -565,17 +565,6 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, } #endif -unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) -{ - /* With radix we don't use slice, so derive it from vma*/ - if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled()) { - unsigned int psize = get_slice_psize(vma->vm_mm, vma->vm_start); - - return 1UL << mmu_psize_to_shift(psize); - } - return vma_kernel_pagesize(vma); -} - bool __init arch_hugetlb_valid_size(unsigned long size) { int shift = __ffs(size); diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c index f42711f865f3..8a3ac062b71e 100644 --- a/arch/powerpc/mm/slice.c +++ b/arch/powerpc/mm/slice.c @@ -759,4 +759,13 @@ int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, return !slice_check_range_fits(mm, maskp, addr, len); } + +unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) +{ + /* With radix we don't use slice, so derive it from vma*/ + if (radix_enabled()) + return vma_kernel_pagesize(vma); + + return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); +} #endif From patchwork Fri Jan 21 08:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719503 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 1277EC433F5 for ; Fri, 21 Jan 2022 08:42:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3B046B0092; Fri, 21 Jan 2022 03:42:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E9A06B0093; Fri, 21 Jan 2022 03:42:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 889CF6B0095; Fri, 21 Jan 2022 03:42:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7A1806B0092 for ; Fri, 21 Jan 2022 03:42:31 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4643996F0A for ; Fri, 21 Jan 2022 08:42:31 +0000 (UTC) X-FDA: 79053652902.14.1FAC859 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120073.outbound.protection.outlook.com [40.107.12.73]) by imf03.hostedemail.com (Postfix) with ESMTP id A905C2000B for ; Fri, 21 Jan 2022 08:42:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ir7BopmHnyJ/i7Bns3u+baLuynD3HTByqWGbPIWnd/gSVv114JfjBKvgYhVqs4B5bRsyhzKz/rdGmHsiTDQg3noIAQRSAzCM1E6y7jVqHVICCrtP9FGynutOztT3TqPc4M4ieT2sJvg2cziXNpSYkmHYSWYDitI1i85PGim4yQAgYhU7r1oCEnkQiIi9/qvzUEqtXZn5EnoOWZJcttIwtCRsGFGohr4bAzFro94OYL3vN6TKsFRLMwRRuXCTyAq+YVTaf+KbYitsiA9MrBP2HwI8btJ47LIKlScl0n+43ouEG/+fu42CgJ2in9yGw/GzcOpYSfVsXS0O0IyoF1Rlag== 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=BcB2DX1cHDXi9JS6wFdHfyCR3d/PINCnfCWyhq69JXA=; b=MEkYioVhQl0vHFj983RMBIUYdbj3DO29XcjrDz8ZDs4fDsYZ8J4BSuMIZ/hkyK7g7y95dTX0VidlqcJ5Sdg2iFjUzCUPeOutt2VIWTkR0n4en6PdH1+HlTGttaEixgwA0j0vtMQXjPBpVea+Y2/uo1Kjn8Woq7FjGbzGWcs9kKTxmdi5HJJLegK/gfmdB81b3GYS5fdgWOZzOfu9eqOsW5qhWFuhPJDOq6hek5xvhir2L8UA3qtWV0SbeQ+iAsSrpc/8v7vJPjADWfujmraN8OczYZYpGZsw96KaT0TPapFwHY6L4VmBbn1H9dFMiIh0H/IYGi0i4xBU+oWlZR2tGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:27 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:27 +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" , Nicholas Piggin Subject: [PATCH v7 07/14] powerpc/mm: Make slice specific to book3s/64 Thread-Topic: [PATCH v7 07/14] powerpc/mm: Make slice specific to book3s/64 Thread-Index: AQHYDqLRddxa/03Vk0SHKge8QDGmPg== Date: Fri, 21 Jan 2022 08:42:27 +0000 Message-ID: <0291cfad5e241a98aff2241fdb6bc30368e66d8a.1642752946.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: 2e6b22f0-f9d0-45e5-bb32-08d9dcb9f45c x-ms-traffictypediagnostic: PR0P264MB0201:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:178; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PcOaaZHOaiEZtliO6UKAbYqdJ9NBtTFkbkfcrDU+KxiGiCzz+Xfo91QyRNd+ekSrgjkVOV7dOkqQDQCOMmWkPpfZzWFsdswHHKAAY2i21jMzf3Jm/fJcaZGT0IAPTtS+McSuqGbavCi6egM+GsFpa5rJwhW36gHh51BLjnolXSXPhGq8OrO5r5WAXTJpJjq/G3RjOxNPN39IM4FUMsIZTlAOe+IyyNrxL3uDPNQThC0cys48GpPbuNypxinj86bYe+dDH1Ts4is5xr8EyNkTZrT+A3Usk880y2EqnI7+PJusuRiHYA1VNRukJvzGAFDmlHCcv+PheAqwo8ush1LXE65Giix7iGW7IOXv9lKLuXfMKAphW4wL9Hvx5JC6UmZIBlKrqaDnB7pTvA5mNkbk0zOuQYYJPfB1ONlofJc1vM9fVxGRyDchZ8mL024jegS97AmhlAKFnLVcg1m4UyDatqCEZ96f19lsMdiN5Zz+GeIt/gzm4aoCee1HO/KzBHduE/Tq0O7hfib/oZCcdZZpdQ/c2kQXrk4mKaVbfEuec+Db562F9NTRA4tTmG9ZC0P0LZ/Dz7qRodmJYLEHYQbgfSx7cz4zIAwqbhgs8NX6FX2V4OS5TuUUK/jamOZXSvNZg6zpgVBry2MlldsWZg2/icI8G16tRnaJhJAulY3jk1SA6Xe5B3iEbZWN91juclzSRCOng3Lj+paNd/LWaEGbOWcrP1iMsx9Hd1ukKHyu7eU= 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002)(32563001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?ZTeUo4DpnvMlndUZ4d8bnH7?= =?iso-8859-1?q?nddLdocTNa/3xMJTvV8SRhcwg1hBL1j2oX7QJ95mc7o1snwVPlWL4zBCagTS?= =?iso-8859-1?q?nUF29dcAtr7XRVKOIKBbn8Np33G7cTcPjzposy6XVzuS9cj77sXBaV8zibTM?= =?iso-8859-1?q?nj3JjB57nCgJzBT7vDnMyDcm/M4dK/Bst63osaiciPyATQ/7NFctpyRQG2/I?= =?iso-8859-1?q?pjiVG0eHWZS2NDPw3LTJQs/DSvG3YFQE1SMoF9zRb0dWuIQaio/90yOIftcY?= =?iso-8859-1?q?yoNTeFUGSJEDBcCns2PRllOYeXiXdkTjMVjcCnrOoXWPrqKxwmqWKiRnb5KW?= =?iso-8859-1?q?HlqdsheG6WK6QNpbfjsaPJ75CbJyjMLTXIAh6rhJDzvphMqccJ5rIoOPVXil?= =?iso-8859-1?q?z5uPYxBmd6F/C79GSVPTCve3iiR103PvyGS96MJui/XiiYINsLc1C/VyewwJ?= =?iso-8859-1?q?WRW8QuOHuRqzzVS/KQ5xoQgJHMfaubEbUxkP2wYSNvd5Msz57AJdjesiwEAM?= =?iso-8859-1?q?P+kiBs73fupDIwSLuAU2TbGWH0XhOCCKIXqozgFAfdJ8m5i1kdcxTrj5shx3?= =?iso-8859-1?q?eR8iEgiI3ofBXi0/HTKVL/bfMB5Kq6UrqmTYyLDDXBa45CpahNQLcGq9Z71I?= =?iso-8859-1?q?Ux9jObtpl1oWjwgmH/005WIOlpMXGys0YsspF3od+sgXTyQqyWq1v/2YGOR/?= =?iso-8859-1?q?OoXyfX6PWkeKv4PdPFGw/o0J0QBCCL57QW/WRmZR/NMwEt8qRoGpCJ9Rme0j?= =?iso-8859-1?q?iCC5NwP5dLa3ANLhTxnDHiXGcRJK6nOrbb/DoRNjtO5Q4VD9seT98qTB8z1y?= =?iso-8859-1?q?9WZTwyPLVmCmXiO/MfXaumWAp3n/9GffHobkfUCjmi+eqaNI35T8I+j2lW4T?= =?iso-8859-1?q?YfMOcJ9pPGLlOYfZZj+peyNiW6Z0BeQdl8TLA4LINAoxlguB6vXQvTKHZejf?= =?iso-8859-1?q?tvb/ZcUaclshQMhQMPwwC06i4gEhaTjOC3Zm6hjIKSd61iBmwsSPN/8MrOQq?= =?iso-8859-1?q?eSe2NW6JJMvAyMbTUug/rlcU9RtJ2sBq9/I+UzDuCR9sDR7ACpfH1KCWuAjn?= =?iso-8859-1?q?Gab8kVlriU2u1m8lGgfvc8TRidkj2rUXad1DggeCFxwXY4LditD7gSTWp7YN?= =?iso-8859-1?q?UWsiD2nCB4mN2pMe5mIiaPunJ0hHU5my1hjogYuKMNPZOHb7/l3AqaWRdgYW?= =?iso-8859-1?q?vXdTmjoHflEplcOz8jOlxVPCsvbid/Ormp4q/CrhalkyGGR/hj5VGA6T5bS3?= =?iso-8859-1?q?QWbN+yIFIENPise7RylYMD4uDLgQIO0cHt5LLKORYC7ZMywGDbqLQUt4yIdD?= =?iso-8859-1?q?ta6DesyWjdZYzoIGFwDbnYSpUQ+KDnMlWz7lFC7iIEr1ltZGKj5Q9c9/cV7Q?= =?iso-8859-1?q?pXA7JNpWYCv6kpWzZsXNDSKXZ2RQe14UiH4Cq/z/RRFZLVMwP3uArcax00lc?= =?iso-8859-1?q?asnPdfqMI9kdvx4SOxAmIljAQwAFKwVAf0qnjvXfiTbCWH4WuJvpUkux5iG/?= =?iso-8859-1?q?qEjZ93zhDla9RgCGl1Rei+ZA75w+SGEX/ik5zNdFdqJr8tw5PkrT+128aoNW?= =?iso-8859-1?q?bfgRSsHF8roX3Sql81cB8dr6ZAV/F5D0TjwotkkTsjejwIZnyPxYtlZqjLAp?= =?iso-8859-1?q?qY0fs+q8Zh3MvMih36FLZfFXROx8NmsheSk4/bl/rerb1KbTd86YmjSF6vrf?= =?iso-8859-1?q?Gk9YE25F24EMoUo4U6qkzM2uPkUZb7D4IXZNnWiLeCP59KHeNf7cmnv/lLAl?= =?iso-8859-1?q?7k0s=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: 2e6b22f0-f9d0-45e5-bb32-08d9dcb9f45c X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:27.5945 (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: r3EfhDW8H9Ig6jGZyWuvFNH9jnUprzA6nWRHp26I3D0d7dUE9AKE1aj8lIIsT1ABKprjl8B2hmuUKTBoyaM8KtvjRuixEbvZYCOXwvhfym4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.73 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Stat-Signature: cwh5x6i66du6tz5juw9jc8eesd75nzks X-Rspamd-Queue-Id: A905C2000B X-Rspamd-Server: rspam12 X-HE-Tag: 1642754549-806340 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: Since commit 555904d07eef ("powerpc/8xx: MM_SLICE is not needed anymore") only book3s/64 selects CONFIG_PPC_MM_SLICES. Move slice.c into mm/book3s64/ Move necessary stuff in asm/book3s/64/slice.h and remove asm/slice.h Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin --- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 + arch/powerpc/include/asm/book3s/64/slice.h | 18 ++++++++ arch/powerpc/include/asm/page.h | 1 - arch/powerpc/include/asm/slice.h | 46 ------------------- arch/powerpc/mm/Makefile | 1 - arch/powerpc/mm/book3s64/Makefile | 1 + arch/powerpc/mm/{ => book3s64}/slice.c | 2 - arch/powerpc/mm/nohash/mmu_context.c | 9 ---- arch/powerpc/mm/nohash/tlb.c | 4 -- 9 files changed, 20 insertions(+), 63 deletions(-) delete mode 100644 arch/powerpc/include/asm/slice.h rename arch/powerpc/mm/{ => book3s64}/slice.c (99%) diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h index 21f780942911..1c4eebbc69c9 100644 --- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h +++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h @@ -18,6 +18,7 @@ * complete pgtable.h but only a portion of it. */ #include +#include #include #include diff --git a/arch/powerpc/include/asm/book3s/64/slice.h b/arch/powerpc/include/asm/book3s/64/slice.h index f0d3194ba41b..5b0f7105bc8b 100644 --- a/arch/powerpc/include/asm/book3s/64/slice.h +++ b/arch/powerpc/include/asm/book3s/64/slice.h @@ -2,6 +2,8 @@ #ifndef _ASM_POWERPC_BOOK3S_64_SLICE_H #define _ASM_POWERPC_BOOK3S_64_SLICE_H +#ifndef __ASSEMBLY__ + #define SLICE_LOW_SHIFT 28 #define SLICE_LOW_TOP (0x100000000ul) #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) @@ -13,4 +15,20 @@ #define SLB_ADDR_LIMIT_DEFAULT DEFAULT_MAP_WINDOW_USER64 +struct mm_struct; + +unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, + unsigned long flags, unsigned int psize, + int topdown); + +unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr); + +void slice_set_range_psize(struct mm_struct *mm, unsigned long start, + unsigned long len, unsigned int psize); + +void slice_init_new_context_exec(struct mm_struct *mm); +void slice_setup_new_exec(void); + +#endif /* __ASSEMBLY__ */ + #endif /* _ASM_POWERPC_BOOK3S_64_SLICE_H */ diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index 254687258f42..62e0c6f12869 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -329,6 +329,5 @@ static inline unsigned long kaslr_offset(void) #include #endif /* __ASSEMBLY__ */ -#include #endif /* _ASM_POWERPC_PAGE_H */ diff --git a/arch/powerpc/include/asm/slice.h b/arch/powerpc/include/asm/slice.h deleted file mode 100644 index 0bdd9c62eca0..000000000000 --- a/arch/powerpc/include/asm/slice.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_POWERPC_SLICE_H -#define _ASM_POWERPC_SLICE_H - -#ifdef CONFIG_PPC_BOOK3S_64 -#include -#endif - -#ifndef __ASSEMBLY__ - -struct mm_struct; - -#ifdef CONFIG_PPC_MM_SLICES - -#ifdef CONFIG_HUGETLB_PAGE -#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA -#endif -#define HAVE_ARCH_UNMAPPED_AREA -#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN - -unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, - unsigned long flags, unsigned int psize, - int topdown); - -unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr); - -void slice_set_range_psize(struct mm_struct *mm, unsigned long start, - unsigned long len, unsigned int psize); - -void slice_init_new_context_exec(struct mm_struct *mm); -void slice_setup_new_exec(void); - -#else /* CONFIG_PPC_MM_SLICES */ - -static inline void slice_init_new_context_exec(struct mm_struct *mm) {} - -static inline unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr) -{ - return 0; -} - -#endif /* CONFIG_PPC_MM_SLICES */ - -#endif /* __ASSEMBLY__ */ - -#endif /* _ASM_POWERPC_SLICE_H */ diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index df8172da2301..d4c20484dad9 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile @@ -14,7 +14,6 @@ obj-$(CONFIG_PPC_MMU_NOHASH) += nohash/ obj-$(CONFIG_PPC_BOOK3S_32) += book3s32/ obj-$(CONFIG_PPC_BOOK3S_64) += book3s64/ obj-$(CONFIG_NUMA) += numa.o -obj-$(CONFIG_PPC_MM_SLICES) += slice.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o obj-$(CONFIG_PPC_COPRO_BASE) += copro_fault.o diff --git a/arch/powerpc/mm/book3s64/Makefile b/arch/powerpc/mm/book3s64/Makefile index 2d50cac499c5..af2f3e75d458 100644 --- a/arch/powerpc/mm/book3s64/Makefile +++ b/arch/powerpc/mm/book3s64/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_PPC_RADIX_MMU) += radix_hugetlbpage.o endif obj-$(CONFIG_SPAPR_TCE_IOMMU) += iommu_api.o obj-$(CONFIG_PPC_PKEY) += pkeys.o +obj-$(CONFIG_PPC_MM_SLICES) += slice.o # Instrumenting the SLB fault path can lead to duplicate SLB entries KCOV_INSTRUMENT_slb.o := n diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/book3s64/slice.c similarity index 99% rename from arch/powerpc/mm/slice.c rename to arch/powerpc/mm/book3s64/slice.c index 8a3ac062b71e..e4382713746d 100644 --- a/arch/powerpc/mm/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -692,7 +692,6 @@ void slice_init_new_context_exec(struct mm_struct *mm) bitmap_fill(mask->high_slices, SLICE_NUM_HIGH); } -#ifdef CONFIG_PPC_BOOK3S_64 void slice_setup_new_exec(void) { struct mm_struct *mm = current->mm; @@ -704,7 +703,6 @@ void slice_setup_new_exec(void) mm_ctx_set_slb_addr_limit(&mm->context, DEFAULT_MAP_WINDOW); } -#endif void slice_set_range_psize(struct mm_struct *mm, unsigned long start, unsigned long len, unsigned int psize) diff --git a/arch/powerpc/mm/nohash/mmu_context.c b/arch/powerpc/mm/nohash/mmu_context.c index 85b048f04c56..ccd5819b1bd9 100644 --- a/arch/powerpc/mm/nohash/mmu_context.c +++ b/arch/powerpc/mm/nohash/mmu_context.c @@ -317,15 +317,6 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next, */ int init_new_context(struct task_struct *t, struct mm_struct *mm) { - /* - * We have MMU_NO_CONTEXT set to be ~0. Hence check - * explicitly against context.id == 0. This ensures that we properly - * initialize context slice details for newly allocated mm's (which will - * have id == 0) and don't alter context slice inherited via fork (which - * will have id != 0). - */ - if (mm->context.id == 0) - slice_init_new_context_exec(mm); mm->context.id = MMU_NO_CONTEXT; mm->context.active = 0; pte_frag_set(&mm->context, NULL); diff --git a/arch/powerpc/mm/nohash/tlb.c b/arch/powerpc/mm/nohash/tlb.c index fd2c77af5c55..7e1e7c3dc66a 100644 --- a/arch/powerpc/mm/nohash/tlb.c +++ b/arch/powerpc/mm/nohash/tlb.c @@ -773,9 +773,5 @@ void __init early_init_mmu(void) #ifdef CONFIG_PPC_47x early_init_mmu_47x(); #endif - -#ifdef CONFIG_PPC_MM_SLICES - mm_ctx_set_slb_addr_limit(&init_mm.context, SLB_ADDR_LIMIT_DEFAULT); -#endif } #endif /* CONFIG_PPC64 */ From patchwork Fri Jan 21 08:42:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719504 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 C84E6C433FE for ; Fri, 21 Jan 2022 08:42:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 644E36B0095; Fri, 21 Jan 2022 03:42:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CB4F6B0096; Fri, 21 Jan 2022 03:42:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A9806B0098; Fri, 21 Jan 2022 03:42:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 2475A6B0095 for ; Fri, 21 Jan 2022 03:42:33 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D59FC181D75B4 for ; Fri, 21 Jan 2022 08:42:32 +0000 (UTC) X-FDA: 79053652944.28.286AE3D Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120040.outbound.protection.outlook.com [40.107.12.40]) by imf31.hostedemail.com (Postfix) with ESMTP id 43FD420005 for ; Fri, 21 Jan 2022 08:42:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kzv8/u7dDO+h0Zv91mJp2bjHy6aZqfquSj7oKA9GhKsS/6RdxRjkntBIWfH03FFzN9cr5fOUEa+QNITjWMx4np0+vzKSUbASp7hMH1N3bzElkJET3dzDkJUNpEoZojcRRDcC68r7aKF3zCl38HI5kM34aRStfJf5foH0FMtkVxT9/8+I24xVplYs8lkNvT21mJ1TJinC5SJDGz5WjV/6SjdiVRxiJNb/PuJIUB2Vd/a6Qmdcu7aaWJd/Lfhi1ILZGH+Dj3+3nqzNsUWt1/BqjHYy6LxCbLLdZ+wv52xe0NbgV/J5+yBu9U/yZ0tjwWh8VQ3MsOykdD0k6ff9Tti1TQ== 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=c4ZMB8Vck7S3/jJgq32uH59oM26CdkGvYggP93rU7ZM=; b=Hve2v48ZAsgr+62WKfgTuXLVK8UUvOyNybQMWDUN6L2AYvSqkhdAX3IxJ2AmJmMkonqxXCFYXpdQj9lFjXRbURBQv1zZci1CYMoq0s5IIqvaLDMQpeRS5q6QhBevhD8JAb9iBSbpIBsnoqhrcpsHS5PJ4Ns8jLnu1zK2qJlDDTTq6G7FOYBrLWhstQ9pTL3dPUrzR0xUePT+Ar4v7OkxlkNESOjLFEjf/5Yr4TICWgUwVSnNbflXIGWe+ApVTEnhk7uYzSg2IIGm30FDXgEPSlWhy8XWS3KQKup8QX2WjsX9LVjHVox+sw9XVR1zhu2jds+3LwYJYBF1h6GW2jZ+qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:30 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:30 +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" , Nicholas Piggin Subject: [PATCH v7 08/14] powerpc/mm: Remove CONFIG_PPC_MM_SLICES Thread-Topic: [PATCH v7 08/14] powerpc/mm: Remove CONFIG_PPC_MM_SLICES Thread-Index: AQHYDqLThRAIxqIg+06VQTsoIjJELg== Date: Fri, 21 Jan 2022 08:42:30 +0000 Message-ID: <3e4c787053bfe6f9d566711a8fc486d7235334c5.1642752946.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: d9ffe691-3a38-4df4-c949-08d9dcb9f626 x-ms-traffictypediagnostic: PR0P264MB0201:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4125; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6b+17K8DTYd/5xLQJY0NakDLf0+tOTJAzBwkxpsfKnmWBtW6fntv4YW2xkjT/hZ+kXjTXCF1AqGnFYzJBjAp4EfteDVmW1tV9CVcb19nlBsexZGm5jo3SKzXyxcd26b1vK1J5Vcy4QIAnyw4ogZGNbCazKIUJh10AmaAfoiwAzheYKUszWCQ5zNV3756/n7bxbVav5GApU2szpvRWlCnut4hs3YAmYMcSuzZ6XIOwHkXnzetFhrCXFsU7Le+1P4c+oWsax0WdRvscnfL2pRAASsHhwI+QbX7itlCIWCIauEU5cfw7OrfIidUFsh/H7DsQNpQcS0dWdS8fUnLkAy4yivs16bouc8zKlgnx0EF/C7O1z0ZzV7zd2yh1bKoo4JjGzqu4riCihQkucdPITVU3sgld2jYwM27s50fUIszD4misAprFrM3xP8dUq484pvjg6SOIK2nf7E+5I7/noMlzSJxDW9CKYzVAqYZ918g4v2UR3u/EoNluKrr6w0nEVLg3XHhmwGd+b6sXNkHOcVWWK/+m1ZbuGfd26H4l3UQsCelqOtWt0Y0SAWs3OJfijWQwW09AF28YvkTONFExMq8/Tp3wmjjxdSSMUTJlP+6hSTkTcGoeLWVS+KIi8/YYSPhv+4VxlxP0+PRHBl2VxUpf7252vjwPkcqhffiztL5wA/VzXn3xpB0z3t1hL1utSoTqpWlo9M/cLSo0fL2J3Prgw== 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?GqMOABsgUHgTGLkPVdh7LHq?= =?iso-8859-1?q?zz8Cvr8ILLDfwlp1P8rnstpMkj4t4EgwLnjDS5mYWpx69+qpBiCrzn102g1g?= =?iso-8859-1?q?bucqmjvEkArpvp7vLqjvmpN4TFMWKZShXcXMgBVD8UeOeQfNEy7qXilQa0qO?= =?iso-8859-1?q?q18Yjv7AwCVzcaP2rKVrmLQ/svFRDbLdwht5cLc/BkvSpo+8a1fPPxklP9p/?= =?iso-8859-1?q?DiqnWEQBu7cr1p4p5PRRgGgv1XWJmVH3nmCYGlfLQBqmkpkcSe4u2+MGiIBJ?= =?iso-8859-1?q?aArSZSo5u79Jw7oeePdEsz0sTol3TMywB8DOeLfMhybydL+f3M/YxdfnpE2+?= =?iso-8859-1?q?ublzRVM7TdIFfFbk2JSYWQwvLlodKIFo0Vstssg3DWNL7jjn6qthQVlF9Z7Q?= =?iso-8859-1?q?39MrM8sO1E7PvMqEK+ElKSys11dGkITSqSl0KTAm58zDMtVPGEdYMFXB831W?= =?iso-8859-1?q?J00s/iT3q2OvqoEYWpzpze+C5Ht0HDnmBuaT+NDRBp2YO19pfppvc7VNUjKX?= =?iso-8859-1?q?f8xWBmAccc705pB44rgLxYn+UG+Ex5Cjx7+0hEWx5CUnLytqjGlnU+GmmoU2?= =?iso-8859-1?q?MC3FN3+nRSs7xuaTHWe++N8+10H3gyOizbg+pMb0GZfP63aTJ9V+Y4RAqcRM?= =?iso-8859-1?q?NRADaqvxDmf/sWGN0nZfPbla3BLXfF8c21My6a0QtyiOoIpG3suIK4RgogWb?= =?iso-8859-1?q?1FkOgk+zJUDjFPtoBflibWP6C7x5B16C84DxLEgtgJAhGRfuW6cPOf4WEv2h?= =?iso-8859-1?q?oPTMIq6+fUb4ySt3ACi5LHUbpqejT/h5c32wHfLLJhV3l5fTxsHKDjcZMhix?= =?iso-8859-1?q?SgRU25M8P3oi5O3dtTqN6PRj7DcGcPsZtISmrTr95fRo94Piu/BPSi40trbO?= =?iso-8859-1?q?eQ40jzy9wT85ZB5OnlJKflAOhMzsb7HPtsUmH3mLUv4ZGH9lkQj6baj0RlGf?= =?iso-8859-1?q?AtNzbiB9ff/betwCMBWnxeelyUaxJThCGIgImObudAW6Z5ZmNqhZBFdW2Ata?= =?iso-8859-1?q?1FWIQj0hl6Rx26zdESug6h924+SArjQNzhJ45xbXvUDyf7HSdszVCTAUqgl4?= =?iso-8859-1?q?LT6S3me6EwUdZaVXVDPUn+HAtGFzukoDqgML6Vc0HZ1zQ8AhwxDJHsAWZBPN?= =?iso-8859-1?q?3IzKEaPJYRl7Px7Gkvy1P/gx4KDnsu9Gv5syCcCxGd+vX4wD64lw4ikwTkDj?= =?iso-8859-1?q?Jth5sZ4lj8Q2BYPJh706ohJlu/pjpdaHihUmNoL3FGGmP+oV8MWMN10qbhJh?= =?iso-8859-1?q?dDQZCqWcNjlIHlyVXRb/KAnQ1c+v37Jt8R77NqrC7Wlt131QcBEl67b0mrEO?= =?iso-8859-1?q?j6iJ7IN5QmAt9xEjaFtB2N6A3o36toS/gxpeA+Ww1vccrPfHasNegtmXWmJo?= =?iso-8859-1?q?/F9uk0qXPGlKuTsn+MhGC7Ey+IbcasFn0TAb3t8K3kd+9uAJVP6FVu+XN9ZA?= =?iso-8859-1?q?TTSESGqUI4x+BraptCMddyf4FJMJn5K86+Q5g0fcGtTZ5RcI5dXiF7WtYY8G?= =?iso-8859-1?q?ua0UYifZz9Ch3zeG4L+p393oFJt+yYx2No/NeW+FTdMiFRHGBJzo6PDYLLsE?= =?iso-8859-1?q?RmhvETaSV536TVuo3wP3pZeDfw9vUL8gA4Kb3Yq5nVeW14z37Y/StQEcnk6e?= =?iso-8859-1?q?DsXCef+UKp0WhJ0LubOALQB8xwszOqyaokYf2N9Zg6d4rc7CqUvyDh3EW6lk?= =?iso-8859-1?q?Z5GUNqcyX5Lq8F/pdFnlxzhiN26qMg9Vs2XYBw+jqHfLY6wW67t39qmxCGaI?= =?iso-8859-1?q?WbbI=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: d9ffe691-3a38-4df4-c949-08d9dcb9f626 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:30.6120 (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: lD6UlRQum4o89LyJzxfGlpiWXLiaqTuAx7pIyfz/dVEK2wPscf3jP+DC0sWJI//dcD0cmUfztSE1jyk3UhKDtJv4ZSGRsNiQDlFrl06AMXM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 43FD420005 X-Stat-Signature: or7ikwb6f44rz7skdcdarg4b4kmg5qc9 Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf31.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.40 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1642754552-892726 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: CONFIG_PPC_MM_SLICES is always selected by hash book3s/64. CONFIG_PPC_MM_SLICES is never selected by other platforms. Remove it. Signed-off-by: Christophe Leroy Reviewed-by: Nicholas Piggin --- arch/powerpc/include/asm/hugetlb.h | 2 +- arch/powerpc/include/asm/paca.h | 7 ------- arch/powerpc/kernel/paca.c | 5 ----- arch/powerpc/mm/book3s64/Makefile | 3 +-- arch/powerpc/mm/book3s64/hash_utils.c | 14 -------------- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/powerpc/mm/mmap.c | 4 ++-- arch/powerpc/platforms/Kconfig.cputype | 4 ---- 8 files changed, 5 insertions(+), 36 deletions(-) diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h index 962708fa1017..46e0b9dc77bf 100644 --- a/arch/powerpc/include/asm/hugetlb.h +++ b/arch/powerpc/include/asm/hugetlb.h @@ -24,7 +24,7 @@ static inline int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, unsigned long len) { - if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled()) + if (IS_ENABLED(CONFIG_PPC_64S_HASH_MMU) && !radix_enabled()) return slice_is_hugepage_only_range(mm, addr, len); return 0; } diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h index 295573a82c66..bd4dd02e61c8 100644 --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -152,16 +152,9 @@ struct paca_struct { struct tlb_core_data tcd; #endif /* CONFIG_PPC_BOOK3E */ -#ifdef CONFIG_PPC_BOOK3S #ifdef CONFIG_PPC_64S_HASH_MMU -#ifdef CONFIG_PPC_MM_SLICES unsigned char mm_ctx_low_slices_psize[BITS_PER_LONG / BITS_PER_BYTE]; unsigned char mm_ctx_high_slices_psize[SLICE_ARRAY_SIZE]; -#else - u16 mm_ctx_user_psize; - u16 mm_ctx_sllp; -#endif -#endif #endif /* diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 39da688a9455..ba593fd60124 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -344,15 +344,10 @@ void copy_mm_to_paca(struct mm_struct *mm) { mm_context_t *context = &mm->context; -#ifdef CONFIG_PPC_MM_SLICES VM_BUG_ON(!mm_ctx_slb_addr_limit(context)); memcpy(&get_paca()->mm_ctx_low_slices_psize, mm_ctx_low_slices(context), LOW_SLICE_ARRAY_SZ); memcpy(&get_paca()->mm_ctx_high_slices_psize, mm_ctx_high_slices(context), TASK_SLICE_ARRAY_SZ(context)); -#else /* CONFIG_PPC_MM_SLICES */ - get_paca()->mm_ctx_user_psize = context->user_psize; - get_paca()->mm_ctx_sllp = context->sllp; -#endif } #endif /* CONFIG_PPC_64S_HASH_MMU */ diff --git a/arch/powerpc/mm/book3s64/Makefile b/arch/powerpc/mm/book3s64/Makefile index af2f3e75d458..d527dc8e30a8 100644 --- a/arch/powerpc/mm/book3s64/Makefile +++ b/arch/powerpc/mm/book3s64/Makefile @@ -5,7 +5,7 @@ ccflags-y := $(NO_MINIMAL_TOC) obj-y += mmu_context.o pgtable.o trace.o ifdef CONFIG_PPC_64S_HASH_MMU CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE) -obj-y += hash_pgtable.o hash_utils.o hash_tlb.o slb.o +obj-y += hash_pgtable.o hash_utils.o hash_tlb.o slb.o slice.o obj-$(CONFIG_PPC_HASH_MMU_NATIVE) += hash_native.o obj-$(CONFIG_PPC_4K_PAGES) += hash_4k.o obj-$(CONFIG_PPC_64K_PAGES) += hash_64k.o @@ -21,7 +21,6 @@ obj-$(CONFIG_PPC_RADIX_MMU) += radix_hugetlbpage.o endif obj-$(CONFIG_SPAPR_TCE_IOMMU) += iommu_api.o obj-$(CONFIG_PPC_PKEY) += pkeys.o -obj-$(CONFIG_PPC_MM_SLICES) += slice.o # Instrumenting the SLB fault path can lead to duplicate SLB entries KCOV_INSTRUMENT_slb.o := n diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index 7abf82a698d3..154a5a860959 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -1264,7 +1264,6 @@ unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap) return pp; } -#ifdef CONFIG_PPC_MM_SLICES static unsigned int get_paca_psize(unsigned long addr) { unsigned char *psizes; @@ -1281,12 +1280,6 @@ static unsigned int get_paca_psize(unsigned long addr) return (psizes[index >> 1] >> (mask_index * 4)) & 0xF; } -#else -unsigned int get_paca_psize(unsigned long addr) -{ - return get_paca()->mm_ctx_user_psize; -} -#endif /* * Demote a segment to using 4k pages. @@ -1710,7 +1703,6 @@ DEFINE_INTERRUPT_HANDLER_RAW(do_hash_fault) return 0; } -#ifdef CONFIG_PPC_MM_SLICES static bool should_hash_preload(struct mm_struct *mm, unsigned long ea) { int psize = get_slice_psize(mm, ea); @@ -1727,12 +1719,6 @@ static bool should_hash_preload(struct mm_struct *mm, unsigned long ea) return true; } -#else -static bool should_hash_preload(struct mm_struct *mm, unsigned long ea) -{ - return true; -} -#endif static void hash_preload(struct mm_struct *mm, pte_t *ptep, unsigned long ea, bool is_exec, unsigned long trap) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 0eec3b61bd13..f18b3a1d18f0 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -558,7 +558,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, return radix__hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); #endif -#ifdef CONFIG_PPC_MM_SLICES +#ifdef CONFIG_PPC_64S_HASH_MMU return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); #endif BUG(); diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index c475cf810aa8..9b0d6e395bc0 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -190,7 +190,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long pgoff, unsigned long flags) { -#ifdef CONFIG_PPC_MM_SLICES +#ifdef CONFIG_PPC_64S_HASH_MMU return slice_get_unmapped_area(addr, len, flags, mm_ctx_user_psize(¤t->mm->context), 0); #else @@ -204,7 +204,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, const unsigned long pgoff, const unsigned long flags) { -#ifdef CONFIG_PPC_MM_SLICES +#ifdef CONFIG_PPC_64S_HASH_MMU return slice_get_unmapped_area(addr0, len, flags, mm_ctx_user_psize(¤t->mm->context), 1); #else diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 87bc1929ee5a..c775b566e7b4 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -376,7 +376,6 @@ config SPE config PPC_64S_HASH_MMU bool "Hash MMU Support" depends on PPC_BOOK3S_64 - select PPC_MM_SLICES default y help Enable support for the Power ISA Hash style MMU. This is implemented @@ -450,9 +449,6 @@ config PPC_BOOK3E_MMU def_bool y depends on FSL_BOOKE || PPC_BOOK3E -config PPC_MM_SLICES - bool - config PPC_HAVE_PMU_SUPPORT bool From patchwork Fri Jan 21 08:42:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719505 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 0B5A3C433F5 for ; Fri, 21 Jan 2022 08:42:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 668686B0098; Fri, 21 Jan 2022 03:42:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 619036B0099; Fri, 21 Jan 2022 03:42:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B9E16B009A; Fri, 21 Jan 2022 03:42:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id 366CA6B0098 for ; Fri, 21 Jan 2022 03:42:36 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EE7988F147 for ; Fri, 21 Jan 2022 08:42:35 +0000 (UTC) X-FDA: 79053653070.15.F79BB8E Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120059.outbound.protection.outlook.com [40.107.12.59]) by imf18.hostedemail.com (Postfix) with ESMTP id 4F9641C0007 for ; Fri, 21 Jan 2022 08:42:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e+Kyvz1CW6FHjb5CKxfXYIFXDKyuQ9xh5bK48M45PncUSVJRFVFBgpN/MelvWCY6K5k+2R9jpZHYniIvTkRzFf66l38uJBgyl2bhFkdSTE+zma9fVW8/4zO3GLOdEnMDsdp5Rc27IJpqQcrD/Ut8N4kx5S1UlFxjpkAFG80wQpJjFIHFg/RNkMsql7uYgEFQvCmH2irKsHBtq9/c49zvUyrpaKkEDtqAmiwxjKHt8DqQTz1ccEymZ9kjMPEEF3be15LOW3n9LQywNDDGGSLOcKtH8W/uqerii/0DKmfo7tivOqZ4mj0Mgoo1f3Q69rGOYF5mldJhFmVAbGhCB+eYWw== 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=1R9HXl3qYoGwoSieVkCnAD5XaAJlrCyaK/qBHE9jM9o=; b=NGowRYhyNpcTMfMK3cnTDqVwjaJDziyTZRDiQLhcY8v04eFKPbEIu9E0vMTzKwwmb8oWC8UdYteCHRnzNUrgIniYaD4bXkoeAe/fw2SfyiWl+C6pR4Lu6qgUHGqvpFGy2jRklC8AlnoMLirNKk8Nqsqv83d7J597ofxjrx0QcoC20WGD43NpD4YdcwcG1ZKL6LcA0mOVK4ywe+pB/oF15wdFpFG/Qp+Qj7cob+Q/nkdyB+p6I5VRTYfmltuNlkc9QQnLBAD5Rl2tyZ3LGSD8h0gkLFo8X+evHqYQZfpQmXmfRIDtYseW+I4/0tMaHEdT9Sy2hZ6IZloOWepxaZKahw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:33 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:33 +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 v7 09/14] powerpc/mm: Use generic_get_unmapped_area() and call it from arch_get_unmapped_area() Thread-Topic: [PATCH v7 09/14] powerpc/mm: Use generic_get_unmapped_area() and call it from arch_get_unmapped_area() Thread-Index: AQHYDqLVm5veIrfhK0GUQ6geY45hSw== Date: Fri, 21 Jan 2022 08:42:33 +0000 Message-ID: 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: 19fad9a6-63e4-47fa-1fe4-08d9dcb9f806 x-ms-traffictypediagnostic: PR0P264MB0201:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kS0v/eP8lnKJxpNHH05Z3vXZLeNmHaltx4fNWVRvAnvgZNkXEBrefXqiXWUvFyJhMu7c2CDCyriykSCsSpNBBbm5qn5dKWx6x71EddjxQL9Lt/9BUb0mMqOJbPybx5xds4IBv5yJ+FJwAXXpcuHtLoSnbgSh+vN8ga7gXSAUKUYjKU2LjlWvrIgMGKHK8ZJQ9enwZrXwKv7ldlGKUisLG1cYuXAnx0GW7gE2rkb76kcGDXnv9uMRFF7Ds0jp1lE99tgV9UzkjP7U0G4IEhMfCE9qLOtsRm0zcxiLbqS7T1kZX1oRfsmkiK4sSz79Gu2VMGUQMBxJDVd8I120xKgBKjdqeFVeHuMi4ev6HIAXllOMcVFhZ5ulNx6aN8nKQNRhJy3WrbVLF439p6W3N6sXu0Azm3G+j+iy/s8rcvxEwScCWjfK2/oYdMBty9X+kb9RgTaNsytxOwwS7lUbqIu0xc8DT7z0AsECHQP/H4H+eAfc3w9lDu4Pu2BNjKeGm7kDSyy1ro2YL2EJw77uFY6VjVIDDw8cUmBl2BfOLyj8mrjablKDwHKiO2bKLVtrS7vMCFUTn3q3ts47aSrzDOWIowMD0bEJ7sovAOUKU6kT+oQ5fUILdn/yHYIdzJ3CSWcBo4115I1HEJp3AxTpNv+uoW1FUyHoJ2pLcOjTLUE9ggvDBKouNFXdKSjFXUPCkuueq9mJJM+fxAF6XJXWid3i97xrTclfNl2OLWP+b5B0hvw= 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002)(41533002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?ia+kquVdA8s2z6JirQGURGl?= =?iso-8859-1?q?s6h3XGqet30Chvjw+FGdDpGF90fms556Myk7PUWSe0B0UXIb5tIm4uKJDUmI?= =?iso-8859-1?q?wzHJcfKDFPok8c/y/QXEBl1ovE7fWQnGK8rh+uXq0YSRVeTsUOVuy5oaoAqX?= =?iso-8859-1?q?kgIOjg31gAJ8FSdbBH67cLOEJDR12mFTBs0McmQgNtLtFLvzdMpbfs1A4cLW?= =?iso-8859-1?q?iTmnu0VeJFDeAnb74tS4JtpzuL7+vjKErX0HqjcHWeUhI1hwUN4HbhAbe1sI?= =?iso-8859-1?q?Y/A0e8ZqS6jXJBTMLxR5Reh8CRlaSwBZWhdPu4DrqKaxOFTRDmrKLMIXl3zE?= =?iso-8859-1?q?DviM1wobscX08Hq0c8OVP+hHp1fcxZKZs2y0vUXOHquVXlxNTqqaHAw8El6i?= =?iso-8859-1?q?ae1ktySuzq909eG9woVa7JvaPBUNE06xqbLfgO+YBJiffyNvSY3J2vhCpgeS?= =?iso-8859-1?q?LqSJjgAWuAAegNZ8F2B0fGiTaJS+ZmcGae1LtLNugqUZZj5oX+T/H3IpN0nN?= =?iso-8859-1?q?GVhlJ1CVUOLavStMvotQrjqtrSgvuO62NDIh6IKp1KEBaU5eJK+/VbY/Zr64?= =?iso-8859-1?q?zbXCWl8MWykSaVNy6qXiHouH2U0nZPYubSQjOofEVz4mnxXjXwc5Y05NH8f4?= =?iso-8859-1?q?KOZy0x7h4A4jOyhNtkcnRsge1O86bQPazFyvGojFxA9qjf09ZddI5actE04Z?= =?iso-8859-1?q?L1Y7/ZmJ4/gH/E+53xoFX60Rp6Ftq1/FiEubZuFRezdQy1i2VbM035n7Z8u1?= =?iso-8859-1?q?CqPi0uRdCS1KT4Sj9PCbagT9dgOsaS1av5lFHg6on+NwVMT5CRB4ReD095tY?= =?iso-8859-1?q?E5jW50fltp//2z2z4fJtPDux0lsBxUElkM8p8/minB7pSxu1fF4qXzoqgFv7?= =?iso-8859-1?q?Y9nqIHRkYD61frd5ZSol7pmsK6zHHkPP2WE5GQtOrmkiyt7NgueN3dZcGVcG?= =?iso-8859-1?q?dOCW5hCYQ3IFVxqD9sNMOHrnj1J13pHgl96/0HaT7WmILwsFF5dHgkr3g24M?= =?iso-8859-1?q?kWL8JRlBfYU3XgjMkzDrWCJr++t/eR/qqpotXIxzH6Hq4HtkYbSA/3xS+6Jp?= =?iso-8859-1?q?LvRoavfLr/Aue+bB5nofbxZf03x6zdEhcu+v8EZ8IY9z9m5GOPZuQt8kmWuw?= =?iso-8859-1?q?dhp7oaeZUAX7lp8TbpEGLtcq6MIYqojDcNKChv7VfBCt3q1XL2rRwZxkBDc4?= =?iso-8859-1?q?yii76r8A5vUY5Di92dJ2BaI5+ySIJ7NqC9maW0xommA9Bd7fh5n9t3g2A+B+?= =?iso-8859-1?q?Yv62oBip3FG3PN0JI2xmOiKy8qBlcdx02uyhINLaPpBvaUb5Q0GQK+t5VdAd?= =?iso-8859-1?q?tR5RT3RCL7v63hMu40elRYY9Bg74k7jyfM795QWVB7eYQz914sF9v+fmdRcG?= =?iso-8859-1?q?9Udv2omaK3/Lzm94zggXoBJTA49aeRBJAhZAbPEgzM9xrHUaVStZt/KdWq2p?= =?iso-8859-1?q?r93h/OJxOKqnivmeq3O61heAjZl+9wngPUJyNHvnjo6JFH+XJ5g7CQPJN8KJ?= =?iso-8859-1?q?Teyy/Eqx/P1umJnnniUF01HUawXr5eLR3vCYfidESlxgQRYbZw/BSmcsJ0sS?= =?iso-8859-1?q?B0CoHfZOIscDySF6GtSNRXZkt1Hi9DyHOUybLlkQQcspjq/BbIUU0BKkVlUc?= =?iso-8859-1?q?g6jyWbawL+j4zU6Dh4qixSxomxXwPIOv4PFaQrQoRlyj8iIp7G0ix5xQ/F8J?= =?iso-8859-1?q?S2qH2WVZggM7c0q14rCrZzuKToCi4Y6HoKZw43kio2wYESgZmBp4VikcK6zD?= =?iso-8859-1?q?l7M4=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: 19fad9a6-63e4-47fa-1fe4-08d9dcb9f806 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:33.6909 (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: 8Umo8CPIWc9oXF7wzgCLBSs3WLFBuP12r+u8GN7cM+Vdgf51XSkF09jm/4WuE5evnr1pCjVkPc9kHi2HgZylwS1KKbok+sIP7QxWsWgELjE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4F9641C0007 X-Stat-Signature: 6u84ahh7f9unj9itx14ggq75h65juaun Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.59 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1642754555-12675 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: Use the generic version of arch_get_unmapped_area() which is now available at all time instead of its copy radix__arch_get_unmapped_area() To allow that for PPC64, add arch_get_mmap_base() and arch_get_mmap_end() macros. Instead of setting mm->get_unmapped_area() to either arch_get_unmapped_area() or generic_get_unmapped_area(), always set it to arch_get_unmapped_area() and call generic_get_unmapped_area() from there when radix is enabled. Do the same with radix__arch_get_unmapped_area_topdown() Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/task_size_64.h | 8 ++ arch/powerpc/mm/mmap.c | 127 ++---------------------- 2 files changed, 14 insertions(+), 121 deletions(-) diff --git a/arch/powerpc/include/asm/task_size_64.h b/arch/powerpc/include/asm/task_size_64.h index 38fdf8041d12..5a709951c901 100644 --- a/arch/powerpc/include/asm/task_size_64.h +++ b/arch/powerpc/include/asm/task_size_64.h @@ -72,4 +72,12 @@ #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, base) \ + (((addr) > DEFAULT_MAP_WINDOW) ? (base) + TASK_SIZE - DEFAULT_MAP_WINDOW : (base)) + +#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) + #endif /* _ASM_POWERPC_TASK_SIZE_64_H */ diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 9b0d6e395bc0..46781d0103d1 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -81,115 +81,15 @@ static inline unsigned long mmap_base(unsigned long rnd, } #ifdef HAVE_ARCH_UNMAPPED_AREA -#ifdef CONFIG_PPC_RADIX_MMU -/* - * Same function as generic code used only for radix, because we don't need to overload - * the generic one. But we will have to duplicate, because hash select - * HAVE_ARCH_UNMAPPED_AREA - */ -static unsigned long -radix__arch_get_unmapped_area(struct file *filp, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - int fixed = (flags & MAP_FIXED); - unsigned long high_limit; - struct vm_unmapped_area_info info; - - high_limit = DEFAULT_MAP_WINDOW; - if (addr >= high_limit || (fixed && (addr + len > high_limit))) - high_limit = TASK_SIZE; - - if (len > high_limit) - return -ENOMEM; - - if (fixed) { - if (addr > high_limit - len) - return -ENOMEM; - return addr; - } - - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma(mm, addr); - if (high_limit - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } - - info.flags = 0; - info.length = len; - info.low_limit = mm->mmap_base; - info.high_limit = high_limit; - info.align_mask = 0; - - return vm_unmapped_area(&info); -} - -static unsigned long -radix__arch_get_unmapped_area_topdown(struct file *filp, - const unsigned long addr0, - const unsigned long len, - const unsigned long pgoff, - const unsigned long flags) -{ - struct vm_area_struct *vma; - struct mm_struct *mm = current->mm; - unsigned long addr = addr0; - int fixed = (flags & MAP_FIXED); - unsigned long high_limit; - struct vm_unmapped_area_info info; - - high_limit = DEFAULT_MAP_WINDOW; - if (addr >= high_limit || (fixed && (addr + len > high_limit))) - high_limit = TASK_SIZE; - - if (len > high_limit) - return -ENOMEM; - - if (fixed) { - if (addr > high_limit - len) - return -ENOMEM; - return addr; - } - - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma(mm, addr); - if (high_limit - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } - - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = max(PAGE_SIZE, mmap_min_addr); - info.high_limit = mm->mmap_base + (high_limit - DEFAULT_MAP_WINDOW); - info.align_mask = 0; - - addr = vm_unmapped_area(&info); - if (!(addr & ~PAGE_MASK)) - return addr; - VM_BUG_ON(addr != -ENOMEM); - - /* - * A failed mmap() very likely causes application failure, - * so fall back to the bottom-up function here. This scenario - * can happen with large stack limits and large mmap() - * allocations. - */ - return radix__arch_get_unmapped_area(filp, addr0, len, pgoff, flags); -} -#endif - unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { + if (radix_enabled()) + return generic_get_unmapped_area(filp, addr, len, pgoff, flags); + #ifdef CONFIG_PPC_64S_HASH_MMU return slice_get_unmapped_area(addr, len, flags, mm_ctx_user_psize(¤t->mm->context), 0); @@ -204,6 +104,9 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, const unsigned long pgoff, const unsigned long flags) { + if (radix_enabled()) + return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); + #ifdef CONFIG_PPC_64S_HASH_MMU return slice_get_unmapped_area(addr0, len, flags, mm_ctx_user_psize(¤t->mm->context), 1); @@ -213,21 +116,6 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, } #endif /* HAVE_ARCH_UNMAPPED_AREA */ -static void radix__arch_pick_mmap_layout(struct mm_struct *mm, - unsigned long random_factor, - struct rlimit *rlim_stack) -{ -#ifdef CONFIG_PPC_RADIX_MMU - if (mmap_is_legacy(rlim_stack)) { - mm->mmap_base = TASK_UNMAPPED_BASE; - mm->get_unmapped_area = radix__arch_get_unmapped_area; - } else { - mm->mmap_base = mmap_base(random_factor, rlim_stack); - mm->get_unmapped_area = radix__arch_get_unmapped_area_topdown; - } -#endif -} - /* * This function, called very early during the creation of a new * process VM image, sets up which VM layout function to use: @@ -239,9 +127,6 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) if (current->flags & PF_RANDOMIZE) random_factor = arch_mmap_rnd(); - if (radix_enabled()) - return radix__arch_pick_mmap_layout(mm, random_factor, - rlim_stack); /* * Fall back to the standard layout if the personality * bit is set, or if the expected stack growth is unlimited: From patchwork Fri Jan 21 08:42:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719506 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 3D6CFC433EF for ; Fri, 21 Jan 2022 08:42:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF80E6B009C; Fri, 21 Jan 2022 03:42:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CA81B6B009D; Fri, 21 Jan 2022 03:42:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B222B6B009E; Fri, 21 Jan 2022 03:42:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id A2B926B009C for ; Fri, 21 Jan 2022 03:42:39 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6793392E09 for ; Fri, 21 Jan 2022 08:42:39 +0000 (UTC) X-FDA: 79053653238.19.30DE456 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120070.outbound.protection.outlook.com [40.107.12.70]) by imf13.hostedemail.com (Postfix) with ESMTP id DC75E2000C for ; Fri, 21 Jan 2022 08:42:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RaSaWOzNJ1qUnZzZSd/rT7GRRlJdamAYAQrA/e97Kz8PTAcIVbVwhUJe8+p705MrYmjcoy9lEP1ozLFJuhdLM5NN7h1ZoBs/6mij+o/6kbr2kM9nz8x6IPseOw4l/NyiessXZxrb8AxQBSnX0WxfTfmzdSyPV1qzJUv/P7mJ8lN587M3ySLW8Bf+rLmRpu4bGcAhE06+3V71Z/rI67ihK43xeo4JwqMTQhnoZO5gO9RNlFU3bQHixcIqiTO6sjwX44ZUYmUs4c8uQ2mzJgLHmKXeqgsEnje6fiqygx+Rs0AkCLh/r0qH++2/LevUGSRKN0uEzQnFaxQtylBGioxosQ== 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=Ao0J4RtTmJCD5YE4NNN5icIYyoHVg3j5QWKaKWYo9c4=; b=Me+CTu0tV+B3uEIJznYO1Hb86VIDcoIwe6gyMitIdJnINY9lXfj5tObOu43UTnuGVnheCRRpdGiGVliG65429SJTW1i/4TeyAMBpQp28Hkgkmw1ZE+uyQodv7N/SAkgtPElwmOEP5iL09VTEciB05PPHmIFYY/GFfMhREQaxYd5UsHcBj6GRSLoSS2f+6FUTSzO9/LjY79WCTNtzDJxKtjjKsigUZxL3ox72/gzkEQvdjcW+fAIjNvKw46RC8iP/gVBBpnFfFLES9EBXPZiJ4xdCZivQeT89V9xuWizFkiKsgc/WYE7USd7GysMgxDtLShdyEAEYcYbT4wr/PmiNhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:36 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:36 +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 v7 10/14] powerpc/mm: Use generic_hugetlb_get_unmapped_area() Thread-Topic: [PATCH v7 10/14] powerpc/mm: Use generic_hugetlb_get_unmapped_area() Thread-Index: AQHYDqLXMEbHY05GpUKmQZyc8qN6vA== Date: Fri, 21 Jan 2022 08:42:36 +0000 Message-ID: <976bb751596336cce4f86563b45e0d41ff208235.1642752946.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: d04c83fe-cd71-4cc3-59c4-08d9dcb9f9c6 x-ms-traffictypediagnostic: PR0P264MB0201:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:246; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /mpoP28VLpqE3CIMeVvEbX4q9ooDSIp+5ghBzLK9ZYq4wfIXaqQHsu0pAU9ipkqFMijsIcWLssaytmuP8JQ/z8plXkev88ihl4VJgKLSTN1/D1dQJ2rGyi6Oyu1zgijyiB04ukyB7iVScuLNfsZ3f/A4T0Ao8S/+Lcu0nCx/naPhrZEqPT++QesZ4RzepMM/JJ+43qqHnhM/Tm7G2Hla3Pydwm6bXmV7pJLgp10USew5R4xybWR9LCspvSKpIL+F3faGBSkWJkLZKSJima1bIwzaWwK255ve4vZLJr1U9Pi48rbZP3xj7fj9h3QFQ+rxE/bDsJaOq9nlRITMQoIzCFa9cRjjQUgqt7DLm48Bx8KWROZFhetBAa32aMutY4WYMgXuHOBZs69Xt27gHvu7I8tNDhsR9l7Wye7dhdGlXYrZaa32ByI47HpI6ijIlWOaOAsuiNtHRbCVBFd8QPuEgSuvkW7SpOUnjahlYzl/P9mlzpGjT1jeSdn2p5Ecr0egGp2UcwTn3v6tHmYfE7ykQl74HGFwI+u1qhEqlMNsdQ/xL3kc/jX4zNthMvhUNCtTk8Qg6octS3CBavVMDpvnVprPn1hcTOeopeF98jL0XcJnTJvFwBlOWUHFy+pzt1ir5IHS31tppr8L/oisnMw/IvGKBF7l+9y9uz208KmVVFd1JyYAdOhdPLtdC7bSDJwFnL5MEtth2Dhto6wP4zt+i8te7xxcCOaB4O+FIdOa3gw= 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002)(41533002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?xBpUYKcSl0eLuLm2UVpm1Kr?= =?iso-8859-1?q?uHo1g3ATLjBZGBrQZtP2t9//9KYocTXKV5uZhp1F3NltM/HXUQ/DTD/8AqzU?= =?iso-8859-1?q?IDGt9RGEdw158qWXMtF6PhlL+Qv3ojeCj+JoPjpn6gZyCLFQWR2qZf8TrlPR?= =?iso-8859-1?q?2OULA+n1tUMdObLPP8WlRcBWyac/KjUOTQ+NDctTHHuN7mJtbazRCNoxR/Zp?= =?iso-8859-1?q?HKrR9I1M11tU76TaGfd7Y480/T0NABezjH0Xy0nG5//VOK9wm3SyHxTg0ttB?= =?iso-8859-1?q?CmnqQDrjjWzSfGPDBwUK/NnHE28VOhNQeG91XMrUP2rRZbBSNtCW0P7lGuq/?= =?iso-8859-1?q?CwznLjSjeFzs2kQYXIl0whprNz+RbwGK9epXyJI/w97OeIXXd67C9tY2zNwX?= =?iso-8859-1?q?83ga5XrxhTQ//icp35xWRy8QboUCfbxMgHLuu/ZBEcKMBMHH4ccGRZoo7LvV?= =?iso-8859-1?q?sYUyJlYIlnjeXIy66tCYML+HhWRUogWX8OJg60JeRhCZnw0VqRque+JgNRX1?= =?iso-8859-1?q?lgu+mLno6TfRZOYaemxk4hIklOZlN+SEdo9/ljEJTqVEajcesgzqxgFM5mN6?= =?iso-8859-1?q?tJwHzuu6j346OqU3yzADmrybG6zhAexgJaTqKYPLRIcUrXcaz4WcBob/WHdb?= =?iso-8859-1?q?yWIQsorE/jtsCvDzIZ4KeZ193SRNcDV+0TxjpDgYevqoUH/f79WFjyEQSt2X?= =?iso-8859-1?q?orCmgVXGPdAx86smp5Z+Q7moHEz/dlWX9+IW6rq/lMaNkOfFqE8+dVeUDXPJ?= =?iso-8859-1?q?T/ZsdQ5hm7Qy1cHDDc8ar4LMr6isK4577DU3yVneNMw9PLfE30L98H/9/OZ1?= =?iso-8859-1?q?jMrm5l/nEBazsvTdir6FBu5OBsCC/qmge+o/EEhj+22uBizt6avfos3D3NHK?= =?iso-8859-1?q?1cbrLbmO/QQYAQDWwyD/MKRFOYyPtOji9HAgxcYEonf2JV4TqcttdR83LTrD?= =?iso-8859-1?q?mU+pH0jU7JUlUM/5SUWBVrqnEYpNkjGV+WnrVK/i0qehzshWyww5H8Lw1cH8?= =?iso-8859-1?q?ocgd0sFyDvZP/Kl12dB3kLXj7VSGD9X99x4UQS5YqSjkWjdxCB/MhF6tys/O?= =?iso-8859-1?q?HR1NZY8o09VAa1lS27KHVDecTmeMLd33B98Ql0s4/Z+jSI8oUiOIh5wUrvdA?= =?iso-8859-1?q?kJIzZlR+bVzXdPqVWW4RKFT0EWszngJ8w+ali4kAIJeIQZbOlG8d19Sp5Hx5?= =?iso-8859-1?q?j0P5AMEV1JxpEhtvDWMXTrRhk+U4DL1eUMF3wJjRiKcXV/jTUqEeTUDvBUQR?= =?iso-8859-1?q?ZdxUwCdLssYvWnWqkYUFShE7jobQvX110d1t0nZIRAFPkTixFtYLl1mteNH6?= =?iso-8859-1?q?/kcB/Bm+Eu07qg/tClkHzl1RVKBvtnJCwU6Q/5M3JdOI7GHUJ//bxJRvn3u9?= =?iso-8859-1?q?3lCTjyVDUcb4+Rvw+nAPDqUSaV/l1YBJM6+rTpdFvlq7XT1EAzP1Hb1lsCux?= =?iso-8859-1?q?EHeZABGZvElc2StlrvnCZG6YumBjX/PlkYyVg0lobtZoQ/3U2quEFZbuQVQm?= =?iso-8859-1?q?uRM57QK4NK71OlnkXwTfzTWbRVjx6j1QSCD8IhXOm37stcWJQb0pBHzYFWi3?= =?iso-8859-1?q?+wv1Y2lZkbPyH4vW8iWaweGfSqj5exoFcj1qBLhqIJi8BN4Tjhb9N6gSLM7T?= =?iso-8859-1?q?7bvZX638KE2Bffg43OdkiuEj58S6+J3MiDaST81Mezhrerjh4HO9PpaEwA52?= =?iso-8859-1?q?qpJb42wlybwrsNy8/QOHmsI/XE4+I1h5g7YKrc5MF8ltbru1/bZ+xdzhZtjP?= =?iso-8859-1?q?rOm8=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: d04c83fe-cd71-4cc3-59c4-08d9dcb9f9c6 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:36.6619 (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: U0bS/Z/16FoEPR5XZ93MvwjJ+rsOuDqyPVsSFEVAkolK8iK5hJMTivh2t1dJ8Uq9bu7FJVoTsYnm2DbfB7/3oyY8T7QiAW2ee6Avv2ILzTg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DC75E2000C X-Stat-Signature: rxfa5a73s9smm1xwddue38y8m1bjj1py Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf13.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.70 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1642754558-528967 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: Use the generic version of arch_hugetlb_get_unmapped_area() which is now available at all time. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/64/hugetlb.h | 4 -- arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 55 -------------------- arch/powerpc/mm/hugetlbpage.c | 4 +- 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h b/arch/powerpc/include/asm/book3s/64/hugetlb.h index 12e150e615b7..b37a28f62cf6 100644 --- a/arch/powerpc/include/asm/book3s/64/hugetlb.h +++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h @@ -8,10 +8,6 @@ */ void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); -extern unsigned long -radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags); extern void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, diff --git a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c index 23d3e08911d3..d2fb776febb4 100644 --- a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c +++ b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c @@ -41,61 +41,6 @@ void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma, unsigned long st radix__flush_tlb_range_psize(vma->vm_mm, start, end, psize); } -/* - * A vairant of hugetlb_get_unmapped_area doing topdown search - * FIXME!! should we do as x86 does or non hugetlb area does ? - * ie, use topdown or not based on mmap_is_legacy check ? - */ -unsigned long -radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - struct hstate *h = hstate_file(file); - int fixed = (flags & MAP_FIXED); - unsigned long high_limit; - struct vm_unmapped_area_info info; - - high_limit = DEFAULT_MAP_WINDOW; - if (addr >= high_limit || (fixed && (addr + len > high_limit))) - high_limit = TASK_SIZE; - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (len > high_limit) - return -ENOMEM; - - if (fixed) { - if (addr > high_limit - len) - return -ENOMEM; - if (prepare_hugepage_range(file, addr, len)) - return -EINVAL; - return addr; - } - - if (addr) { - addr = ALIGN(addr, huge_page_size(h)); - vma = find_vma(mm, addr); - if (high_limit - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } - /* - * We are always doing an topdown search here. Slice code - * does that too. - */ - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = max(PAGE_SIZE, mmap_min_addr); - info.high_limit = mm->mmap_base + (high_limit - DEFAULT_MAP_WINDOW); - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - info.align_offset = 0; - - return vm_unmapped_area(&info); -} - void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t old_pte, pte_t pte) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index f18b3a1d18f0..bfd7f4af1e58 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -553,11 +553,9 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { -#ifdef CONFIG_PPC_RADIX_MMU if (radix_enabled()) - return radix__hugetlb_get_unmapped_area(file, addr, len, + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); -#endif #ifdef CONFIG_PPC_64S_HASH_MMU return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); #endif From patchwork Fri Jan 21 08:42:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719507 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 9850AC433EF for ; Fri, 21 Jan 2022 08:42:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35AF96B009F; Fri, 21 Jan 2022 03:42:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 30B466B00A0; Fri, 21 Jan 2022 03:42:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AC976B00A1; Fri, 21 Jan 2022 03:42:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 0A09C6B009F for ; Fri, 21 Jan 2022 03:42:43 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C156C181D75B4 for ; Fri, 21 Jan 2022 08:42:42 +0000 (UTC) X-FDA: 79053653364.28.0364A1B Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120057.outbound.protection.outlook.com [40.107.12.57]) by imf06.hostedemail.com (Postfix) with ESMTP id 3C50C18000E for ; Fri, 21 Jan 2022 08:42:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gpNTen02C54xig4Yw04LcbDg0a3G5H8CUmOalUT8BkQlga4uER3XSXO7ycLV3SrbNtHdg4TXYUdfxBLKYpqYRVxeiqVXTGZ33AMHM14auWV85FzuGqjIh0DODLsOpQXYyvq9bwafxl6dS9ZJD6WnPSi9kbP1JMbxo0L1Nl7aeOMnlq9pdWcoY6YtR9oe4wg4y/2PewPHypDoy4L39s03b5rWVJgGDCHqwqf7b3jdaW4sM9EvN1upOvC2E6xml5OT1pLa1Vfr8tH/OgIQqXdPeEZ/ZQVpQ8myZ0mPlgg5pL2CUkg5fTXFL6OiQ6knd557j9NWfZShXUv4jSGNELqkxg== 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=IGU4kvfJG4xkpoIdoZMTgYSWFbe4RKU94sIZkxd75As=; b=HPTIrA8LW0mNH3XbJy5iTPBI82ap2fI0diTw/uzwYMD78TxMWIIPKHiXRT894YUiXTCL5JP9lsRE6DU+QI3E9DvMu+d3P6kOWeHj9QVOQrUJtrXJwBK6rCTYQkQ8ByOPFdvlLP0UZ/8Dw1PNGE2WvLkIX4+F7M2vS3BTGSbvRnpd9SWxaJEMk+uHRuq+BsIXM6x6mwIRaav68fUee3sf3qfNb8ritC/3HWtGQFXRJa2gRCFnyANdo+s3g3+d1O6YDbXQJxMDL4rlAYmLBwS3KBWtmAZX2JAuxjg3mEfx5DByYgedYDIHvfniOKIBxfPR2HuzKyCQPo0RBI1kAHYV+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:40 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:40 +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 v7 11/14] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Topic: [PATCH v7 11/14] powerpc/mm: Move get_unmapped_area functions to slice.c Thread-Index: AQHYDqLZ1ugDhI6z+E+ZOoMcYyydgQ== Date: Fri, 21 Jan 2022 08:42:40 +0000 Message-ID: <1c083902be8813752bff297f2fb760bdc089339a.1642752946.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: 45710015-d061-4663-39fd-08d9dcb9fbc7 x-ms-traffictypediagnostic: PR0P264MB0201:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pL5tnNjoW41rXCod5XamzHMQWNqpe4TcumrT/InYh/VSkn7vP8WtbDjXYy1NSxMaxFQ+DoIEvfgVo224vG9Dvh6DnM7PV+HKXH+qZmtWH+107Z9lVvsUHJmSMk5Ar+swsjIMImQP84qEtpDi2JqghVnClue9i8KMW/bSNRDXVXDX4+xEqNHFpAHB3vHpQZP8s56KemY1EmxmTP7QkpIfP5yXge5tH2ehEXjg7q1C0x1bI4kM5ONochS0Xy3TM6Tst+YdaiDWefGBOL38hxCuQxp07DpCfwWPZqoqasLnHH1/hpBXxYLO4TbSI5QvHnWv/Kr5MxKvLBgZDPsFCYJWkBaJ2WHdzIn7MfNZIKQL8PFiNSu/pYXtRjb+ASGbfu2MKylGokrl0Daw+A791hcCyyjSUgzzxXanVY5R+uWfCTpiDv/jyX6AxLRYgBRrlUmsV4bIUh41zSN/guqI+eDdIxSoBdv9y9Dts+r0Fscmv1zA3qAfFF+36uyXX6biQ4r7Whf5y2fbWDy3ovofJ9+yG34ktSuufIln2AC7RunEhU/Fi1wCo5a8Oep80xbt558rByGtX9K2moVpgTO7gIFs1njwAY4lQHv3Ax//m9AJeUXVSW++xCPuC9ECPG7ETaMOWSwWRH5uBNINSZaS7dbh0I1OHVE4Cpq5rTrfQqTS1wU+ZFt76NiBhV6lEl61GdJCdR6QZd0NWcJkVdgwQ4P1Iw== 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?4QpF/JTplOmNv2GF+OVg9B1?= =?iso-8859-1?q?cB1DASAY8fgKRlk9HnuNqqfaFpdkgycB0M8qEXq0A3Iqiz37/WQwWISk0Xuc?= =?iso-8859-1?q?Z+sQhzxsPrtsYTwZaLmw0uGgXzRlyNzMBL8Y9ydUnAC9h2kOTgtXfbgZ/Y14?= =?iso-8859-1?q?PvWIEePlUs7UBGJBHxMQPcBgmOpo1J9TV1bWUWr9nZReUqQWr3l9P7B3vB6N?= =?iso-8859-1?q?Q6jaDRBGX61j2NlslnRlsZjRkVIT5FLkOATThcjmb8+MnOfAj4J40Y6ezhPW?= =?iso-8859-1?q?QOP2TqfPExgkX3xqgRr/fx7Rzb+BZ/rnTHk/7O/WqSS6RhVY8i8aC1ijii3f?= =?iso-8859-1?q?Zf41DjjCFLWwqivx9kWWIrwC+/eeJNgEcvN+JXPnE8a4andsFQ7TavXTiEbQ?= =?iso-8859-1?q?cOVT0vskRjlgkHvJ5pR4bjsHQWvfwkq47uU8uqz233drKMhwZYEwOmq8qZ6v?= =?iso-8859-1?q?fu8X6i68wBM0zx3wrWmbvByd0CMHwQ6gV175HcUhTX/3UcyjGEGZ1lbDts3m?= =?iso-8859-1?q?0cauUl8fvv1QwiiNbjoUE2RDPg86wXFwaWtdAjZNPIW7fM3x/8TEQQNinLcf?= =?iso-8859-1?q?zA48LdYTzX/TC7MKCptq/peEYjVAfCMTaLLRrTv7OiecbT5+3htplIYFSTa3?= =?iso-8859-1?q?/tpF6L7dv866rqVV4F7EU2KANq7ilL01HH2yaUjBSxKY82/opJB5bnlxp+/3?= =?iso-8859-1?q?9NwgV6aqf29IGw/5kLlAXNL9h+HBpCE9HGj748t+pgdlQ3sRe6x8oAib3Ky3?= =?iso-8859-1?q?aGvF7r88dSz4Aw6uWnEac0wK4k4ndlRnjO/Ru3g4kVqY6Kk0kErFzySaJJLZ?= =?iso-8859-1?q?LF1NFotoQd4AD9aXsfXGI0ZMQYjKySPO9/SwidU12GBYHfxp/jv8MlaxN43k?= =?iso-8859-1?q?VLig0uo/iW9ErdPgnl7ZXyoaaoI3uHoqgurdoHOl1fXsygDP/vipQdO+21Ma?= =?iso-8859-1?q?8UjkiSHObYxz3Rv7wTGYEH7X7CySDHW6xk62/7okQVNkgPsZo3Y4tajJEK/k?= =?iso-8859-1?q?1ISfFxdPwKrkqW0VbgBEOGQbPV13A4yZA2eeDNQPPR3Eoro0qYXZm3SaVm5v?= =?iso-8859-1?q?IKy7uyu0PBte8yMfBtQiVz75pAdIiK9gjmMR8AacAUMItrRZeq1y+Csn54Ho?= =?iso-8859-1?q?GHaxEbR+beOCfvJ2+xGTpGvgJ3gC6GuZyADLPB6vXgpSseKfCdNoK8MBphGT?= =?iso-8859-1?q?c/ED6Vnqc+nfP1duUb2Yu91dV4xmqbJp5wg/tjBe1kwlsddrt/UHLnnFptna?= =?iso-8859-1?q?Bcu0UwDVZDoGf9qxwPUFQ9wTC6DUn8aPt7MnEIO0AnZUn4YFbhk9bFccha6E?= =?iso-8859-1?q?doAwr0kR/hGIvxqOJqZc1kVR8JOHH1xjDbe10YjH8KSmjp8SoZ4woVdZR+9n?= =?iso-8859-1?q?49btLfdL7kesZ3E0ouHqSpFPiPSI/IP740dPYZkKsPSlaCoyO0Q6l02WT/g4?= =?iso-8859-1?q?RyHZqROOGzadzcgLJZnFXMwfleIpvUgVlBCIqGccMDgSmZcMIg5TeFwxNh4p?= =?iso-8859-1?q?a5k5Q5SnMPLuqD4cZabcE7Bnd2kXwE6G9GOlvzBBJzB4+c6ITXx23IH8XmW3?= =?iso-8859-1?q?8515UNkA9By4ZOtqeuHUAoFyHkFt0rDxysYS2cbh/MJBKFGtPTqOsCWY2lQ+?= =?iso-8859-1?q?vACCONHwTruLTGh7dwX67E0cXK+z1R1+YRcznr0ABrIU7irfy7JKWgn/jMb3?= =?iso-8859-1?q?LnVBc3v4oT7ShdeaJnbA7VTAgYLsnZtdBv/mqzCYPJlB1UHDCXAYAch1ZzMi?= =?iso-8859-1?q?ZEpo=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: 45710015-d061-4663-39fd-08d9dcb9fbc7 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:40.0052 (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: ed0mTYjtt/MICJq700pSVfham4LHK6Yx9eHtBvKxaXvihyaqvXopkZ8WZgcv0CyySIkPruS0ntwaPSVfsnRLxsfcdjIXSXKV91zcQmKloIk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3C50C18000E X-Stat-Signature: 6gxza5cd4octk6cfqp911ubhusoe955g Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.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: 1642754562-830474 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: hugetlb_get_unmapped_area() is now identical to the generic version if only RADIX is enabled, so move it to slice.c and let it fallback on the generic one when HASH MMU is not compiled in. Do the same with arch_get_unmapped_area() and arch_get_unmapped_area_topdown(). Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/64/mmu.h | 6 ---- arch/powerpc/include/asm/book3s/64/slice.h | 6 ++++ arch/powerpc/mm/book3s64/slice.c | 42 ++++++++++++++++++++++ arch/powerpc/mm/hugetlbpage.c | 21 ----------- arch/powerpc/mm/mmap.c | 36 ------------------- 5 files changed, 48 insertions(+), 63 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h index ba5b1becf518..db47524fa8ea 100644 --- a/arch/powerpc/include/asm/book3s/64/mmu.h +++ b/arch/powerpc/include/asm/book3s/64/mmu.h @@ -4,12 +4,6 @@ #include -#ifdef CONFIG_HUGETLB_PAGE -#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA -#endif -#define HAVE_ARCH_UNMAPPED_AREA -#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN - #ifndef __ASSEMBLY__ /* * Page size definition diff --git a/arch/powerpc/include/asm/book3s/64/slice.h b/arch/powerpc/include/asm/book3s/64/slice.h index 5b0f7105bc8b..b8eb4ad271b9 100644 --- a/arch/powerpc/include/asm/book3s/64/slice.h +++ b/arch/powerpc/include/asm/book3s/64/slice.h @@ -4,6 +4,12 @@ #ifndef __ASSEMBLY__ +#ifdef CONFIG_HUGETLB_PAGE +#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA +#endif +#define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN + #define SLICE_LOW_SHIFT 28 #define SLICE_LOW_TOP (0x100000000ul) #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index e4382713746d..03681042b807 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -639,6 +639,32 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, } EXPORT_SYMBOL_GPL(slice_get_unmapped_area); +unsigned long arch_get_unmapped_area(struct file *filp, + unsigned long addr, + unsigned long len, + unsigned long pgoff, + unsigned long flags) +{ + if (radix_enabled()) + return generic_get_unmapped_area(filp, addr, len, pgoff, flags); + + return slice_get_unmapped_area(addr, len, flags, + mm_ctx_user_psize(¤t->mm->context), 0); +} + +unsigned long arch_get_unmapped_area_topdown(struct file *filp, + const unsigned long addr0, + const unsigned long len, + const unsigned long pgoff, + const unsigned long flags) +{ + if (radix_enabled()) + return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); + + return slice_get_unmapped_area(addr0, len, flags, + mm_ctx_user_psize(¤t->mm->context), 1); +} + unsigned int notrace get_slice_psize(struct mm_struct *mm, unsigned long addr) { unsigned char *psizes; @@ -766,4 +792,20 @@ unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); } + +static int file_to_psize(struct file *file) +{ + struct hstate *hstate = hstate_file(file); + return shift_to_mmu_psize(huge_page_shift(hstate)); +} + +unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + if (radix_enabled()) + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); + + return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); +} #endif diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index bfd7f4af1e58..eb9de09e49a3 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -542,27 +542,6 @@ struct page *follow_huge_pd(struct vm_area_struct *vma, return page; } -#ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA -static inline int file_to_psize(struct file *file) -{ - struct hstate *hstate = hstate_file(file); - return shift_to_mmu_psize(huge_page_shift(hstate)); -} - -unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - if (radix_enabled()) - return generic_hugetlb_get_unmapped_area(file, addr, len, - pgoff, flags); -#ifdef CONFIG_PPC_64S_HASH_MMU - return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); -#endif - BUG(); -} -#endif - bool __init arch_hugetlb_valid_size(unsigned long size) { int shift = __ffs(size); diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 46781d0103d1..5972d619d274 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -80,42 +80,6 @@ static inline unsigned long mmap_base(unsigned long rnd, return PAGE_ALIGN(DEFAULT_MAP_WINDOW - gap - rnd); } -#ifdef HAVE_ARCH_UNMAPPED_AREA -unsigned long arch_get_unmapped_area(struct file *filp, - unsigned long addr, - unsigned long len, - unsigned long pgoff, - unsigned long flags) -{ - if (radix_enabled()) - return generic_get_unmapped_area(filp, addr, len, pgoff, flags); - -#ifdef CONFIG_PPC_64S_HASH_MMU - return slice_get_unmapped_area(addr, len, flags, - mm_ctx_user_psize(¤t->mm->context), 0); -#else - BUG(); -#endif -} - -unsigned long arch_get_unmapped_area_topdown(struct file *filp, - const unsigned long addr0, - const unsigned long len, - const unsigned long pgoff, - const unsigned long flags) -{ - if (radix_enabled()) - return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); - -#ifdef CONFIG_PPC_64S_HASH_MMU - return slice_get_unmapped_area(addr0, len, flags, - mm_ctx_user_psize(¤t->mm->context), 1); -#else - BUG(); -#endif -} -#endif /* HAVE_ARCH_UNMAPPED_AREA */ - /* * This function, called very early during the creation of a new * process VM image, sets up which VM layout function to use: From patchwork Fri Jan 21 08:42:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719508 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 B2194C433F5 for ; Fri, 21 Jan 2022 08:42:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46D836B00A1; Fri, 21 Jan 2022 03:42:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 41D1A6B00A2; Fri, 21 Jan 2022 03:42:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BD9D6B00A3; Fri, 21 Jan 2022 03:42:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 1CC7D6B00A1 for ; Fri, 21 Jan 2022 03:42:45 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D548793D95 for ; Fri, 21 Jan 2022 08:42:44 +0000 (UTC) X-FDA: 79053653448.12.54C1065 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120072.outbound.protection.outlook.com [40.107.12.72]) by imf13.hostedemail.com (Postfix) with ESMTP id 6C69B20007 for ; Fri, 21 Jan 2022 08:42:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AX3Z2hTDUI3yohRYTfCpCFfK7ogCvIY3gI8q1zSw1H+X8P8TSM5gjujLrfLNeH5+z9aqdAE9+SjL9M4tZQ1GQA0JUmzhDU80okl6X2dan2w9OOvTZcmkqY/A05Nc+DUuPm6eVETUJZBl0eBlx3OjX9+S0fMHCnbPxJzdt9Zo8N68SRH36nmCN9Q0YX8UINBrbI/FOxxiEse2jZs+CCDFZ+BJgX/d7PWzeYVeHb6y/VlvaUHeS6h3UOpLdmV3SIFklWOqOx0w9jhWINdq7R6Ojl1mfE+g0THKs5ikKjq6OL2OeIyOnFKT4rTTLRyq/rVNvcrCeCZ7KbeQJxhZhYtrdQ== 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=PM1tsV2E7+/dx7vpR2aV9rqndz5KU8OyEwLYpGyZ5i4=; b=CQ1CdBuwLYnepCl8JOU5k7epgLB2pN7d/Uq0U/6sZJ+RcJHnEuQrY/RUO1SDsvCWDOIDbndyRY43kec4g8EKQ19wNgjTEfr64ydbkiIK8P6HmeD/Tjd56lfyIx6WUHeMzHZ3lRrow4hyogPlifQYRCEI3/UiyBbqey3hZ7v2SkiNoDIx+tWBKdj6DIjRGukqp3uRR11zOjLUDsXXyyaucowAkqDE6tho2c2TBd6ojUMNkjIvFtZ7b9b1Fc6pqDEXmUMdZ7M9+9hDGXuWr0yDl+JuXBW5YlXS52lkT4+1jLW0lxg4Nf088UOXDwLEg6rwIP2i0GvzYFYjBkdWwjLmfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB0201.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 21 Jan 2022 08:42:42 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:42 +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 v7 12/14] powerpc/mm: Enable full randomisation of memory mappings Thread-Topic: [PATCH v7 12/14] powerpc/mm: Enable full randomisation of memory mappings Thread-Index: AQHYDqLadZ1PUGsqwUCDshHOaCgmUQ== Date: Fri, 21 Jan 2022 08:42:42 +0000 Message-ID: <675b7946a15dd18d5517bf10a8b49b09142b6c58.1642752946.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: 7b692418-8b7f-4eb3-2775-08d9dcb9fd6b x-ms-traffictypediagnostic: PR0P264MB0201:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2887; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ajglEGKiaPxsU+ZeacAlUAYW9R/nQfHWTaVNiogMEf88iibxl2nxkm8p725MEf5jsPL2yFPQXDOdmO5N++4ThlaBaY70RK64Qi6RIxzoBGvKCgtZvkhRHxj7A3MfsrlHHIggvtagKkUAStTrZnE1AmshY7ogtZC0puvsq4ok7nA5FFrK2IBCZiCHtKfIKHLG06QcwR6+Hc9plo+9Ct4XGzMU9WwA/NwHjF2wm+lhy4S1TFon9FqsmPdUjPg41Amt/bwe9n1XCxgrWuoBXuaBSWuUzYJvZlMqfFs2GZCE8XI+Rs6X5v45mXpnE/7wmEMe4KHDygW1rX+FyitUS4hEZEP4V/bdAf0ozcI9WAYhCyVi7pqoFfHHYI1Uz1h+A5MjZm7TeW36NvYg/5J5Bm7ANCyLUI6yp9cXtljw9UkPL6Flkd31CU1ClyfAdaBYkfGhkZJcoPBjC/T5KRSh0e3JP3rTDxNOkLIrCi9RiMHmBsJuenbj81qNgUHphRZUEDA5waZiBzl2LPWFD6jKH+aVAS4NJa6GPDlMf+kDh2m0Fz3EgPebYJCECm2m4bc5SMr6fV2tYG7nU511A1AIbN7ktOvHWQuR/sp2G2bemdVDLjbO7BWKNgo0gmvrVdxnNVe5l9Tg8eRb+lb3cBWMBsFQkh9e7wN8muClPF1gQaFybJ9qN+mmvB2ehdyVDjE5u2qDJQFevH0xbUci8GqTqweV0A== 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)(76116006)(91956017)(36756003)(66476007)(2906002)(5660300002)(66946007)(8676002)(6512007)(122000001)(71200400001)(8936002)(83380400001)(66446008)(64756008)(4326008)(66556008)(86362001)(26005)(508600001)(6486002)(54906003)(2616005)(44832011)(38070700005)(6506007)(186003)(38100700002)(7416002)(110136005)(316002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?+U9d1ltFf/r/v6RWXZGQW5l?= =?iso-8859-1?q?1JSyZTh+k695dQxkFj8Q5R1vjCIg5axsq9uCsy0aSaswxQPGdktasu3gEJ9U?= =?iso-8859-1?q?QzZ7TTyH1aF9Yv1JpdGREyMAq/YCiWNy1iIlNXWyH5YzJ03Us/E9ZuVO/I2F?= =?iso-8859-1?q?lqStN99nsefDod7rXQXYCbOJ4/D9HsmEOEfH5Nl67x0NqKO3M0TUwWwg0lS/?= =?iso-8859-1?q?iT+KBwxWLpUiXQVxlflitxAs/KwwIgwx4s+EwI/Gk46lnK1nCSudls4+p5rV?= =?iso-8859-1?q?E912BVx8hbnnhnzq1PfQZH1SxpmVVluetkx3aPhdV12AiqMD/lqKoEV7CoXg?= =?iso-8859-1?q?9YmqKqncnYG8c1kngmjXcXZOBDycW6wDRf3hDGaL80KkJRcqs9sgvi5/irLW?= =?iso-8859-1?q?a4H2YCwOYvOE3ptlQzihc8cbHqCjxLKgziYO30XHwvrVzeJ9fcIZbdEOLNt2?= =?iso-8859-1?q?ccr32t1InG5gwCVsLiaSk7pdUETqYvmFlbyYfar9trrw9ayPMhsfowypfjHP?= =?iso-8859-1?q?HIPaliOgXmZ3Jvj+V0hVmrZgX9DYobWXC/yNAuQASgq5e4c9UHMC87xOW2ax?= =?iso-8859-1?q?OswENcoS5nmzUCV5moX9vpkb9FwACOz0eFXBgWd7SuQvziKcRdYRc9g5vZK3?= =?iso-8859-1?q?IheEwHmXgMjA8O0+DnF+UIwKdv9crQyNdX26tpvjLbWFAqpR5tjuIYGKN7rx?= =?iso-8859-1?q?n3k4LfG51Rcu7Uh75yIbODuuZS2tQ3cwuX3ezzdVHlUZH8PYGrXBfOPt+bI+?= =?iso-8859-1?q?5Ul/UFI4PzFd0b3UqFOWFN4PjM1VyJu6zvKogD2zXc7avEpy+sUMIoYGTgVX?= =?iso-8859-1?q?qLpzm0WmwjypJTTSa3k+DGQ17Gkk9AMgAOz2MCWio4pHl3JHfaJs1ZUuL6VR?= =?iso-8859-1?q?rxtrXjfDtm1WUetNramg5TZuUft+lTbuU6dQmGUAHAl6SDlMum2E/q7nARLO?= =?iso-8859-1?q?vZtIo8aeN3d9PDIJJtNWBf1iO3dtvWfH65GoJ1earZZegEHfhV/I/7LPNZV0?= =?iso-8859-1?q?HRFs08vHX5haLZWHp3zCo1XKTUsHujMP+NjC4Z0OArhFe/LGl4NDle7CcZf6?= =?iso-8859-1?q?qxGYdjkKPxRBl2hnHZsNNpl2uD2IyslTRwSAfnTqZfAjumUJQbjFlVj1Fk9q?= =?iso-8859-1?q?KijBqtLkL8fOWTgPUJIs/sosuKd8D3hLWtHp6ERYCr4KgxLO17OEPsK5wFAD?= =?iso-8859-1?q?D1ihnrqTKZyqQsb9/WzPuH0Bhe1A/7oLDRYceItJ6DStWEI/nQ2mrx9i71FI?= =?iso-8859-1?q?Mp1VXpO73NesmhDQkQFWZIRap1K8NRpwfhveFGN/FbJhS7xwChmAq6zAA1Lz?= =?iso-8859-1?q?SriwY8p47jN7u4P0kRBTrE5WNX/Gqhdm99S4v1sLfySs2N32OXNW7wHaYJF2?= =?iso-8859-1?q?6zJRIFutfaBRIkApEvGOPgOPBzpxbDOZ7lua2TBvfZCLI8kwWybXBf1NUR2/?= =?iso-8859-1?q?tHyfZPXP+0hClYxX36GeezgZ0XrfagpuASXd8noSNARUShmeFRSsG8Gv2e6p?= =?iso-8859-1?q?RmhljOXizqbQOMS1vAz+pUwkIeIYp0hg+vVLEYlAN879pkCHh5CvgEu7/S1e?= =?iso-8859-1?q?e4/ekUM7O59E01VlmYdm/cml+0uT7VXWyU2Npmvzi7kaRw+5Bhv2AbkZF7vy?= =?iso-8859-1?q?Ktq+E7USV3fK5gEmCTLgPI0JSMYZt3TArWbGFMcDTL1GMgfoVnFbJkp+U4N2?= =?iso-8859-1?q?5qJIGVKOgNixKRYZ2eNqQGtg5IF4VzaqoK2Ln482RhTkiZaA/SreLgiyMRB3?= =?iso-8859-1?q?sJXk=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: 7b692418-8b7f-4eb3-2775-08d9dcb9fd6b X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:42.7885 (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: YKv5QGv2tePGOq2d+ZQPrzd0hoLel+UOfxFUVHCxi0V/lbJKnTWWGWi4kOxxNYW18f+kWSdVLq9X5jEgIiTyB74c6zcQR0qNLeYCqhVy1/0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB0201 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6C69B20007 X-Stat-Signature: efj1y6d1psn6jaujzcr7ephg9rpmeqsg Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf13.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.72 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1642754564-893901 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: Do like most other architectures and provide randomisation also to "legacy" memory mappings, by adding the random factor to mm->mmap_base in arch_pick_mmap_layout(). See commit 8b8addf891de ("x86/mm/32: Enable full randomization on i386 and X86_32") for all explanations and benefits of that mmap randomisation. At the moment, slice_find_area_bottomup() doesn't use mm->mmap_base but uses the fixed TASK_UNMAPPED_BASE instead. slice_find_area_bottomup() being used as a fallback to slice_find_area_topdown(), it can't use mm->mmap_base directly. Instead of always using TASK_UNMAPPED_BASE as base address, leave it to the caller. When called from slice_find_area_topdown() TASK_UNMAPPED_BASE is used. Otherwise mm->mmap_base is used. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/book3s64/slice.c | 18 +++++++----------- arch/powerpc/mm/mmap.c | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index 03681042b807..c0b58afb9a47 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -276,20 +276,18 @@ static bool slice_scan_available(unsigned long addr, } static unsigned long slice_find_area_bottomup(struct mm_struct *mm, - unsigned long len, + unsigned long addr, unsigned long len, const struct slice_mask *available, int psize, unsigned long high_limit) { int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); - unsigned long addr, found, next_end; + unsigned long found, next_end; struct vm_unmapped_area_info info; info.flags = 0; info.length = len; info.align_mask = PAGE_MASK & ((1ul << pshift) - 1); info.align_offset = 0; - - addr = TASK_UNMAPPED_BASE; /* * Check till the allow max value for this mmap request */ @@ -322,12 +320,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm, } static unsigned long slice_find_area_topdown(struct mm_struct *mm, - unsigned long len, + unsigned long addr, unsigned long len, const struct slice_mask *available, int psize, unsigned long high_limit) { int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); - unsigned long addr, found, prev; + unsigned long found, prev; struct vm_unmapped_area_info info; unsigned long min_addr = max(PAGE_SIZE, mmap_min_addr); @@ -335,8 +333,6 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm, info.length = len; info.align_mask = PAGE_MASK & ((1ul << pshift) - 1); info.align_offset = 0; - - addr = mm->mmap_base; /* * If we are trying to allocate above DEFAULT_MAP_WINDOW * Add the different to the mmap_base. @@ -377,7 +373,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm, * can happen with large stack limits and large mmap() * allocations. */ - return slice_find_area_bottomup(mm, len, available, psize, high_limit); + return slice_find_area_bottomup(mm, TASK_UNMAPPED_BASE, len, available, psize, high_limit); } @@ -386,9 +382,9 @@ static unsigned long slice_find_area(struct mm_struct *mm, unsigned long len, int topdown, unsigned long high_limit) { if (topdown) - return slice_find_area_topdown(mm, len, mask, psize, high_limit); + return slice_find_area_topdown(mm, mm->mmap_base, len, mask, psize, high_limit); else - return slice_find_area_bottomup(mm, len, mask, psize, high_limit); + return slice_find_area_bottomup(mm, mm->mmap_base, len, mask, psize, high_limit); } static inline void slice_copy_mask(struct slice_mask *dst, diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 5972d619d274..d9eae456558a 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -96,7 +96,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) * bit is set, or if the expected stack growth is unlimited: */ if (mmap_is_legacy(rlim_stack)) { - mm->mmap_base = TASK_UNMAPPED_BASE; + 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); From patchwork Fri Jan 21 08:42:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719509 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 392C3C433F5 for ; Fri, 21 Jan 2022 08:42:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B23346B00A3; Fri, 21 Jan 2022 03:42:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD3326B00A4; Fri, 21 Jan 2022 03:42:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99B4D6B00A5; Fri, 21 Jan 2022 03:42:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay039.a.hostedemail.com [64.99.140.39]) by kanga.kvack.org (Postfix) with ESMTP id 8AE046B00A3 for ; Fri, 21 Jan 2022 03:42:48 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 443DF22F01 for ; Fri, 21 Jan 2022 08:42:48 +0000 (UTC) X-FDA: 79053653616.01.005AA11 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120049.outbound.protection.outlook.com [40.107.12.49]) by imf31.hostedemail.com (Postfix) with ESMTP id C0D3220006 for ; Fri, 21 Jan 2022 08:42:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HtcV3g07PmtNR2jc5QbyiLWm1wpA9zAiTjuq+7mKqjhsVxsZ7/QuoiJJezoe2HyoupWQQ3wJ8O1VLZmgoJIWn+d+7JRyqDWLwN9UyyQHmbC/htJ6/4qNQwrHrau0cHa9efYz322yNbPHNn2qJQI+GDZeWGRie/ePIcE/JAfY10aq8hv2QvPy/MWeXNO1rUkFwwIvQY/xL+2qN0US/N+IwNGAow3d+HxeoDWwTvd3HhKmdfXK5iqbPKc/JHFyyy0M8pv8MMoqU1jfvlAOY+XFmkfvPID6gfNg281WGFm8r6kmdf8dK5FVFFn2IlpOL6dV2375gh9ikn78QYHEWYw6VQ== 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=jcRs0Wek2whK8do2+40CtHsAi3sU07tFOa1qv1zVaAtGO0Ce2R5/wEKO0D9RlH+9pzpH9rXP1x2IEOAmXCWg43GxIsLhemVYv3P2QVF76zO0vMWCmL5Lt5TtRnEyqtP2MZ82dBEKbtXpyuOZ1XlPDqaMZ2H22yDXTI1AtZhTJJdQy9GlKQCR1BoYKE03PKQtw2/8NLV4NlndvrnyLKgWRUdRVzjZOmsE+eS8fRASQassHN8r7h+RXh9F7gLHi/kPzBF1ZlTyxLk8ogtHmWWRlmRr8R5uBUdmvHkEFSi20YDyoANIzQJEd0pBo+1oPSYR9Fi42HA+k3zl9PaoTVlQQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by MR2P264MB0196.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Fri, 21 Jan 2022 08:42:45 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:45 +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 v7 13/14] powerpc/mm: Convert to default topdown mmap layout Thread-Topic: [PATCH v7 13/14] powerpc/mm: Convert to default topdown mmap layout Thread-Index: AQHYDqLcBvroGy5qcEimJqCY0/Bldw== Date: Fri, 21 Jan 2022 08:42:45 +0000 Message-ID: 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: 74296052-3a68-4771-0580-08d9dcb9ff35 x-ms-traffictypediagnostic: MR2P264MB0196: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: JCwvEfC0u8nJxuxZ8SqVgS2JAono9lFxPpOlJYaUYINdRZhYYF9hRVqFnxWfgJ2sNlRd1tbOcopSoOWK2+zg4aFd5UflDy7hrgU7G4tYE4pBikm5wbfL3zB9Ho2WmAw5I8YYqn8fUbV++4u97cKk8vTqdNV9B1NItfokr8TPZ3ZCWyE1QhT4Oz54v7MMHD97GKX7rpedJhpu8sN+Ni2QH7/xwywnf+DKb9mrk2oo1G34aq9Q8yGaISvJJm9hD3p10sVybvfs0XZHuxddDFRwxxxcWKv1XhjRtgdJsRUMsUYYajhkLnrU7/ChW6QBVSBK5ACFvWisE9+Tu2jjxJMR+gAkwAVuCFLpnyYPPQ8D2BRuPDaaUkPjbcxIa1XNH6ixJIXxz3kWW+ZDPXcWcwi2VKdEzxTHO2L3EYsf/2AZdPV6Edcvu6n4vG0bW5FNpHAltlD6BgDixkNsOC0HXdBY6QcHUxRbaEqeSVK8vgDOnW5lcCaptxnrm/CemWiY23xh20E7pZA3+tzdSv8e3UZn8VwzwzI0EGME5uTGUuHgKPPEQzsteSrRVbee6ZNR+ptEwBTd9gbkoXpqpJcsVdcOejTM/tbzFMW7zrdLJWl4sb0kYgLxuQVqBgoFpGx/ihzClaT+dcfMWF25QWDP9SnF5hDeCQzLOi8NJQDUhHdlI1ZomUPgK4swCOPMtGNUFNRoRNPqVUPqNDMuLtslixGBjw== 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)(2616005)(6486002)(186003)(44832011)(26005)(7416002)(6512007)(6506007)(2906002)(8676002)(71200400001)(8936002)(508600001)(86362001)(4326008)(5660300002)(316002)(66446008)(64756008)(66556008)(91956017)(110136005)(54906003)(38070700005)(76116006)(66476007)(122000001)(38100700002)(66946007)(36756003)(83380400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?jZqiE+l+22nLaN5CTYPQn6U?= =?iso-8859-1?q?jVRLxo9IihIz7RYDMm8L29fuSyjHvTrj9bOiPP46E0cU2KBNPXULhUSlO/aM?= =?iso-8859-1?q?uCYV6+cGifS8cbtKGmDjbj689M7GVJHVe4PL5P3MOjETLjuVDk4Kw5KyX7xE?= =?iso-8859-1?q?SxK+PAANzzyq6FRp5xdnRJHtZm0fRjd/lQrxIIwIbm0d4xqf/Suu17E6IVkf?= =?iso-8859-1?q?xk2/J0BtbkRIJ4h0z1KqGAaQY2idQp6wkWsxh1F+qPixkL+17zzHFBA+fNWq?= =?iso-8859-1?q?Y+QbPd/CS1fe9XZf1C2qPjTZVBLZJkK7psX6/tLJLdcYDMAhqXAHqUREhkng?= =?iso-8859-1?q?tm7yGQzta08/vHaSsH6Bm22AEvXeV/vSlZviVGRirJoq/jJH8uctfFmpCaYx?= =?iso-8859-1?q?fxYaUx0aKXlaRLt4yoQA2MP0UjI69Slq/JNsFQ+uu4OhITNBeVsJIBagRuK+?= =?iso-8859-1?q?XDdShErZaPxcNuVKoagrWpQRlvysbpfB+0pa5erqERObeVGgM2WdVQ4Zzyo+?= =?iso-8859-1?q?QLnbfRfp/VwDa3wMYlUQjqc3s0NTAUNdYYC2rkDR+AkDN8xTffrKgH3tgeaQ?= =?iso-8859-1?q?KY5+ReAKjNx3wzrpD+p3YgUIu5Uo15OqrrsSzA6tdB8D6Ob/6eeF9ELziB2a?= =?iso-8859-1?q?1YmUv2YXGrV3hLbcbbCZxjtr4hNuvOU+HSOAW2K32LRdAyMPeysOzWF2XIGO?= =?iso-8859-1?q?CflEpwEF53r6PFist9XDEHomFsdPZuVH8DRXjWgeQ08PXHcbURLw0SWMdQRv?= =?iso-8859-1?q?8NV/S1Yp9J7NWi8Qs9teqWHTsgHJft6HpFAasKj2s1jB7PxKx3BPlJwIYyCA?= =?iso-8859-1?q?U5EruerCrtKHMxTRIAdHnjPkOL3lTWdgG+WqpyxNDMg/yE/5abSR3UEIlTu8?= =?iso-8859-1?q?ym4WpJimm+ZG2QuZrPj22Z4n4fV4isOe7yqzE1YRInmRk6GfG8ElzPdwLC/v?= =?iso-8859-1?q?T9WlPqcltVwV7Anqe0ahA0W0jHYbb0l+zYmOSeiBLThwz07ulQRuGosmzh1F?= =?iso-8859-1?q?IZMJ8Vsa+gRfzidMTKvPNKZcQc64UEkOiZFZdDcX6w8+SUgMKcdhtiogtEXn?= =?iso-8859-1?q?CnkXm2Z6L8bcr3jqljAsD3zmQxducz22G3c+7Fz8omd6WYEsyV+Dj8sqePI+?= =?iso-8859-1?q?d+Wxno6teQWtejh6675d/S0jm0AMs5f3fADaXms9N5AKlQ8ls5iQ9t/UhGP0?= =?iso-8859-1?q?GzEcPkFRGZeZjQyv+HG4OM8Z7faYGljvZjP/L1/AoOEkL9CFaC3Wc6hEk+/S?= =?iso-8859-1?q?V+4P2VRMxnyL6CIQ6/AANpZQYnSsh6P3WmKa1NVScQa5C1nT64sMERr765C8?= =?iso-8859-1?q?0AmQy6LAF2Wl1FrGnApQLELd0Id6VWXcFfmyWJBjqDdArpamAKfzqfPP+o8P?= =?iso-8859-1?q?6rdLjAUDz5B6ZU+EY7VQOoQYRq/CJgaoMEwYz06KemK0M14e1jZu8bR4kGg1?= =?iso-8859-1?q?f6LJYlWH8y3W+8lV6DUo6HlakIiN/bhO7Sba956hIA2uUmEhQOvZBBAmThG0?= =?iso-8859-1?q?o0K3tguprg2xGBMVp6p1k68t60+XI5qN6zUTasZ/6vORm/on97vzvpneik6O?= =?iso-8859-1?q?lVPFVXkb9tObsJA4DUdxaZaPZAPBVn8CCotPK/8AUXqYqnET+Mjye+CwOacV?= =?iso-8859-1?q?nrLogqHOA3R+0K7ZljYWTFDKC8Z7PXSHtB7llA1NPKJGj8G4xTOh9qOr0spv?= =?iso-8859-1?q?g3NTMJCSLJ1BSSf/W12lFHHFcQ2XvnRaQv9DRYlqW21CLSQxaa2Y0YaAwfs8?= =?iso-8859-1?q?n2RU=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: 74296052-3a68-4771-0580-08d9dcb9ff35 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:45.7736 (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: YvqYMZqThSUb7klbfPz3kIPG3E9/S6WPAd3TBPTyeCbD060E/D22unWS4c6Zu3Ebre7HYF1Xotd9XINkJLubazwVV0e4uu7L14+bL1XIKpc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR2P264MB0196 X-Rspamd-Queue-Id: C0D3220006 X-Stat-Signature: x7rtna91skbfj81u1smdjs76t11dqy6p Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf31.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.49 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-Rspamd-Server: rspam06 X-HE-Tag: 1642754567-481186 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; - } -} From patchwork Fri Jan 21 08:42:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12719510 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 50DFDC433EF for ; Fri, 21 Jan 2022 08:42:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0A1F6B00A7; Fri, 21 Jan 2022 03:42:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB93D6B00A8; Fri, 21 Jan 2022 03:42:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5A4E6B00A9; Fri, 21 Jan 2022 03:42:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id B65D56B00A7 for ; Fri, 21 Jan 2022 03:42:51 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 827F695272 for ; Fri, 21 Jan 2022 08:42:51 +0000 (UTC) X-FDA: 79053653742.17.91A733D Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120080.outbound.protection.outlook.com [40.107.12.80]) by imf06.hostedemail.com (Postfix) with ESMTP id CD94B180002 for ; Fri, 21 Jan 2022 08:42:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bPTj455QNB+EVyVm224htK0Vc2P12e48zgbKtv4PdyeoO0GBzfQoghgjAWMi3+w2gBI6j/mBCwmdTRbWEfSp8Aksmu9rfQjNjD92UijI8Re0MQRFXNhQ+KHav/3k6vsPnW/gACSDSCmx90mKhJl0yFByets0hP1pBMGK3fHg2dhDSdnbvJqsTBi9EhrCnD2/Cx/Q0/h7/D9P/g5dh9UJQrQjtKGyuaCZPksaJ6G2kVXTzNqWQQONn7S/EmU0IRojW7NH7tPr7FT1vGsAO5LbIQMUzyTq4z913OyjIzEMdgbvyy0Q2IQbWSQz7eX5KQb57Pvzs35Djt8noitZ2lSITg== 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=a9SuhqlOy06KBe0gYPpfKhVvBqJHRnDfSe40VkrHRks=; b=JaRA4mK0b4JTJ+RL40l4c0DISgxxmA94q+kSdMszPjb9j05rqTGIBJI3pRH4GztJFv7wWnPUKXTXtJR/3yFXUQRUybBvFSbSqdjRa7d60orM8E3At1q8CXBxhUvcmonulDnOpUY/nT6UWKYib0/Fz5nCEA/hP12Ufz3PXx5blRKIRb/34NaiFq+mmCDZ1rjsSApGYra2tNKna/Bf4INJKrn3A38vVhelY+DSgKT57yymv/FPm7D3PsYWFPPIyy+Ku8j5UkrNwWG2kU+DdTXB0nqDDrM+nEc2+ogH5ZZRtIHS//+1vcVSitLXFfsIIQpHLmMyjkJkuytsyPa2y0iutg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by MR2P264MB0196.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Fri, 21 Jan 2022 08:42:48 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:42:48 +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 v7 14/14] powerpc: Simplify and move arch_randomize_brk() Thread-Topic: [PATCH v7 14/14] powerpc: Simplify and move arch_randomize_brk() Thread-Index: AQHYDqLenb0tMTWDJ02+PYwHQDqHvA== Date: Fri, 21 Jan 2022 08:42:48 +0000 Message-ID: <49dc4982c458867c66f022d11f16ad34e656cd85.1642752946.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: dd402a8c-678b-4878-e2bc-08d9dcba00fe x-ms-traffictypediagnostic: MR2P264MB0196:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O/9ozK6umGY0tJIszwAYxTiJgjiKCCBynk+LGK8Alwp7mRZqQcpO4thYpJrXS2PbHPzy7WZ8bYon9Hw16Z04wKmlS76/KYhmVpLKyLSf/nKPXCPTOXCXhyTb0iMjXZrPYayai921tbzRBMOzjsT35BWQPlbuYO7gP6wui/xDUUxIymOdYJFX8v06a3N3HefbLKcFNacpwlwrcGRFDpTzoS89bEtY3zT3qUMM43zSUC0cr0cc0/X75aKCi5XI8OTGoqaKSRrfpqh9jABKeWXjXre2E1NULvyKNuVAgGj5eC2fjNss6Ubs/MSCgYT45b8UuNz1NLKIb/aWjcebI5TCyDiQyf3dHnM+JnHtopLjFYIE5FBwelqCE7W/kAxpyGHUWgfDuiRzJoOrp8cxq5TsUb1BJzP0XNlRoJMp1pPuIX0P3wKMj6dHC25Lpuz+5JOSd5y6rOdlwFcu39Rqxlfmw2G+NAwI4i+HA7Bxo1TKKzTS2ROTtx+BoYBhynFpUOPCYUuSmf3/Pt4KyIWs7EfD5Wmoe6KuYXcQan40bN+FpQ7gaIasEl9gh2atD1GtNnbWRYV0mJtKwm9ieJpcausxrdnS971DFBJ3uVZpTFy0McLrkAVevqu8DMby8KYHQLv4oYjsmB2kjA8aCU8oYZpouqiu8++vVfRojNjj+hqlhJaPYg4oDZPeKNca+8y2xU5jXqUYXnDHmqMrpSig5YVlzA== 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)(2616005)(6486002)(186003)(44832011)(26005)(7416002)(6512007)(6506007)(2906002)(8676002)(71200400001)(8936002)(508600001)(86362001)(4326008)(5660300002)(316002)(66446008)(64756008)(66556008)(91956017)(110136005)(54906003)(38070700005)(76116006)(66476007)(122000001)(38100700002)(66946007)(36756003)(83380400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?r7C3FOW/zL6zHNmBEFUepPu?= =?iso-8859-1?q?mHD4c3g20NOC6K8hWLK+Lw4GbOBOaMOJcowytDzsvEoQgOib2l7vIMYj/XSV?= =?iso-8859-1?q?Y9WE5b/Migd7qnMX4r2plnRW3pdUmnBmHNOyY0m/qigUwdLoW1YeJAx2QIYO?= =?iso-8859-1?q?W5m0spYx2vOrHSDPFED/p1hqoQR2BScPlnrKcWLO/7rugcST/QxpsaLOwXed?= =?iso-8859-1?q?q0H6zsw+UA4JhrOKCUVcymjqmMaG4SK242Ur9KoZWRyglT+sJu8dUE8ZyM5O?= =?iso-8859-1?q?ZyYD7vFFquRKmMj374XaieTxH/CTyaKA4xOLLSvAI7p+PAC8DcTvbdDipxu2?= =?iso-8859-1?q?VJ6twi3mGGQvJuXN9XopQstJg5r/gw8zk2ANKf+LxCVz/9L/lSN3JJ985le4?= =?iso-8859-1?q?HtghPj34XsJXIr7Niws8JEBix8ggNPAyBSXU4z2rRHKLw30z8+CeJYHcjt3U?= =?iso-8859-1?q?c04KzwgFfmaUkU93OfSp5KlWGOP5tHabw2GviGr8AdVwHL82f8dSMQl0NBgY?= =?iso-8859-1?q?gehfSs9xbBuXkBBXeDXtmJKno5t0Zo5H5NmWXI49WIYpkXcQOKnG26nOM7F9?= =?iso-8859-1?q?uzbpGAMEeDkDtSI8eBNZiFL5+r661pUNm8sgrM3D0EAG+BpYVFCqNUdKzD4T?= =?iso-8859-1?q?fzKC/4CPL9FMBwEz0xxsh2OZKH1SHo9uBdoEankWtDqyzyYDLrLiC9bfesO5?= =?iso-8859-1?q?hPlkqvZcft7bb8SKwKjyAeZrB+oBKuds6SMdhFGknATntv5C+zfsfwH7b1Z3?= =?iso-8859-1?q?+qVJQoUBZsRtDLCkZ5JUcqpbnHTvjkysjDOFwu/wqpcbdSqhbrpzZz1pZyd5?= =?iso-8859-1?q?jPV4hXizsnfoOjvBTSirn6dsalUGnoj22/yFTTZmZMd9ONonYlaNuODUD1um?= =?iso-8859-1?q?p+qQ32K8G098kEiNQs2Q1KSVTHkXXgprPC2nMhlLQx9C9cMoIFgSeW1v3A/2?= =?iso-8859-1?q?q5tubp2QaYA1QiftstxYLsXpCGTw5TcJcpZph4qgT+/mXN8aHEiLr8JLyVXr?= =?iso-8859-1?q?3OInZN2s/7+qe85wGOS6i3E7Qo9MMhaptW5S84sy2TaTsNmaNo+HiLL9QBjv?= =?iso-8859-1?q?fc87IzR2B076LdVVXeFPmKOsaANQfyQvNhUYkOYHYMF0X8DuXkfMMnhi8bjT?= =?iso-8859-1?q?5AfoWehs8fZ0dKW5Mq09IjkJ5QpZP90bj7TdkqxV2r2dAYxmPPdesDgoVkpp?= =?iso-8859-1?q?V2QMRNbfHOIYBX+Fu+jWk+HReSszDLcZFHZbd7G8+4a9tEcEax5VxJdYHUau?= =?iso-8859-1?q?gghbABAjGpRCN1skYNHGQ0UnaJCEhStOCnbY+yO2AUiXP7h9k78NqOaH4pHh?= =?iso-8859-1?q?T5SVLAK43Db6JkMEvEzmnRTTF9doujXLEAWTNP5HOeziMcqtWhaOk4+ocy8O?= =?iso-8859-1?q?fh4b1VbRbpdFB+zbag/zIGGp4jD7jZQH1NvW94ktRscYjJMEfimzeHPZS6aZ?= =?iso-8859-1?q?OshKxEMJh7Y7wMVJhqwX1phf5hMLb9a1/7ynezPeeWJjDtSvtfJFzvcdvyCU?= =?iso-8859-1?q?4f65Gepa/iQqh1DuexkBrGIfz5kO5Osd38+1G7QWGfnrEaNiCbbwOpzGS0c8?= =?iso-8859-1?q?dWvFxcmBy46Vxb42X9frvviGXXEYS9oZedlyXfAarn9NTeAx/d01zu/82uAs?= =?iso-8859-1?q?mzv6aTsqA++G7JA9qjPIolM4W85Wb55els/unj3igh9vYp/odAtxZLghB2yp?= =?iso-8859-1?q?i2ZbsZa3dCOlMP5rMf8xfpU1M7fQGsEMnnL7vivcniJ0KaElhWDhRPzmeF0H?= =?iso-8859-1?q?FSdY=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: dd402a8c-678b-4878-e2bc-08d9dcba00fe X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:42:48.8055 (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: KdQOI9rbEU1DV/T6+acUVGQZdYJarLJnno5XF4Nh6zIe3ir42Do9dVTOoQVIgmr9JE7BkH5VKAYQzZ0eAyl4msu/TG8791Q0vbVXf6uwn5U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR2P264MB0196 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: CD94B180002 X-Stat-Signature: ybo8shdrajg3mw8aprga94r6nc59mt8e Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf06.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.12.80 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1642754570-876187 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: arch_randomize_brk() is only needed for hash on book3s/64, for other platforms the one provided by the default mmap layout is good enough. Move it to hash_utils.c and use randomize_page() like the generic one. And properly opt out the radix case instead of making an assumption on mmu_highuser_ssize. Also change to a 32M range like most other architectures instead of 8M. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/process.c | 41 --------------------------- arch/powerpc/mm/book3s64/hash_utils.c | 19 +++++++++++++ 2 files changed, 19 insertions(+), 41 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 984813a4d5dc..e7f809bdd433 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -34,10 +34,8 @@ #include #include #include -#include #include #include -#include #include #include @@ -2313,42 +2311,3 @@ unsigned long arch_align_stack(unsigned long sp) sp -= get_random_int() & ~PAGE_MASK; return sp & ~0xf; } - -static inline unsigned long brk_rnd(void) -{ - unsigned long rnd = 0; - - /* 8MB for 32bit, 1GB for 64bit */ - if (is_32bit_task()) - rnd = (get_random_long() % (1UL<<(23-PAGE_SHIFT))); - else - rnd = (get_random_long() % (1UL<<(30-PAGE_SHIFT))); - - return rnd << PAGE_SHIFT; -} - -unsigned long arch_randomize_brk(struct mm_struct *mm) -{ - unsigned long base = mm->brk; - unsigned long ret; - -#ifdef CONFIG_PPC_BOOK3S_64 - /* - * If we are using 1TB segments and we are allowed to randomise - * the heap, we can put it above 1TB so it is backed by a 1TB - * segment. Otherwise the heap will be in the bottom 1TB - * which always uses 256MB segments and this may result in a - * performance penalty. - */ - if (!radix_enabled() && !is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T)) - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T); -#endif - - ret = PAGE_ALIGN(base + brk_rnd()); - - if (ret < mm->brk) - return mm->brk; - - return ret; -} - diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index 154a5a860959..d28003132a51 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -2171,3 +2173,20 @@ void __init print_system_hash_info(void) if (htab_hash_mask) pr_info("htab_hash_mask = 0x%lx\n", htab_hash_mask); } + +unsigned long arch_randomize_brk(struct mm_struct *mm) +{ + /* + * If we are using 1TB segments and we are allowed to randomise + * the heap, we can put it above 1TB so it is backed by a 1TB + * segment. Otherwise the heap will be in the bottom 1TB + * which always uses 256MB segments and this may result in a + * performance penalty. + */ + if (is_32bit_task()) + return randomize_page(mm->brk, SZ_32M); + else if (!radix_enabled() && mmu_highuser_ssize == MMU_SEGSIZE_1T) + return randomize_page(max_t(unsigned long, mm->brk, SZ_1T), SZ_1G); + else + return randomize_page(mm->brk, SZ_1G); +}