From patchwork Fri Nov 15 12:41:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13876187 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 BE30BD6DDF8 for ; Fri, 15 Nov 2024 12:42:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50B576B00AF; Fri, 15 Nov 2024 07:42:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BB5B6B00B1; Fri, 15 Nov 2024 07:42:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E9586B00B2; Fri, 15 Nov 2024 07:42:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 077BF6B00AF for ; Fri, 15 Nov 2024 07:42:38 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B7C80161696 for ; Fri, 15 Nov 2024 12:42:37 +0000 (UTC) X-FDA: 82788292734.28.E3224EC Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf24.hostedemail.com (Postfix) with ESMTP id 77CAD18000D for ; Fri, 15 Nov 2024 12:42:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=GkttqdLn; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=DwsAraHz; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf24.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731674465; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=spnAHCCRbHps3QlTZk9KoUOkxA5rCBm5i/Uk9iQm9cQ=; b=oVDf7hoa9ijrxkl62mmYmoiOJvjioDvuY4+4gd3CMQ/G8jBg0V+Ttd8pk0kCwehgruoZzS 51zuBIogKhkb8v+HAQ2q1PQFPLTnVTJMh4CCczsI8Lj7SSWBF2acFwnd5xq8WjPzQS23WJ NtxcbsxvSKFIchxhHS5x/NnUUkje/ME= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=GkttqdLn; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=DwsAraHz; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf24.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1731674466; a=rsa-sha256; cv=pass; b=IKWDzSir2FO9O8LObQYW8O8aVX5DMoqXYYJL27JrE+z+eByrcJgaeDIo213UfL4uRDPGGR dNJ9Iz0vYEJ5VYadAe9J7xS/D5YQ07Bs1f60hugCnUFNIBdsMvEniXVLSU03EcefWsbOYM vN5sMC1bRo9dggt1bNm6srqLmJgxTXo= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AFAHBL1021442; Fri, 15 Nov 2024 12:42:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=spnAHCCRbHps3QlTZk9KoUOkxA5rCBm5i/Uk9iQm9cQ=; b= GkttqdLn0EKqwLEZII9F2CN9sId8EnPNvpKOkk8EnAJCMLwr61/npX0nRK++zoaU 2S0V04UcrmbevrGRG8q7oOQFkD7xZFbVSG5HJ156XHipRu53bojL4k+kPlMhoGYV g9bdkiD9R85GZNfFUQkyCJ7Tuh+IAP4FxkucuKuVAAkubUZ1Ee56sFPBLBwT2xBt 3aOjUb3oFJ6FfoVvX1KkIlgONvwBUxKIbbXLNk4bg2lPJvkTu76Dl2RPLzucPotR SKu7O4JU4hMwAG+JjxW9fNBzZx4S3kIzvRACgydWF2dbl5y1mH1oIFIkm97jDazF YYUoOqJ6/vd+vdu24b1s8A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42vsp4n16n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:42:21 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AFAe6R0005765; Fri, 15 Nov 2024 12:42:20 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6ckve9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2024 12:42:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=maS2x0Y6LiBP3PpOkYDiKfVOdDhx2XAjdzS5LiD8xETMFxMdkceirb8eu9mQp5yB8GxmDi3VmpleqFHKFqozX9MXmyzJaJvteJufsfZZpLaUJDIVqfZfSFf1zIOLA2rYsLJB7NkZWpSMgdZ3eH+JSE3+RkaOMXO8DGNoUghoDYwkDt3R79vJ4SWOvmzhdfLwNMlKIncIRC44pCdThz42EbMRwO54DY1OlLI29Wa1eK6qrQZA0FtOWGmW4DBTf1bBvXX6b7c4fv7cv0kpo4Wpq5dOjweCIJhATsYf+XU8U9l47ftUD5syaz/v4oECkQB3I9q805R+xMhzJ+NUbhYELg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=spnAHCCRbHps3QlTZk9KoUOkxA5rCBm5i/Uk9iQm9cQ=; b=NuN24qKlNFPM6WLF+ZXYivVvwOjJmFCBrCPp9MO5cku04Kff7aZFvFVIxBwrfSMjIK28lJdhXrxRf9GIA4FQBjIwiKUb21gKsj45Gphb741lL/8nMFXBu9x1/UlQPn2lHrVGZHpPHwjxKzD7Uzt8QwM+OCFxF5Q9id2p+hr7iKqeLkykgqOybhglVsH/XTQ6JBw+zlv+/c1ESIxshumrBFfYUOyo9E/CNbxPXL6IPVj5fd+2RidRhCf6fHT+Jq1oiVGm6FzCa+B31+Dcoivz719FuQtmYTd8HPK555KsYLJKp7eyYJ2ujQvAWT4ZEnVXHGo+aoZw7sys43+X5SzbIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=spnAHCCRbHps3QlTZk9KoUOkxA5rCBm5i/Uk9iQm9cQ=; b=DwsAraHzf/gzgipfJw0qWPlV5x8dDOxs0hew64hF0ZtJI1hvyEt5aOO4eMCBbJJn4CYqLLhFVVaWX95jPji64853ZzGvMm7WGa9d6EMIsyMbElOPY/7SOdaIEXjYvzE6a0iWjNwBD4Noc5PL5QzOLAbQaWm8VYVMsjqBLgHWno0= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by DM6PR10MB4201.namprd10.prod.outlook.com (2603:10b6:5:216::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Fri, 15 Nov 2024 12:42:16 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%7]) with mapi id 15.20.8137.027; Fri, 15 Nov 2024 12:42:16 +0000 From: Lorenzo Stoakes To: stable@vger.kernel.org Cc: Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu , Catalin Marinas , Will Deacon , Mark Brown , "David S . Miller" , Andreas Larsson , "James E . J . Bottomley" , Helge Deller Subject: [PATCH 6.6.y 4/5] mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling Date: Fri, 15 Nov 2024 12:41:57 +0000 Message-ID: <7c0218d03fd2119025d8cbc1b814639cf09314e0.1731672733.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0036.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::23) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|DM6PR10MB4201:EE_ X-MS-Office365-Filtering-Correlation-Id: 0312004c-47cb-49d6-acfd-08dd0572ef9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: dgTI7/rkKOyZzNkmUhkYEl+nOYoBKmyWIqe6jDyxLsljNMmpMgHoMj8IlsGZCrvwmAK4PbFqAMpxWiRECfpYJG9fyuMfH9RC/PJAHZrPoeSPgIr47hWwFWF2zsdH16IIdDzd81Z8gLZ59e6kZJY8PO8A1/8RLRmDTQx0iQGYWiJMCIn5bDTOttUN8ExyqkJEQMPtlXhkRgV2TjIBSYoMNRupuen/ScaxAmpMEFCO/n2mV6plfmPrwYbQt926w27XBSLB7IU1CUhJ6li0lyBtdgK40SDHhh/WBtLzLK/12Oxbgwpm3stB3HZezuzXLuGM8FFKP61Kp2Pnm8kw/OzgWfAM1sTwRUxuUwTNB1dq+pgT8qp/BB7b/E9Q0MYwKYBM8a5OPFXBAO85HaZgc1WIVt8aaHd6UNRKhRdPopRTZje5SwdQiLYpXGE8GMmkreTDReBsUESbHmwD/ouY1N+/NrKBILDDotteBMShGz6qmDOT+MkCZFA7Omd1UCV93eV5HYYRrXVfixV8USXz7LzHH4KIijFdOl3OlCQE+JPYoli3sjx06Bq5Ir6TDx2Nu+1XfnSB+fTALVMQ1SHCT/Qp/1hjNIzyRGe4WImkAeO3JkwG6voE76FwXENEMUmDRVgjd0Us3gJWzE3hKe4j1/qDh4pENe0dTZKXVBv57CfqPul2GjrjC9CBXmIDkYBgzTKklibw9HYFoohP1ZAVYp9JzAct890esX0zwT3GVnXb37Ac4umUXuCkah5KiYwPTwZePOg33mEgM1BkcAiUl9on090JmLbdzJyLP0rmgxOgPh3reD/jNdqXxSwI5xXtYOeb3fYTEuzvtjyUgkfL5crZvBsiIc9rDQBJjqHSN3jOkAqOxsqr2wQlGwmWWTsWM6sn5/26OgWIF7RllskFPnA/nahAgCSKcMAPOArCCtL4dpklEIuL9i713RtWtRJTwE9x7PSo9rQiqF5Up6re2vct6O/DDn9zFa01lwWW7Ry5VFRFF72B37Sx5rY5AWB4bKrePmRiqjWE6COhbe4jAIDjbqlOb6Ji+JJYLGIyUO53RwIIlMJgXtWYzAGN+AGVnE4xJ2rSWe/k9u3nAzDVVYJ56PN9K9zqzVcveGt5w2M30S3kj5hDkk1EqPmlu3ZLMkUCqTsYAmXijVYgvTcVKv2a2IvzukoSU/qrXiG9GoW1LkEtoUsmRkozUzeNxpvzPV3b2RAMgqbCDDD4+r7H3rLR2p5rha6lYsdX/mGMhWAl9h6qhRL89Qk/sYi0ODZc07P5Ot6GqosKM17xdWbRMh+0hGrLgYxjrd8H3kNEYIbylNqZ2PAr5k7dFbrpH0KUBEXn X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9HU+N19vEJl2+dCbk+mDd43BICK4Qp3E3uMCr5cl3kJuhVF75TXnCU160H5EPnT2pvXmVWiGAOYBEyVduadxTp9u454nFg0k4y4Zr9RgmD7Lt3ZvGGuOFw+EYx3e7I0Hk0uierJf9sgOZsRIWOme4SDqxnv4N7rn6HSCa+0vhKCmqZeeMpitMmN1Qys4XUAEnEHSSDw9ZS+YyXGCK2e+rM3Om289F8Omiuo2L3Zg1oL6Seit+emqsz+w+Dt4z0IQFp0Y02df7qrewN87A78AKFlVnI8KAAdJaLzVFV6kOkwN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oEJDCtg4H5fyGrE6aX4YTGkMyoOEbFgfUkhRBcg2su/y2ZYrHQ2+NuRCR9w1lDOOrG2+aDN+ro0dV38vETNU+eodJlegoZsvjWmha8ZkFXSJnqU7NEAK/uWxoqBiGvw0K+rlUu1NnC3Ag+dvbHAluopgMPTuOWjbiUkGctTBRhGRkexuBNn2jvtr+GP45xZRn48p4wTNn3AQ1emBrZZRmKXnBcxKS/9tS/XySrEtcbrg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: TpCaOwC9/y5j8RpCCO35u3LRuiDG/P+NnLEy2Yqb1uMCcuq72l772GIq2coPkIgYMqo/27k5xKHcw7WBGHzVl1Px9aNn0dmoUKAmS6YDqQqOjhVnhT2r5C1NkMrnZ8DWCpS+21KS2tyKMR8mjTv1aQd0+Y6siA2Dvl49dan+ZDcwgGhKgFniKvbiKrCOwN3BBl+L5SlXCFqMBYZre4bYnGobKOU5QctKjVGJZWx5aCC8AkOHXBGDyVFk4s1MbZ0jEzNsY0u9nu0laI31c2Ddtq7R4e0YU+S0L1KElQpUQLArn2BVnPmZDAbVAtFKMZh+kN1YeALY4a91gjbDdQFtu5bJx6/q/YG1qFWyGHPsM4CnX+Yia4GPdNYB2QP1RVCTi/+TnP+cUWL7UKvwzsiZ2qi+RNCUnmptBQRaHiiMRDcy0S+Gnl1M+ZnCdyPOcGWK8mIVz/e5IiquzSHMh3D2Al3W54lQu7l3iZNKs1809xW6hYH4he96ReTMyNBXortzioZQshfJTJ5ICQ6kX5uFhfIdICSxKyt64mcHffaNu0ZifQqqpRkSy3dkxysvEtGce3RYIv6wR0tJAPo+hgd0H6WmuWk7MiLgr/S/gg9TgPI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0312004c-47cb-49d6-acfd-08dd0572ef9e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 12:42:16.3598 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IMHfufEIIX2jE2jUTH++hC9ba0U2h3Kw9wiQ4EOagKiF2G0bDEHTDO2o+hWMQSed6gZOpG1jg7eF+4lsNlDLMa7nXsxOLdV38cB+SXz5pnY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-14_05,2024-11-14_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411150108 X-Proofpoint-ORIG-GUID: RVwjD-P-eMj8lzbvHWkEcg-Xd9D5K93J X-Proofpoint-GUID: RVwjD-P-eMj8lzbvHWkEcg-Xd9D5K93J X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 77CAD18000D X-Stat-Signature: oo86d7qke68mqd9w6mwoigywy9t91ybp X-HE-Tag: 1731674548-157626 X-HE-Meta: U2FsdGVkX191R8eAW7Gk8GNkVwvigsxzDHqQVMN9JyVOuhLkKBR0zPUTpu28OJq8Q2JddXM7rc37dRw1HTUprDLDbn7QOPJJAqDf1/AUo72Xy2HxCwu6ycrUTaHYU4mCLbW9pIFjFjqMykf7XleXApczTA/YQUhjz4Sxjte7TzELr2qDCalHcLWpfvmWbJ/LnbT4WikySO2XK7g/0f6t10sRC2R6T89MraQbkRj4wseeVAMcGfZ/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wuZOpvw+19vsfVS2QoPxv8bXF5d+q/7ouptQHt7AGJ5bdhxgaoeLAwYBJrIKi/tzhdYKYL5r2p/1rd10RKbdmXQStGAwouM2goQB7BFeDq8LUPEUog5cTkSaYEMGyy5xJhFSBVgojDKdHimgBKadxB96ewizza2WLDzsRsZM7FrscQ0OAN6SZN77p+GlcA/exoG8nAOvTqvY2BqQcowToGtgJZXD2n/SZ0TJoza7b5Lnu6VxjuR5uiafIZ+7OEj5mVTUelpWcBN4jH4n0YFEcWNYCAZxd5RWt5adXyzEJNB9SPi295jSh0eB82EALbFi4K7+8XuiMxXMhBYAgVpyHAnz3g8+pfOBFh4K2zpcBRrwI17ofqqlBm6kjPB/tnnAG8fhkQ/vTEFDLR3auDnELVp0tcNzBisgCFYK5Bv3RGsZelYPHlV4Uk5/Onnd2+NCVFg0EVG1jzbXyyCAw7ETKrJXCEjsDUC4rkaVZ3O1qp3TT950nmEcQ/47TvRCm+C/DIMobZ0r0siU2F5jiNc+1oga0GnHrgyqVqVx8DwVHJnpiu4uNhGJPa/5ndzKNxkGqZIewxh39LmZzrZwd+UBS7YjLnIL086tekMFO98HLaQUMCCE1msLG5FYQUzHbFEZlYM0CfuS3Uc5cKLHM63j4D SWTpqhgW 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: List-Subscribe: List-Unsubscribe: [ Upstream commit 5baf8b037debf4ec60108ccfeccb8636d1dbad81 ] Currently MTE is permitted in two circumstances (desiring to use MTE having been specified by the VM_MTE flag) - where MAP_ANONYMOUS is specified, as checked by arch_calc_vm_flag_bits() and actualised by setting the VM_MTE_ALLOWED flag, or if the file backing the mapping is shmem, in which case we set VM_MTE_ALLOWED in shmem_mmap() when the mmap hook is activated in mmap_region(). The function that checks that, if VM_MTE is set, VM_MTE_ALLOWED is also set is the arm64 implementation of arch_validate_flags(). Unfortunately, we intend to refactor mmap_region() to perform this check earlier, meaning that in the case of a shmem backing we will not have invoked shmem_mmap() yet, causing the mapping to fail spuriously. It is inappropriate to set this architecture-specific flag in general mm code anyway, so a sensible resolution of this issue is to instead move the check somewhere else. We resolve this by setting VM_MTE_ALLOWED much earlier in do_mmap(), via the arch_calc_vm_flag_bits() call. This is an appropriate place to do this as we already check for the MAP_ANONYMOUS case here, and the shmem file case is simply a variant of the same idea - we permit RAM-backed memory. This requires a modification to the arch_calc_vm_flag_bits() signature to pass in a pointer to the struct file associated with the mapping, however this is not too egregious as this is only used by two architectures anyway - arm64 and parisc. So this patch performs this adjustment and removes the unnecessary assignment of VM_MTE_ALLOWED in shmem_mmap(). [akpm@linux-foundation.org: fix whitespace, per Catalin] Link: https://lkml.kernel.org/r/ec251b20ba1964fb64cf1607d2ad80c47f3873df.1730224667.git.lorenzo.stoakes@oracle.com Fixes: deb0f6562884 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails") Signed-off-by: Lorenzo Stoakes Suggested-by: Catalin Marinas Reported-by: Jann Horn Reviewed-by: Catalin Marinas Reviewed-by: Vlastimil Babka Cc: Andreas Larsson Cc: David S. Miller Cc: Helge Deller Cc: James E.J. Bottomley Cc: Liam R. Howlett Cc: Linus Torvalds Cc: Mark Brown Cc: Peter Xu Cc: Will Deacon Cc: Signed-off-by: Andrew Morton Signed-off-by: Lorenzo Stoakes --- arch/arm64/include/asm/mman.h | 10 +++++++--- arch/parisc/include/asm/mman.h | 5 +++-- include/linux/mman.h | 7 ++++--- mm/mmap.c | 2 +- mm/nommu.c | 2 +- mm/shmem.c | 3 --- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/mman.h b/arch/arm64/include/asm/mman.h index 5966ee4a6154..ef35c52aabd6 100644 --- a/arch/arm64/include/asm/mman.h +++ b/arch/arm64/include/asm/mman.h @@ -3,6 +3,8 @@ #define __ASM_MMAN_H__ #include +#include +#include #include #include @@ -21,19 +23,21 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, } #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) -static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags) +static inline unsigned long arch_calc_vm_flag_bits(struct file *file, + unsigned long flags) { /* * Only allow MTE on anonymous mappings as these are guaranteed to be * backed by tags-capable memory. The vm_flags may be overridden by a * filesystem supporting MTE (RAM-based). */ - if (system_supports_mte() && (flags & MAP_ANONYMOUS)) + if (system_supports_mte() && + ((flags & MAP_ANONYMOUS) || shmem_file(file))) return VM_MTE_ALLOWED; return 0; } -#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags) +#define arch_calc_vm_flag_bits(file, flags) arch_calc_vm_flag_bits(file, flags) static inline bool arch_validate_prot(unsigned long prot, unsigned long addr __always_unused) diff --git a/arch/parisc/include/asm/mman.h b/arch/parisc/include/asm/mman.h index 89b6beeda0b8..663f587dc789 100644 --- a/arch/parisc/include/asm/mman.h +++ b/arch/parisc/include/asm/mman.h @@ -2,6 +2,7 @@ #ifndef __ASM_MMAN_H__ #define __ASM_MMAN_H__ +#include #include /* PARISC cannot allow mdwe as it needs writable stacks */ @@ -11,7 +12,7 @@ static inline bool arch_memory_deny_write_exec_supported(void) } #define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported -static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags) +static inline unsigned long arch_calc_vm_flag_bits(struct file *file, unsigned long flags) { /* * The stack on parisc grows upwards, so if userspace requests memory @@ -23,6 +24,6 @@ static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags) return 0; } -#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags) +#define arch_calc_vm_flag_bits(file, flags) arch_calc_vm_flag_bits(file, flags) #endif /* __ASM_MMAN_H__ */ diff --git a/include/linux/mman.h b/include/linux/mman.h index 651705c2bf47..b2e2677ea156 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MMAN_H #define _LINUX_MMAN_H +#include #include #include @@ -94,7 +95,7 @@ static inline void vm_unacct_memory(long pages) #endif #ifndef arch_calc_vm_flag_bits -#define arch_calc_vm_flag_bits(flags) 0 +#define arch_calc_vm_flag_bits(file, flags) 0 #endif #ifndef arch_validate_prot @@ -151,12 +152,12 @@ calc_vm_prot_bits(unsigned long prot, unsigned long pkey) * Combine the mmap "flags" argument into "vm_flags" used internally. */ static inline unsigned long -calc_vm_flag_bits(unsigned long flags) +calc_vm_flag_bits(struct file *file, unsigned long flags) { return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) | _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) | _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) | - arch_calc_vm_flag_bits(flags); + arch_calc_vm_flag_bits(file, flags); } unsigned long vm_commit_limit(void); diff --git a/mm/mmap.c b/mm/mmap.c index d71ac65563b2..fca3429da2fe 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1273,7 +1273,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr, * to. we assume access permissions have been handled by the open * of the memory object, so we don't do any here. */ - vm_flags |= calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(flags) | + vm_flags |= calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(file, flags) | mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC; if (flags & MAP_LOCKED) diff --git a/mm/nommu.c b/mm/nommu.c index 8bc339050e6d..7d37b734e66b 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -853,7 +853,7 @@ static unsigned long determine_vm_flags(struct file *file, { unsigned long vm_flags; - vm_flags = calc_vm_prot_bits(prot, 0) | calc_vm_flag_bits(flags); + vm_flags = calc_vm_prot_bits(prot, 0) | calc_vm_flag_bits(file, flags); if (!file) { /* diff --git a/mm/shmem.c b/mm/shmem.c index 5d076022da24..78c061517a72 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2402,9 +2402,6 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma) if (ret) return ret; - /* arm64 - allow memory tagging on RAM-based files */ - vm_flags_set(vma, VM_MTE_ALLOWED); - file_accessed(file); /* This is anonymous shared memory if it is unlinked at the time of mmap */ if (inode->i_nlink)