From patchwork Mon Nov 18 16:17:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13878825 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 34438D44009 for ; Mon, 18 Nov 2024 16:19:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FD026B008A; Mon, 18 Nov 2024 11:18:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 70C3C6B008C; Mon, 18 Nov 2024 11:18:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 511AB6B0092; Mon, 18 Nov 2024 11:18:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2198F6B008C for ; Mon, 18 Nov 2024 11:18:57 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D4FE31C5478 for ; Mon, 18 Nov 2024 16:18:56 +0000 (UTC) X-FDA: 82799721270.20.DCB9619 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf25.hostedemail.com (Postfix) with ESMTP id E7FCCA0003 for ; Mon, 18 Nov 2024 16:18:17 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=T9eoTatX; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Mq2Ai5QQ; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf25.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1731946667; a=rsa-sha256; cv=pass; b=ClQiyUeoeOMcamEb2yH4WKQMZJoHg84OX0NGuo6UG72Qn3qLEakTckEZR9yWC8jtDMy2S9 CeVM/FVufyfrlwZqFHK1GptPtqXpRovSlkfN0Qui0AOFpBmV9F8bDx9wd5iCrwW5X7KCnm ZgldxnIeAJirQbv1QeSg/Li/yE3LNcE= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=T9eoTatX; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Mq2Ai5QQ; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf25.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.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=1731946667; 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=DQOybQXxm8QK69H+ekYsnrRu/djaUo/ByvscuyUxD20=; b=pnQ/CjgTyo5uCyAs7LmbV9qthzFKcLvNlaqTALfhb0k4/COfuIqMgV+PHetl3GM9lrmqL0 xfOQ4NdSEvZ8VI2kEiC/0kgaEtkFu4Yz0UMKY3zeLlaFD9P0T9TFgULjbyZoC98WVPiTNW wNoBjLBc/X+5RANlcX2AkCkmpi33ZzI= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8QZaD009482; Mon, 18 Nov 2024 16:18:43 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=DQOybQXxm8QK69H+ekYsnrRu/djaUo/ByvscuyUxD20=; b= T9eoTatXzPU7SqlbkX0UOJbybDURIDq8nYa634fCa4wg5mLq/SHVgHqE63bgvVYr RF/1StqRGgyg5as7+xCVTWYhydeYt3HwM6rgBPxtCySipc/b/aGzd4PW3/j6ZKpR McBYTJureTeayOym2f0vsqMZloilZ8ClOWlqoMGRPjXqStPG6bqxQ3e1iOCTPcBO ARcgrao8gJnADYYWcKsLVngwLkg8VZq9bZRCl4gMLmLicH/fMuE4zrPShU7H9fue vmUDhqMCqLt7IXcJs6A4Ziod23Y70ABkWvr2WdRdK1S6k2jOPGvly7ZijIH2RgOa Dnp5qh8qKjrZi4Y1Q5QYvw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42xhtc3425-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 16:18:42 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AIG1G5k009102; Mon, 18 Nov 2024 16:18:38 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2045.outbound.protection.outlook.com [104.47.70.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42xhu7gxfh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 16:18:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a9kGyHRfaA05D4JMCzfZfqhSZGXtsJBSNj6hp9i4pl0mHOfihSiyc1Pb4T9nz4BsydxzJGGdIu+5bpJUnssC5Ch8ARSwGpbOcJs2ml44yb8FlFSgkHzAlhQdIEQ9kPpue8BWDum0ckxTBAMNpRN6E+J/e/T+OhOckBGmz6xlYrPNxlFQ4+wFBZi3EyY9sPnt8x9iZR8N1PKMUao1HvGMKJPNB6RcU01xOiFqVBYFVCLvN3Lu30QReKbpacCEQ4kiAWUh7WNMNIqXzitRCpGoe2hNRMjucO8+InrzgWJDpE1ry+GftLFkW7EGsCGb5OCa0LhWDvUtDeg6CeyjU1VisA== 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=DQOybQXxm8QK69H+ekYsnrRu/djaUo/ByvscuyUxD20=; b=LzZuJGd0vT13990tUQNhRLIZkUyAclpavRltVcgLBOZlc6KGjY0CPypsOZZ94dagq+ZpGyZ56361yy/4gmcZOZIbuYIFI/pEzZR6qCxyBw1YTEdJ6oFN6Aj7CNz+kuG+Twjs+DhS2GfajhztR7kl/oPr8kSzAGs6UTbmqZFVSexAv8UzJoBMrUdpR5tWvEn6dghebmk21Rqnby3ipF4QxqkEf+dvOrLnBPsHGbJYHqVZUTFDP5gKQDvBsCOuZ5kUv+vYbIfKP+bErUdf2GzZgMJJLlms8ikW5cAOKIBSlS7GNlz8JGfRATKxrx6D+ylniphNIkv+Xvh0lsYDXesAOA== 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=DQOybQXxm8QK69H+ekYsnrRu/djaUo/ByvscuyUxD20=; b=Mq2Ai5QQ5d380hUSEmB19YxNwwe3CwSHYhhRTbRtmhhIhLedELbYPmke4PYDZuG02x+ibuGMZ/Boz7j63GKFkbCtO2rK27FKx1R9PW1L8uP+IHKvah8o90unqJuZH+s22pW3WrnlERqElzQODfqg9ZWk2RTw+hg9SsvGS3V4Yk0= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by IA0PR10MB6819.namprd10.prod.outlook.com (2603:10b6:208:438::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:18:21 +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.8158.021; Mon, 18 Nov 2024 16:18:21 +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.1.y v2 3/4] mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling Date: Mon, 18 Nov 2024 16:17:27 +0000 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: LO4P123CA0044.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:152::13) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|IA0PR10MB6819:EE_ X-MS-Office365-Filtering-Correlation-Id: 72dc83b8-cb10-429e-c549-08dd07ec9ebc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: a3RY11dY+5cEUnk1B2GHk1ZLueSJoq/xxZyAOgoEqYh+L/4msjI1Ew8JWu95OhB53yUwGVErFx9vGz1rc/q9Kbhjc/0fUgKFckQz4ntBVu8rM9O6mwDlmWWJm2E3S6SDf1WMbpDMS4hdhTmaZnL1YVN7X5RV5G9gKUfMbTs/gvFt2sLiMuZTKMOBQoep+2NmOic0qKrlsAETZRwQA12er/QkzNhXBMrD4aB5Be+CYMqwpq49J4Xk77ihmK45upU8Ga6F7O1oGdGgjxD3WM0A4+wavba5S3i8RBkJ6LHad4mHVP9ez7zYh18OkNkh6LEc2K1eY8SAB5hZB/YL1eW6bpIdH9hv+kkZOBRRcC6U0WD3lAZA2JkLMNB/+D87Z+0rFp1m+/sefIq90Sq68gR78t839f0imZFMGsWOXx1o3xxDbyVUOVxy5J68/wdDziYoT7/HUa9lXgP/HCZQkyvN8TGiShDFGRqPHREwcPnvEZS4Jriv4POV2SAHKLhnyyehBaqxHQHr6w6VrcxRbFdTmEWWsaGzhEuzaNxyopodqAe/ukiPZ6fDGXB88it3aavtR7XiX1hDJEVFDKPrlZfpBuogyQkr0rkcaOBzypjcJKd6DQW1215WIxNAVF2w+DCHJxbWis+ZuI2Pe9qqyDBRsnzHyKSrW7AoSvnxT/0W7IJYNDtJR8DC9xy11fNavcg9mJdqE80K0eNz0/JXFdnoVHwjiqJyQ0F00EaE/7qkkfGJgKuayIXjSx+v4GoKGST5AfO0sIhefINXdyUrqbViKGgYL0Vtqsro0VfPNspVBnvCsElGt3hhr9PCeKxTSRJbdYTx4PfzKtn+m2h4Ym6tp486bNG8Z/0hJxiFJ9Ttl5vDWfhyEuAjRKmQwG/Tz9LiFxS0YFGEgwTv8B1Dtsfr0/RI/7q4OeIeVPJV+ZzQhmM7KVLWktinyWicJxsb+dzGaq/LynWx1y08WB8nbsERE2e9xEOVK9jSlcYdfkb/Y6Dbf3quSMqu76crhxENJn0gfoRBjYmxSiNr5CTnEb2xiYL4ZNGCbQ5lkFBZIQ0Qz5Mvqf0GjuxDdk4BVo6qJiXmiAabL/qZfQ3Gnb8ILwlYPkXOaFHpgZstU0iFDptxnQesNo+LmZpM8DhGwZqg5bNg0aEpwVbYsMr/vZtgRoL3X90XvRfMe7H0/MaZugYoDFF0nPT+iC4u935JtIVm+MjqgE5aZAMoKubgUVzqUdsAZ212qK2Sus8sUWK1BfCjcd3iNlZQZLX5U209pyBRZJohH5LkQ67XV38H/WaxvSTTR1O1L+wriB0RsrT+IyJq2HWLGgWye7KVZpBHkm0a06NR 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dH2z1p72GeV6DftdIJ9M/pPUkYlIzWwHAyD9Fet9RZaFzOOk7lHmc+KST6pua5qb977hi5OgtRUqmaZj4qYBVMjRJMkGnyI2hJYzf/8E4IK+K//c07jNiOvJMSJxMAZWw48DvWMknwXVJ4lh98x5xwWDTTFZldWVf4LkfIPm0bsL0TSyIw+RHY7N3Spxyzf2Q9aum2rRxOSghj42bOfpnIYToWkO3gyV6ab8Bu+dBiZ7xT3dUlptXRlbZMJ+CnrWXN1YL8/3VcAQfIf4DsZEYp9GzrTP0aIJrmcRzALO/D49ClkUYeZWHRn28ai69EievT3GdWIF51TJlOonXG8yowgTOsEoOPXDBPOHSJ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Tm0YGnJr6TYoTZQfK+GDrJU2Nm1SkuxX8y1uw/C11pc+Ffl35Ez4xeTik77E6bSHIJbBS1q7Ux75Sz3VMBQZvI5kTvikIzf9KYa650xOVkjiuveoTDDa7pJw7X6xGOTHvcbs4WT8ijcUufXEI0exkEkZbPdnkN00+GMz9YhtgYWk16Kw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: maork1lP6r2+Azhgdt9Mbfu8BpkFLp4dbRKQT3sKFeZzQZMWsSLFPPed26+w3cbOT9wqSwwXkK5I39S4nAdDy3hG/G9UnhE18Ak4DY7UGDmY0fJrcjvwbYs8D/kOQx9BVWiIthK0r8PmWYQiFpQCwIhLiLHTw9kogqOU23YT/1LRmKa0ndETAyhw/1lVnXjhg8Qa7+UbOnxq04xZ97LWq/8AFPDBSS4w3jEx1Rgw5H4CoI5OBQ9SteRCjyoaL9aR8it3ph0+gpQM838oRnN4lN4I3n7gddhX3po0XVV0yfi4M3pv609lUoULxWTvL6BTjSuEOVr4yBWC3rbAFdyRusPFkp3oofTyav0ISTpEPHHN6s+JYk68z4Os1KYz4vJkZJaXg/VpG7nQoVWo0HHwoyEfXqCBZGZm8roLm4/EAZKSSR6K6M3J/2I987Py0S0LS1VJwjSx1pH/SzODdpUA0R2iR3mzug2YWcCdDWZFfd5nTLhC5A4U08i4dWwPOaVzior9qqts2Ees1QCQwWSWvuvelu796Af8EcCDo/OVZRO3q03e9Wcjqta85iZEz4JrJykiTYvVL23cLWchleHlOHoDRIirYF3JNTSQK4Slb/Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72dc83b8-cb10-429e-c549-08dd07ec9ebc X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:18:21.5963 (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: xoSnbu77s0kUz83tC92MSss03UNsQYyQqWq7jjWYTyy1m60mmLMt5h0PQd7//uvpgHWcXDkrd4YxDNUz3Yg3Kj03tZXXfU7hRqVjNF/L/PE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6819 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-18_12,2024-11-18_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411180135 X-Proofpoint-GUID: M-Q7TO7tHsn5W1cYUrbQ9m-98e7SGbHF X-Proofpoint-ORIG-GUID: M-Q7TO7tHsn5W1cYUrbQ9m-98e7SGbHF X-Rspam-User: X-Rspamd-Queue-Id: E7FCCA0003 X-Rspamd-Server: rspam11 X-Stat-Signature: kzxstw6znu9mfu8or8rjea7wpx6a6tia X-HE-Tag: 1731946697-97996 X-HE-Meta: U2FsdGVkX19kVol8yFw107z8xJg1Kyll2WLui8Q95Q+27aeb2NdIllTniX6kn9F6eHNbTtlDY4T2rhEs9nTvkO4+GSr71WWXELcueIdZGqIomlQuEJMG4wTBx6xjBaDGtsDDg/7cRi00cdbG3csD3/9E4VH2vLM/0kzn8AIy9ZFxt6SBGa4gueV1u/Io0HGR2UhN3ksU/hEcnfS0CGvwzUSB5s6ZgFymSnxk4zMkR0CFylNOjJ7wcog2IGCSJjzgWOWGsmmarzbpycf2e3sSdUwCpbxx8RZiR5wtXuUiLkHJqgybmLNhYX8bnIUM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LSQtR/u5jPhrXYYCrl82ulJe/+GVl7HkVIP0VsQoI8QBC7tz1pPQDOcV/ywA7h3tRA716yCFa1J0SivgNl8tZMadSGdKU5eSMw5zZ//CpQ4WcjoW3vUx6gWXSoFJia89+CJjrVqaEpC4B3255LePV1vJS8YLEhQkE2kOV1hTHbzLAUiuEZlI6xHIcHN35v3bJmeCu7EThuewhCkHc+Ni+39MlRkXqfBMWi63mlIHe5q0tG6LUgksARW1Rzp0QHEBVD2+J8jTOoXYfr6Slloeq47ynS1xTWK7DE9wrQtQOuCOYkom0vcc1X6d6eysUi9dl7k5GgkeGfGpXq+lEhEsimXbHcrBcYLA5qhoIgYrVHS8+t2zrX8VA8gWZrW5utOlJ+kZjxFuO6khTjeKxB0HkeKvDXidYlXaNvUjhXG95LF373eSJ2TOLBDL1dXMLnsRPmJK5oQlAbPAEEl+LoftvHuZrJ7G9a5Ax59hvgei0yTjxzmEFUdtA8g1VGq73oOubiXQxokqz8E84/Jja57H3el7iAVqW0sGcwumjYByKXnRqxwLjrSAdsz1+S9KRu9B+ +nyR3Z6W 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 +++++++--- include/linux/mman.h | 7 ++++--- mm/mmap.c | 2 +- mm/nommu.c | 2 +- mm/shmem.c | 3 --- 5 files changed, 13 insertions(+), 11 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/include/linux/mman.h b/include/linux/mman.h index 58b3abd457a3..21ea08b919d9 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 @@ -90,7 +91,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 @@ -147,12 +148,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 4bfec4df51c2..322677f61d30 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1316,7 +1316,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 e0428fa57526..859ba6bdeb9c 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -903,7 +903,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); /* vm_flags |= mm->def_flags; */ if (!(capabilities & NOMMU_MAP_DIRECT)) { diff --git a/mm/shmem.c b/mm/shmem.c index 0e1fbc53717d..d1a33f66cc7f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2308,9 +2308,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 */ - vma->vm_flags |= VM_MTE_ALLOWED; - file_accessed(file); vma->vm_ops = &shmem_vm_ops; return 0;