From patchwork Thu Jul 20 08:39:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13320118 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 65B64EB64DC for ; Thu, 20 Jul 2023 08:39:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 06E412800D9; Thu, 20 Jul 2023 04:39:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 01E5A28004C; Thu, 20 Jul 2023 04:39:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB19A2800D9; Thu, 20 Jul 2023 04:39:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C89B528004C for ; Thu, 20 Jul 2023 04:39:51 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9F018A021C for ; Thu, 20 Jul 2023 08:39:51 +0000 (UTC) X-FDA: 81031342182.12.9C35BE6 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2065.outbound.protection.outlook.com [40.107.244.65]) by imf18.hostedemail.com (Postfix) with ESMTP id C4F721C000E for ; Thu, 20 Jul 2023 08:39:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=bTkPNhib; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf18.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.65 as permitted sender) smtp.mailfrom=apopple@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689842388; 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=ppehoSrCgyLFyaJH/ZGUibIGa4K8lHOftxZoQu5p944=; b=6WeH0/jxkbBGeaArnrOwwDiXbAyFL0aDLC23Zrn15UgxOGJLCcmYRGqlzDYFlW98cc9N48 +uTZ3b4AvnPiMJuX795lFmDf1TVa22EH/f1N1sfrCJ2743L2qP8HfswFvjbtI/gXQyupYZ QJ1LJI6TEeqS8yXN3WeRByaBFWs/ncQ= ARC-Authentication-Results: i=2; imf18.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=bTkPNhib; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf18.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.65 as permitted sender) smtp.mailfrom=apopple@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1689842388; a=rsa-sha256; cv=pass; b=1GieOKTPKVUaU/88NdRGi8GhznIoBelHvULmi1/CGGJjjpta5Z79CdSwpgJC/9oK4ox5vS FPigkS7mE6lu05oCaUbgMEyC+jndlZC0QfBWg27QZbAIUYXuR9KX2ACN/e6fRdpsWdu5d8 S3KA+GYnApq3cx+4j4QRIloXya1OVeg= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvSBmcOJMZUws4Z6ukb23Fh6o92px4nFt2UYG9ZhBJM2NKuwqXLKaHmGeNk0BxbnmZ8l4bQjX+Ms39xtuNGgPsELtlfNbjkCHpMdbKQkuXiL8/5UWqhPsbcCrnkeFupIW9YV7BNfuaJdeCJSVaBuUzfYhyrJJHl9SWQ6whLkZg2nJ7AMohtn443pd4tFnI6HPxK1hqLs8T1EIEC8OGmTyysFN15yu+mbZ3K9nmyMWyzJfla7SxPuuqexffB80x1v6B8NZfEA+bHpAtN8xTfNSeBmeiwCh80i+6j1iTAH9afX15FMM4i+iOwvdA+jZJ4IIajSsdUcQufHpxOvxtwBAw== 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=ppehoSrCgyLFyaJH/ZGUibIGa4K8lHOftxZoQu5p944=; b=hlpV1y2aptActkbla/Wo20ejvQYkw5zPb/y4EWi6rsD4HCJeWxbbSxgxoaTDbviyLbzQbjpaUf/z9EQffGIhufGNQprnbsUbbVGH80ZoEDQxKDBctWjFeTVYDKr97DEoha5gG1TIWce686y8GYUoCjIbWSXw5RPDV+g3lXO3fHxlhqL+5Y43lGvRlJBBo/FbsNcyBIIzIE5LXrZRwY9Px7xUz8lQJ2pvJ/o3d9Iz5invOinrMtmeEW9uTb8ykpG1cdi8fUH4HeqCpd6KVLBVSNUuBnbf9+0l+FxqheqGd4zTRhVOFaeRY3is12AyNjt8hQpyQSLspj1EKMRk4Cpucw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ppehoSrCgyLFyaJH/ZGUibIGa4K8lHOftxZoQu5p944=; b=bTkPNhibWjcJI2W+dadrFK6opdVBohDuMRqf/o/60Y2E6Np1/xohYJNtpj9ePv2X0XsnbCY6CnrL7wUN5/EJ20MIpYvbMn9q2QKuj3IQS/I66D0MmpAQLQV7L6ocNexTkieQ81NeVd97LBQOfpvVu/4c7BMTorotvfg1eknwkPB3fKDL/naZKzC3JTxjSvgNo/Xd1OE6wevDju1jRnKDIu2k8GMXuUDfZkNq/vGj6V/Uck3twj8RL4Ks7b+FhZo/gpI/IOAgfrE+WJqfjknaVOlh5E+9tYx3gOJxATOyWYTWF+oQQ40hfwr0PZypexlH3bb2dEvuSzvVqmd5BRpk5Q== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by PH8PR12MB7025.namprd12.prod.outlook.com (2603:10b6:510:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:39:45 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74%7]) with mapi id 15.20.6609.025; Thu, 20 Jul 2023 08:39:45 +0000 From: Alistair Popple To: akpm@linux-foundation.org Cc: ajd@linux.ibm.com, catalin.marinas@arm.com, fbarrat@linux.ibm.com, iommu@lists.linux.dev, jgg@ziepe.ca, jhubbard@nvidia.com, kevin.tian@intel.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, nicolinc@nvidia.com, npiggin@gmail.com, robin.murphy@arm.com, seanjc@google.com, will@kernel.org, x86@kernel.org, zhi.wang.linux@gmail.com, sj@kernel.org, Alistair Popple Subject: [PATCH v3 1/5] arm64/smmu: Use TLBI ASID when invalidating entire range Date: Thu, 20 Jul 2023 18:39:23 +1000 Message-Id: <082390057ec33969c81d49d35aa3024d7082b0bd.1689842332.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SY2PR01CA0037.ausprd01.prod.outlook.com (2603:10c6:1:15::25) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3176:EE_|PH8PR12MB7025:EE_ X-MS-Office365-Filtering-Correlation-Id: 71a9a0f8-e298-4619-4932-08db88fcde88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sVneCM/Dg9K30ylAW9TjIHNkuAsJ203YUZ7CqFkNHefMCTPdPuDCbA4YbzfTu0TtSxzvGupAkt5UD1ipoKHA8r/Zzngusdu2FqhYyGMNwfNvtXOS4rw052nGXRa6UNQev/m0IGXkhAgoRHYzcl+l9c/YqLIYogfz5qHJ43WsxrEdJqwh62qFAnDPxdeXhNOSQ5iuSATUXXliBo/wp6UqonTzxNu63hX6bR16PsTatvU2wXdT21WehheEX93VUqwNfDVbgYu7vGg+VqSZUrHtWbfAbJ28LhR/ZBTvsN/SVz2laNVVHuBmxWWQXi+AOysfan1pIhUzQtAvTZWzvL6ieY7/vapsBn2R+Twi7ixmz31m0UXfxKvBq0SIg/Ld3sX5tN97UpX6YbkA/8KS7z16RTH+hMhXLbavOJAc1srVjD9saeBeY8lv42RLiChF5NQBqzwRdu/oRECQEUE3egSZqlLb5D6bZ+sTmNBZpk4p6V+Q9aoXvCjt4LFpzIejfHkj+W12UZikkXLQef+48L1uqxIraG59Xh3c0dgPxy4vcfLGpqLrRqXi4ZMRYXcBjCpm X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(451199021)(36756003)(86362001)(66899021)(38100700002)(186003)(7416002)(478600001)(6506007)(6666004)(26005)(41300700001)(66476007)(66946007)(4326008)(66556008)(6916009)(5660300002)(316002)(2616005)(8936002)(8676002)(83380400001)(6512007)(107886003)(6486002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wHqiF3NjiI1Qkb+tt4ASongrf64ybb7hwVxTMrmfxWbMKjtOa2gzUg/zOxyCE9yWQdGIM2GzB1EeaZjb7QFk2GbrHJ1ZZi2My7vxoeIAFbrTWSnKMPvdTPmMQxptRc+6JvAjyhjZsUNXT2/XxawZr3XBRBds9oWQT7D7XMRuBE3vhzWscKw/zMN//uxEhFDa7ea47crbdM4L8W6x9w6bj+JZqxnbvFaeEq+40Vvw83trLfg36tfXip4X8dVfYeil40bpW1J3d0R+ql9Xwf3YFv4oiIVmkVqNl9i6xXWOu8DeYSnmuG3+CP5adYj9RShjZPwM+F3sGmUX4YHvpVpnNz3yr9tcWAYojt+DlhiBkYblPjju2Mae9zbHarWvCpeQzKlM4MCYh3rlNJkQSA44eD4hnPcWNXc949BBZO5BKRKCqeV2S9GyLLTI0ghXvTT8vm2pydaXHBmg3EcBHAVnniuVDMTyXLVRepDwLOk6S2IbrgPbaig1LacV+aNqqB5Vm/Y/d0LlM/BGWg3KZlj0lzzHaIGQS8lYxH8RnuT+U3SUX90WjfLl6vDCXbzsoZEc1P9Ujy3g/Aeo1msDc8p75ziFSlfrJHUCP8yZlP8gnhBIuwMVNyqYfytuiJKTRRXu7urCgPnwTvHewCE+QfYtmY4xASg5G1vfx6cOlwjtAowOyIBBEZLABnUSm5XYz+rrTCrMfuAW4x0+KYhrgiPK4F0JcWOjlvIP4AzFOzzv7/4jolQEjpXXLD4vFYK6jKROZ2qA4BFri1LTPc+AXG1fCQbnWG8QeijB02PNrG4shPdOmiUjHGw/rpJ59cn5d9uSHj+b9Hvyem05ckGhBWw4Te56m7ppztOGayCQBVSuKcCYdMvjvXzzsugpaP8gsfxsUUDxbckNee55QwmnAdlCtza7/yVFACGRXHHhHymAl56/qMtOa4LL4MuqQQDnXdCCOM8Rn7QOLlEj3+w4XMq3rFChlkCORVnijr4ZBOvFZF1BJxJGmZtraPANgMwfpEX6PzpIzN5xhvhCP+sduDXub48z4hV1m4E2xYGWv39HtmZOjpNHLMDtOyxAIgmSXX9HfzUSFRZrzyKxdAvhYD8N12VRhKX6GBYEmUEuMVzrkSTWR2oC7gC2obSInYRS/2hcaDCP/U2TgfPnwEz0xIybeTrveoALFkhYsBzxBrYsUASTsOvRZuzfI4vVJIU4iaSFdmbiCq2BeTYrr/VtQ+5KCiGWIO2aQzzhNritYO+20Hkd1ACnCsHCJZsuoT+WKkK/ad2jez2RCA0iCeOl0se1qu27vHqoaOqQo6zcr88Yu7RrYxKA48lARIY2atKMGpmEX6whW67Ofr0sGdR2gPnK9boiIrBu93yYoalnrYfdDTMMZfidYH9wfZwqjV1g8dOUofZ0eHOjmpLwit0HMmLgAJBumOovkESuPu2dyiEOq9AztKM3ym2tZqewmXXQDl8HBC6Cxe5Ni6baHRXYcGxS59r9v7fhPTVK2IzjwZpTmen0fubLGbrZkGx/vHVOieO0d0URNim14XkWf6QEsZGCIu0R40kKsrPjbG4I1BBHI0YNIUduI2oY98exf6aQhAV4 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71a9a0f8-e298-4619-4932-08db88fcde88 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:39:45.0950 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: y2+mhUVdw3pCz9hk3flwamV5KGK7+RznL33Ef24k9BsQxxw/OyhIqEiwNWShtqX//oMjIhuPWSa1MgCQx7kicg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7025 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C4F721C000E X-Stat-Signature: ffd76kxpuj6cjp8fnogmeoj4qchmtkjf X-HE-Tag: 1689842388-414365 X-HE-Meta: U2FsdGVkX1/xRLXIpN6BtJtNlIvrLEcV2xtiD+n8U504veGC61ice/HBC4i7M7fZrdTpO6PVcNFXSRLgG7ndLXJLnaeLQuWmQrTqi9IKBhA85ROskSU5mYGAybfqJK1GMq7KF7k/nCRL+iirF9R/Tiv3eJ4YyFGBbsvCqJLyx6CUmURRlPGJWbBIka+TNS0aQvr4Fmx/VO0mZ69DL+/WTQ8X/il7IWqdSWXyGIAxJxiXGaZ1vXRomuKTyJt4iiCtA+erd7qNi37O7pyCJGGBc/7LhXhLu85Sd6UMZ31kRIQl8Zdeg7ZConZtxBBX9ytUJihxC0cTWtLCZ+Ym9iZxOP4/Xth3tNzMj1oIyeQ5gZr8iPeseiGqmMR+TdqlL91aHGAD5EfKgFthERqWShP0XsGpoeCX2HAftVjR+Kp3H8zvzu79lrtSZODCa+ZbJ460JTgVBtmON6caYc/WuzKaD3NTuPPAPjBM+MCgBQf4wR4MpSUlZGN92TOxeZUvyys0TXxZDoYSWMEuhOcFLjbqRgetjZRtGMK8EITmn96SMYRDJ4c03APMGD3MZ7tM8u9k/ymG3UNbxxd9Qu8R8ou/bxkcdeICururzpCI1a3KAvGIeeDYRQZk6ovSdPNKetqsmVesCOhWjqsrFwxdNBITgD3FyNrDD5dzhmBsYF0882lPiv9uJ2XGkHiexnslDLbVwotzhxcdfYSFDJAtmVsgl3jX1K/RQxPA2L0MspG+EaqbeNHdkUD6yrM5C+9kxq7ZY8abcWdpBSeLwItB5nfXFXx7VWntryVUt2PDU8sn028f7msDCuE2s5++A/9916xFeBgcyXS0CsTbU9TymhzLkAzJSLtimrYN/Ye4yhxlBG0ATwBk3X5bw8mRbAtK5h6mkYWgqMR3Iv0vdKrK6rYI6xvIzh8+JuyV7fdEpzbPKSdS4ELkh3NJJquwyB34+bODy2PSDmdn9t8plIKzzlR iG48eQ+j spe44j9UHlFn7qDPNgbAyww/o5aOloUTnqH1r2JftftKg5ZoNed5DFavO0JbD01/yZbA+XwquSKg9qmIlce3TJ9PrjQtBcgGV8zLXOG86sRHIrNp8yg9BWdcrmyGHeq1v92epHDDfDuSyLKz4dj/+a6OdBkgG9eSJT/TuznCs86IRvWsInoEM1bJmd6NlepuiKZBmiRKSgZRh/Udgmykx9P57sa5Nfrq+TFBAxpEp+A64zJ9Yj4mIILkx34AOA5hscGeR7YkMjVPuegcsqs5C+or6jvtPAaizqHHdQCuOJGYJz8FBnetYuj3fvZTBOUagxnie3DgmVoQtKESSENZDzQRmoXrQeYZmICwgbESV1fOjkLReTRTrlDkCUw== 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: The ARM SMMU has a specific command for invalidating the TLB for an entire ASID. Currently this is used for the IO_PGTABLE API but not for ATS when called from the MMU notifier. The current implementation of notifiers does not attempt to invalidate such a large address range, instead walking each VMA and invalidating each range individually during mmap removal. However in future SMMU TLB invalidations are going to be sent as part of the normal flush_tlb_*() kernel calls. To better deal with that add handling to use TLBI ASID when invalidating the entire address space. Signed-off-by: Alistair Popple Reviewed-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index a5a63b1..2a19784 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -200,10 +200,20 @@ static void arm_smmu_mm_invalidate_range(struct mmu_notifier *mn, * range. So do a simple translation here by calculating size correctly. */ size = end - start; + if (size == ULONG_MAX) + size = 0; + + if (!(smmu_domain->smmu->features & ARM_SMMU_FEAT_BTM)) { + if (!size) + arm_smmu_tlb_inv_asid(smmu_domain->smmu, + smmu_mn->cd->asid); + else + arm_smmu_tlb_inv_range_asid(start, size, + smmu_mn->cd->asid, + PAGE_SIZE, false, + smmu_domain); + } - if (!(smmu_domain->smmu->features & ARM_SMMU_FEAT_BTM)) - arm_smmu_tlb_inv_range_asid(start, size, smmu_mn->cd->asid, - PAGE_SIZE, false, smmu_domain); arm_smmu_atc_inv_domain(smmu_domain, mm->pasid, start, size); } From patchwork Thu Jul 20 08:39:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13320119 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 DC364EB64DA for ; Thu, 20 Jul 2023 08:39:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7727D2800DA; Thu, 20 Jul 2023 04:39:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7215A28004C; Thu, 20 Jul 2023 04:39:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C3232800DA; Thu, 20 Jul 2023 04:39:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4BD2B28004C for ; Thu, 20 Jul 2023 04:39:57 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1C5011A020F for ; Thu, 20 Jul 2023 08:39:57 +0000 (UTC) X-FDA: 81031342434.02.EC7DB4D Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) by imf06.hostedemail.com (Postfix) with ESMTP id 36416180006 for ; Thu, 20 Jul 2023 08:39:53 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=PlVmjHQs; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf06.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.79 as permitted sender) smtp.mailfrom=apopple@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689842394; 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=D/cCYj8Xd7PDxmlOmxc7ZGo63wZ++XgwVNU3j4KQgOc=; b=FdAUZjW2eCI44VwurW8cPQT56aNKN8pbWOWW/7cvcPEuqXuyPHI2mwHaP8nUW9CZ25uK9k wIN5Vj6Iex2d0It89DuR/vwgtJaEc3RG/TClfadEkHUyh/d7umVCxJCNQz8SFeUAzRLUO+ LgZSNmqh18cOlBsWTGZc5ObW32v+5cw= ARC-Authentication-Results: i=2; imf06.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=PlVmjHQs; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf06.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.79 as permitted sender) smtp.mailfrom=apopple@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1689842394; a=rsa-sha256; cv=pass; b=osEMz6MCdH/TSSGox4iNoemvUZgfc+If1Ddo8KcV7capz84AnPME0YC+6EyPqXtoXhw8GQ 0Fg4bOYLDWufl5f7Rjo91g8S5uYYXkhHo4wgb5I/qgLHmW23/nGA/6EMteppFfDyZoGa4n JFG60+ToeIbNh/xZgUys2/+tGRxxWu4= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ECvaaA3ySZDw5vHoY+JC9P8vXLYkaBk8MF4sYWcdmjMjl866XZlPdPmXXspCr2Fs64JXZuKEw/QfmJd4IZTj/gF9LCrNhCH3KTXtH/iRpa/Cr4x5K61RLU6Ql3bopGPA5J6gc1btkf60ZZQc2FJ0EZvrHQVLP+qpnX5gTQ+bkcoQSHkXxc8ppnhgo7MDtVvDDed6hlZ3CI+3bEnARdUniHs6L2arz98HuPg1V9eTm7/WjqeT13e+evf0C1PiS3UkFJYkVya0GyeIW/ln1eSszVyo15PUaQpqFPmdcUXOt1uR+6HT5HRzZLyspsXvCANqUTj5cdRE5DqEae75NhUQXQ== 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=D/cCYj8Xd7PDxmlOmxc7ZGo63wZ++XgwVNU3j4KQgOc=; b=HOwjuVjj3bdkRRRf0+MyuOjBoIv6ui061C9eMFXHos//+uKfc4kQTUswHKR/xaKiZgGKv91Dqr7cToZCVhUKnaCuGGOfHqGHyp6zOgGX2G+OO2BVBDUCV0aCiKDv8fSGrPPJKJWJX+UKdWFZB7SANkAKfdp0I9brzdvN6/oe8Wl+oKlcH2j7DlwEpOpamGQhovIOBBYkHX9JHeSuO7Fb87EBZeU1kL6zJH8ONsIEKxK8gtta3vpJsWYHAa3MEmOLGAD1Ta2LlKYnWSvqqNcdADr7SxUwdUOL+EDT0sZB44ZaWvutveWbf05h3qLFBOfpEFmjnE+nE/coKbrTTwMp/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D/cCYj8Xd7PDxmlOmxc7ZGo63wZ++XgwVNU3j4KQgOc=; b=PlVmjHQsWvDa8c0m9WSwFzKwG7DCZ4Z290hPqi2PT5toTVVL+SGoB8m8A+DdY+UGmG191MmxMkTc9dVPDcqSNsuve3OZWnF62qlYJL8WL7ZlD9ohDSaPtdmiPMcv9IG2+XQEV3R/yrB38DUqsWwag8DPey4DBspxKGleN92Zs48XrAnAM2Pu0srKAfLZHirUsbNiBr+6p24bvAVFJILEeH0X8LYoQOO/C41y4gL11bvtuTMA2RoOFwcb9v7WinQmdIg80Lm5X7xqI+0hXwyIdjvZCsJl2qczjiW1i0n9Jv7Tyc8EzGFamsZZHkN1nd6rxfizEvOGlgaeS4zKxKgqVw== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by PH8PR12MB7025.namprd12.prod.outlook.com (2603:10b6:510:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:39:52 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74%7]) with mapi id 15.20.6609.025; Thu, 20 Jul 2023 08:39:52 +0000 From: Alistair Popple To: akpm@linux-foundation.org Cc: ajd@linux.ibm.com, catalin.marinas@arm.com, fbarrat@linux.ibm.com, iommu@lists.linux.dev, jgg@ziepe.ca, jhubbard@nvidia.com, kevin.tian@intel.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, nicolinc@nvidia.com, npiggin@gmail.com, robin.murphy@arm.com, seanjc@google.com, will@kernel.org, x86@kernel.org, zhi.wang.linux@gmail.com, sj@kernel.org, Alistair Popple Subject: [PATCH v3 2/5] mmu_notifiers: Fixup comment in mmu_interval_read_begin() Date: Thu, 20 Jul 2023 18:39:24 +1000 Message-Id: <06fa82756e4d6458895962a7743cc7f162658a54.1689842332.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SY5P282CA0076.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:201::6) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3176:EE_|PH8PR12MB7025:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b834c26-30b5-4686-5146-08db88fce2b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NKFgrMSkEbwVZAmEFXKbnVft15qBKTzeInwePEcG1hrohOUbz6IiSkRTPGx9PLj1Y8p2la6CZoX+RYqMweJwM8eEWc5lPu31BfApk1Rqov10/F0xgEia8id4Mv9WkWcKlAr4cUGw9xyZxn8UA5LIJWtxxIDMyXgmBJmR7ugeUGIcA9fvda6z13SHnJE29cOEZePN2hAzVqkZhAz9Hu154e3T5IYyxznDhB4lP8GPbde58T2NCOBIzo6c00DEvAkzOmhB+iOVavCxksdbmLPjmZC1qhywVgVfceFP6K4Arur0Bv1OK6g2udVgvo7pBAZ+1QMsbJv0Q0fGk8iS+5xYkI5NbmF/+RN8eiQ+7WitilRrpyzJND75e+1b1+yg4aAOK7GfpdgRUTmSquC5HeCWAsZaLpEbkoKV87Po/V2TzBXzqnOpXJjA7+ZF9Pa6EQodp1YDMG/vA/UGhXDgMJMcRjAqUpErNHiCQS47Ajl8KqAhqDpVU12isoLV2xjdAoqtYUtyhOEOY8H4/y4ONMTFfo6UZUvrJF+Yn4dfEP6hfS8Cwkpe9NHXBShpqNSgtaOt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(451199021)(36756003)(86362001)(38100700002)(186003)(7416002)(478600001)(6506007)(6666004)(26005)(41300700001)(66476007)(66946007)(4326008)(66556008)(6916009)(5660300002)(316002)(2616005)(8936002)(8676002)(83380400001)(6512007)(107886003)(6486002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qCUN7qdsU7Ongh1mMS76qCO72xN+/RqD5YHQAwUkrveGbNzXZ7WuMZEi/RF8xZwgBd3ng2KbxVo+SWsqgRhv2fze2oIr6mO639CtOmCxRLgFo01AJ6DknYsC6IwswUZWHPAXkWT5XFQvL8DvnBFkDQb4iSnk+/ZgOh+YfpF6+5VPoPnKA5K6gtCWmBjj65s9zwHTbFzk06WS6P0Ec1VpWpUTpDBDlOONZv+OK2OsWhH2x8cmtF1gyJsuQGIHgV++Rp7Svia15rjEvT/F1GbW8dQUWk9oLixC+5R2mINHLfG0EPywjbjqu6x1OUiO9I+Cz3DH0o1goI+ZlOed71HHr40+RvA6Y0A7TAbGw6k73m3zrbDGc5rG/1hRkubpDuysJfnYby4c7Y9ooeTatqBJJOQTmRvecy2RY7qEQB3DJitBojNpvAHmv0Naj5gpWGxWQdI3ioOJcCgrELdPdDg7Mk8rUra/MyrUMqf3qldeLoe+J/H6EqI/Yye7H/cNy1lNDOS0vkpjceaUjeG1SHTjNbgW1xoU7b3iJceZ8wbGd4VDUZD+TW6qjTha88Wd7gVCewwQ2uecV8ysQQHbO9NeIIVanr2kFtvoBw3rJCm7w+qYvG6MKDPI+FtuN6x756A/7x0ntL6xLOVSVjhzEG5MfES+YZW2MxQ+kCI3CUARcCvS+igFf5kbT4AV+Cnnaf8EnW5KMHgS/5O3NVwTOC5RC/6CPtJKjNJQBfbjSo4kK8dGcgeEWwokQ2lFAbWfRtc8k2yQCcBhkp5BoGmTAv9Hx4Ljaysbp89Hy0g9LA+L8XqA7yBTdCfD5Pmf7YG81fo34B4iVmMbTy+dkPGYcbnYprEkXHHpsyNgvd7mNpTE15274Xfosb8+oqszrN4OxufdiReB2d7vkaGMs1mzLofRsPWVpH5AiZUL5uCR8HgUrH3s4bklc86ur2VDBzEVnexOwMvbVAq/oNofAD1d/FppOpMK3mYhy03+jNwcalo7q/EoGVwrN2dF5nvmPN67Qxq/OyxHOjuiEh5whqGkWDnvvAajdmMXPSC5lC43owilhQhGLA5HVlITKSKgGGeMT0rvm0iuXLMqEOQcUxe3iig6WqLJrfAyD42tpKYkYcdGwufxSWYTVgSHmx0C72HaBS5LdQnbhi6n2zlzZwntmYk5LKYSI9rfUsM7nI7L+itvBa6HRwYYctzLj/Qyo8aicfCyiDj+zMT4TpXKgeRB5sWdH062c1/wccQHaYBI8HJ52CUc6nUfoiyumZhg75RMwVi7iUhdXUVEAsBwhMCpt5qkf4wLweCPALlcp+UIwOJxiY24VlmuUHmhvxPn637597fJmCvumnCfz2BRD873WMieAiw0hnOy9aC2J3BIrCNZbkpyfA7nANbDLTNUJPob55a+f7uS2ekOBb3DcCF2AjbVdtHQiwUw9xsevW0yxr48z0MZ3MEsXhMoBF+fkcerSRv8v4ViY6qbeVJChUjMiAzD8A5vxkY2W1YfdJBoqN3zvpW4X68fFb8rydn8BPV3Lr5sOLP4Ienwsjap6/ydsWRy5XnIVoa4FOTLCsPixPjk5Qj3J8NhgQNTZK0t/NVbGX8r X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b834c26-30b5-4686-5146-08db88fce2b4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:39:52.0953 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tInQ6FJ2kzkNrjSLGbp/KoHQPBAJiteOD2LGi/O4vC0tNaD3WT7sJxlDmWe5wvnMCUeuRbjF3GBNIzxUnNJUaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7025 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 36416180006 X-Stat-Signature: yocxhxczxyx9zd8frkxj6s755c1gc1yw X-HE-Tag: 1689842393-94752 X-HE-Meta: U2FsdGVkX18Kf/MtShlM3h6jFO1BUv5bqWthUdazcMggsrrlzHACozD71udXuloT+RkxJf9p4rtf5PgPeGW9IZYqEaeZe8Vm6jG7wZOUJLOW1edTcXhWaWJ5evNeiEELvPlWGMf1rep/7jP/6fHkxzbWX8HEfrvrVetA6BXPDm2HwbEPJuwKypauDu9zgdYKG+dsXcj5Hb8StdEKsotR1bCPS+rM5ITWDqUlyDBTNAUatQUJs4HbQyadjjrDXwKEbCSdrZaMWQyF3RB1o8FKj5R3sOKZap7/Pv2JDpp62vX6VbQ+G9Pk8oMQlv39jAD1RlE4KBl8oeapEqHWekwbGRDzv7DFQ5vyue9nJ3CIYL/IKO67CkcDr5eVdroBmlNa5j/WH9t5RoC7W7X2palw2jX+OqJMwl85YiUUScM7J9yaxUdtGbgmAlJvQ+X5n9cNiBRH4wl4HVeeilq42PY/gjGSl5nopjDx053DpRQGmHs0fQZ96BJ8M4v6+DwKqbHE1I4VWS0OponhCULY47ZSP5pTC1xD7AKgM4njAxL6qFYZJBsqYmigREP85FnVxL+LpdvikmaP1qGD1vmEGJl4raR8M0vRhxlZwQ3trsFvKrfH4OgLvhCAo5+sNxpoWK5mhqodpXNQfEOfwsBYQEx7XuHBTT1VxCcVaFRL+MZdGUjCC256+ojlQFjxIfNo5Dy08E0161DWEcuWv8UksP4oMxRmDipGAlbZi1+sCI2kljxb9ifDEwU8aRy1aamDSmKiNmz7Pt53NYkCGPgoxFhs5D4BRfnJzudlV16Xjttq4BsstUjluExDux4AdH+A6XD7CwGZo/V6MpwIjt2Vi+x56ZDXLJFX5vndWyldR+WgyXdUfbCS3k7Bsm1v/D84Zkq8J5QlVbTeR4STTwmOotEuObjzmCIwLflYpNjFGt0sLubs6A090qt/tQzqQl6WHiDR4cUcFF3kW3wYo8H2hlW VhZo476F 4fChTEnsn8qLAWQp/vIQHo9VhF0w9dFtmdnRkM7PyysNOuu6cygXsqmm2T359DANPfoJIE0mxDKxZ4cfidjlJ83HnQ3Rum75M12g2waWuXYLOSRcWK4p0UnGkpko+wVM+xMdCuu2OhLOdW+gaxXBd3rd4PrBXGKdQNCy/WxGjoz28zB0gxO2twU+Ukh17YQHn7dmU/lX+LQGNhKL8aYyNwpsTP2zBu4NiVMcgzC+5BBtrl03uCRf2SYvvfaxe0OlCJtuy/gVUjfieeHV3BefT25zzFv71GsK49NGr/sEpqjM0i03BddoAcKq9F+iUG6Dhk9V0AcV/oavEEVE0lLvmT7xfmQ== 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: The comment in mmu_interval_read_begin() refers to a function that doesn't exist and uses the wrong call-back name. The op for mmu interval notifiers is mmu_interval_notifier_ops->invalidate() so fix the comment up to reflect that. Signed-off-by: Alistair Popple Reviewed-by: Jason Gunthorpe --- mm/mmu_notifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 50c0dde..b7ad155 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -199,7 +199,7 @@ mmu_interval_read_begin(struct mmu_interval_notifier *interval_sub) * invalidate_start/end and is colliding. * * The locking looks broadly like this: - * mn_tree_invalidate_start(): mmu_interval_read_begin(): + * mn_itree_inv_start(): mmu_interval_read_begin(): * spin_lock * seq = READ_ONCE(interval_sub->invalidate_seq); * seq == subs->invalidate_seq @@ -207,7 +207,7 @@ mmu_interval_read_begin(struct mmu_interval_notifier *interval_sub) * spin_lock * seq = ++subscriptions->invalidate_seq * spin_unlock - * op->invalidate_range(): + * op->invalidate(): * user_lock * mmu_interval_set_seq() * interval_sub->invalidate_seq = seq From patchwork Thu Jul 20 08:39:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13320120 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 82A5DEB64DA for ; Thu, 20 Jul 2023 08:40:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F31A2800DB; Thu, 20 Jul 2023 04:40:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 154E128004C; Thu, 20 Jul 2023 04:40:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1C6C2800DB; Thu, 20 Jul 2023 04:40:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E216828004C for ; Thu, 20 Jul 2023 04:40:05 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B7FF21C87B4 for ; Thu, 20 Jul 2023 08:40:05 +0000 (UTC) X-FDA: 81031342770.18.A8B67C1 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) by imf03.hostedemail.com (Postfix) with ESMTP id BBC3920012 for ; Thu, 20 Jul 2023 08:40:02 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=pzkVvYJz; spf=pass (imf03.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.57 as permitted sender) smtp.mailfrom=apopple@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689842402; 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=kyTjkl32gx9e58egMAR68Ym72eF/grtnHpGANsDW46c=; b=8F8iKFtojeJ+0MWiyQv+7LD7BwVvbHSEKpmS9NVb5c3fGb85mJz8uN0rYF4UxYbFho38sx J8ZMQUjTbqMWIZnUzqWYa+O7MNe82Fv2S0i8lX7o2x70G4UllYBGqLuI40DsuAJpODJl0z r4MvC/mK70oH9DyZNw53qqQqnMOf7ms= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1689842402; a=rsa-sha256; cv=pass; b=5wbQA/ezXvXy9YyCrwT5Mk2/SbY1y4/JwMxpyLe4qXQFoNCY3+f7OjheIEZZFnEaYbYSJy IRoOEhOi8hqIFuLaSDb2TyjLUGlRC+fnNIvK23wJXvTyfmK6W80uQQfd+u+I9VA5YnDM/F K5w2SkBm63pcvyO4IRtwFwMAxkOs6Lo= ARC-Authentication-Results: i=2; imf03.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=pzkVvYJz; spf=pass (imf03.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.57 as permitted sender) smtp.mailfrom=apopple@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N0Urp2JJb8Bsyj5XPSrYP1ZnUykYXDayVn9hFknzDkJs1mRr1Cv1LYNrGqmo2iqx/Gl5lcr1I9EIbb77tutGMNi3DyVwT+UDYj0XGcCnmXCjc5E5x4cm/kbkOPzMzvseV3+nrePAvTI3Ib0KrSyZaFN9enQTd60bxzigRumWtBQMYc3McdO0k+sC7Ac+8NDfITwNPgC/ebngsuwEhiZ3q9zBj7SV/zizHr6mFdsIQnvkDaitKXzPTgq7qPbMFYY+SDMD65tVt6fRCqiLUvraeyx+dyJQmlITpuGi7oabVtM1N7VlSscqgEjWSgF+4FWb1hnwTWxckFx3Cjt6Ysq/kQ== 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=kyTjkl32gx9e58egMAR68Ym72eF/grtnHpGANsDW46c=; b=MIEHN7NSHcczrXuQ7uBNCBg/rwRO8xNzNvqQXMz3OTIof2EdelROairMuKzjEou7VIpkBGyt2HBqpQPB2jSXaJkabdUWwcsDhmGjX4zLkwOoUhtjfIiqkCZo7WS2aIu8e47U9EKmT1vzKn4GiiwzPg8ggJvIAbk5mndYbiFAk3ZQrNcFnhZygmduNZRLJt9pg4cekXbPry54Nswiucg9cEKDcHi2Gk79ZG7Z3gyKedtYBJpR2lDFndk8/101EbVRRDLG6Z1yctT3sejJGqGMln/bK58M5x5+Y5K4F41lXmcMyllyyadgtw5eMm0sFGAV/Ec38Cm8slJLC2jL0msrYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kyTjkl32gx9e58egMAR68Ym72eF/grtnHpGANsDW46c=; b=pzkVvYJzcqb+S4IieNcTuiq3SqCpx4UQZyGpRX8v1G+xz4RmfCmwH7iDq3+w9j8MuKdr8t21+zyJ/uNedHAlPFUmYOjY0S9/0OU2S2dIK0WL3ty0Uq/Lo69sE95g5yJD92OK55S6kWbD4sIp42Ova6gcY62WKbIRpRYjVP2QN9UJXNavSkceTLV5G67FU5za3mnPi6g88hhIpWYOiDIti9hQ9zYkwvGk8QL4j05Db+HoCI7udkLo+ok1rB47ihBUwvWrrkiFSNSt4bOcEiWtxcP+GtMbXOiXNjCdxmAq1K37x7QDKYbLibBl6C0YQNKDf5i2k9ORCA6eSQNqS5cRsA== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by PH8PR12MB7025.namprd12.prod.outlook.com (2603:10b6:510:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:40:00 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74%7]) with mapi id 15.20.6609.025; Thu, 20 Jul 2023 08:39:59 +0000 From: Alistair Popple To: akpm@linux-foundation.org Cc: ajd@linux.ibm.com, catalin.marinas@arm.com, fbarrat@linux.ibm.com, iommu@lists.linux.dev, jgg@ziepe.ca, jhubbard@nvidia.com, kevin.tian@intel.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, nicolinc@nvidia.com, npiggin@gmail.com, robin.murphy@arm.com, seanjc@google.com, will@kernel.org, x86@kernel.org, zhi.wang.linux@gmail.com, sj@kernel.org, Alistair Popple Subject: [PATCH v3 3/5] mmu_notifiers: Call invalidate_range() when invalidating TLBs Date: Thu, 20 Jul 2023 18:39:25 +1000 Message-Id: <86a0bf86394f1765fcbf9890bbabb154ba8dd980.1689842332.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SY5P282CA0027.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:202::13) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3176:EE_|PH8PR12MB7025:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e63b837-3c96-45cc-262f-08db88fce669 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6tot57rTTfJnVhe6fp8DjkoKozXl1dpztfU9J9WUI4tb58AlpmEJDnzBjdJTh7XwmkkxhqauuOMRSVeTGHE0u4WLGmzGzN0TKJIm89mDKuRVV86Idy6ionB+dDlBS+pU7Zy/KZpvVgDGJ3PoDFg0oayuxdjRPrcNBE9DNDP4FQY3ZO9b79GxAGxv858lixRqbuZABj/BX+4vOG2OJJDUH+ib2kUxP+moHiNh1saqvDTgwXKSxzm1xmUdAJ6wIbr6fGT4/CKnreT1a+/+5E7BOxq0jazFHfmbEYqBOFdIPxhnRGtJQxbySNIhFbLaHaliMI3Im0DcTnK2gybJbuodV1ovkazXbEksQrfXmyegLzFShwwCzeEsVsrJ7YhxDcc4D6PQhVZJP/Ym8rcTK1diCT4T+kqTkQs+8zytOajTtyYamd5Uvnx0hvcL+PCxtcAd86WCYCD3hoYW15bsFHypnpt9IVzwATN6jScqzbE8INGYLaspenukshNNUgebDKSUhqA1CjsN7j9VsL+O+Km0wR8Ujo+F9FZZsaAO+PVMhK3nihEHVbwu0B394P9Utnv7G1QWNduuaa6uFfB68uJDlHsuBXjCq4f9jQiLTtxIHJNKcOHT0mQ92568KXjIAcnZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(451199021)(36756003)(86362001)(38100700002)(186003)(7416002)(478600001)(6506007)(6666004)(26005)(41300700001)(66476007)(66946007)(4326008)(66556008)(6916009)(5660300002)(316002)(2616005)(8936002)(8676002)(83380400001)(6512007)(107886003)(6486002)(2906002)(473944003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /7HaGLIpXgQ8vHorvsI0YgpPv4wQ8MA9xwOxLIDX6vRO3AJJ5IP6DXoxBtzLuVgMm61Q9VrHrMkGsWk2aw0q3fLr3wsdyWR2JcYaye8AY00ryRNrtrDuJCic9g8UV9Ojdzyi0+N0iVEKYZsQ3BeIU3hrHs2uYXwzCYtD5wx51CYaj2IcIUXOWnguc6wM7lByDcH85bZdfMFaewNrtzJEZaJO1N+Qiw+1NTQHYGYeLzgriK0UNRaHjlT5t42yBGr0MfgSsd+yIf6Qri/53qMs3x9vLl6PD2RoFGTjSuNsQzvHtwqs7l81n8qh+WsDClLA+CtN6CQAFxjdrBnQFnF7nS9VdyGFPIGaWOHtfJecC42yiVLyBqXoKpqopr+YNQtH9+R9XTOexYo9zNEVb1pINZ/sowfxKj/m44Lv8CdSLj+aRiZyA0G0bpCaHXalKk4ZbTEgG43X+ydXYp10mFHAlj0VGsOrDc4LcpHmL4fEXqIvLo2ebJT8S74hCFGiuvjQtOg3ISi3y73H/4HENFLpA/wUZkTFhtOYkwCXgdf750AKk1TNkroJ/r2f7BzN7BsPOmr24aHY1EyOkBiL2kDLyQUwXpPEg5bYzKLpnKtmwi2rV4MsJ0TV6wXHPvecq88FuDEQrvIB8jmuQ4PYHj//Duy6n8Zbj/eJy4e/t6Kls1l08kl24TNp07XaElkqL6crq8HT8/K/2omkcQCIk8UhQKmjqyrjIhJO4/LQ86IWs2Un7eRQbABSJQO6wj1NErKsmELStDJ+WY4pMTBDgRriWaF6rJanVBktJKvenMbbevh2sXgnlm2NQ+i4FBITBhUQ80ujk21LVk/HXydHkciuwpOXvbQDOSwsmZouLrNFNjGHJ338K/nReuo0lSlCAnt8IVfxPksL5RsMFeHXQAv6O0xVXMibn0+KWGkeVt9aEFxFhvtaIi3I8V8p082faEUT6MVt4yJ9921Rft1NgmRdaJhVRND1wzUhBfgLy4kYeGv5sn5tpALRsi3KotP1WvgbZxJidmZgD2l89vKGVEomMfQImettCy1vj9zsyR064n3ywsyVSn9CiklXSRQgchWtSINi4ix4Rf/ctMASPWJb5NShhebNwW/sSV4FL1loPbTTQZ/3tM7OGvm43NvIeaSSpaegrcZ2DfdGcYTSyGHVfY0vQYaCvLw1gaOgyqGdbaVEXdaKBcdx0lHxUoXF3810Efrg4XkziuQDNZhO+vkZOEFnGJhQGLF8ezwMwbbMLvR6qmSA4uvnjzb5EhcPSmTvzwWeXgevT1+dn/xcaiWSpySNZyuMV+QDQGQ1bkoweOWGXk7MNpknimL2NpYwDKyzXayhrfPksb4Ci1ht6VdaEija8g9H+6kMOCL+8KJw4dlnis6PgPUX4g+m/2zMgwY7cfeImCTUhHli4Xzroer6StstUquviHMBghqnB1J8OQ37Gcgv2RhsiqbPxTNEB+k96hAvgTRHZTWpIK8oaqbemnSbm9zv7E6kJ5VCExHfFXtrJ+57AE+hcaSww8F54N3usj4zpUBrtuL137jSAjLzZ4PoGmPU8oOd2RTK2qfe1OY3ydf/SmFROUCaowe/rF43 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e63b837-3c96-45cc-262f-08db88fce669 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:39:59.8060 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I0WbJ6hjFPqz9JkPDEgkJtq+Z0pPoQ2oupaF0DF15p5eatu+NmOCruQ/QR1C1X0PufRN7RqADUfhi5NZ13wzJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7025 X-Rspamd-Queue-Id: BBC3920012 X-Rspam-User: X-Stat-Signature: r5fikauey67jnqcsc7o3ntbcepf43snx X-Rspamd-Server: rspam03 X-HE-Tag: 1689842402-439300 X-HE-Meta: U2FsdGVkX1+RORDQ+vcYWLbEDD6vMY5PMpJ1/lGvLQlRHosHn7v1a/TQHY43NdKRNf/n06PQcy5fB9AVCH6tnqmsc+Nnm/atttBGE5klB0IdeG4nMMWKTRkDmP4oCzG74lfZ2WRRQFAG8ww7wuKxABv94Ypnise8d4BOdMjPoemGRv/Y/BiKP7c6aHewg9bOb3ZJSSEOC0zYd+HuQichBfshpAPTTgIyHQvjgfZjWA13kdMGUj8GzX8w40BnhzWLfp49begXNvkWL0hXB5/a5XqLSisjI7+PwgOIVta5IVNn9XiF3hBTIdBjzCzLmyw0xmhKfcShqYkcYDXr296mwUzzUEOCwlwZMwPRD0kzKVCySotMtpDLlo1aylhw+kNtscNMnfVJgu3z5kK82LWJqEAveKtLWgKJo4Y8knw3R3dAIUDbtwCy5t79tLQP2hVsAv8CVyomXTzm52sGJmYMVkXpQ/zFxU5UgQIfsjC8HNBbE7xJDqT29ZwHHcUyz+4krq/9zW3egkd69YvmgLXFWXKdnS+NKhEO5U8H3jkMWo85NSYcE9jUNj8Jo3BFRxYb0TSzCK9e76St6/WJllQ/a98/ofEiG8dTxfz+UiImZnIBjKQ3msA/l+PfvwO5Q0o6eBxcUD9NGDpCGkrulOV4tNH+7czmG/4H9mPxin1+2qBsdpB8ku3YXuX+QyC1SVbgE+gQcE+sBXLqPeNW5ifupgirkdjX0ynl2P0UBSXE7Fti+BOCE4Gxz6s/KNttVmUEhRNa0q5eTYLBot0GaYrqhCj/r9NrX2BxqrxqgyUSvuMS9lUdX8lnTu5bUNQlkC+SCj5wY5r8Sme0Fbzk6JwFxc2g+76btBjc2BWQNdHpdPBMIUnld+VHKLG1JFMP67fr6ncchKpkVDQAT22BuyZFU6olMXTK+t0QKfLwC+eSLTis26PlLZuqmnDiTOzoYv22DtTg5+8sK8YAj2iaqRW xMlraj9l NB2KCesxZPspxGUfEEpJnCNOe0hvpiWczmBb2Vgk0eeVjWdojBA89K5/VTVdE0khAy6Twko7ZjMV5uBvxYRCakFGBWi4Bkp3FOfjEkZOWDxloRGwHW4G35anBsE36NF1nSo+fUQYw2eLK1RrGHC9UzP0VGh2iE2lv/IUnvf2AeI19XnYjGCugWeSIEY6bfHWNobMzZgHDDYEn0VSU9kUod9BdV5paH/CvCuO/7XJqPJG1DDjBwqpCYyWzREHMoEtqz5OFCtOD3nSgPjR1sKlNRZl0ayCQSAqAcb9/0FdbaBoTPTjPBrq42513QWEkPax82KSRUggHrQTe2tbdWwPw5Hwlm5Ws+6eoD99FzjF94Gff8e9rO/tcF6DPsp5TZe3R2CgUzkKOV2BoErTtVKyYOEZ/5a1/UrwZZBpun3eMOcXH5glqUfJk+HV1Yrx/9/cFgeUDBnbYDL0VhwkVtjwsXB9AzA== 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: The invalidate_range() is going to become an architecture specific mmu notifier used to keep the TLB of secondary MMUs such as an IOMMU in sync with the CPU page tables. Currently it is called from separate code paths to the main CPU TLB invalidations. This can lead to a secondary TLB not getting invalidated when required and makes it hard to reason about when exactly the secondary TLB is invalidated. To fix this move the notifier call to the architecture specific TLB maintenance functions for architectures that have secondary MMUs requiring explicit software invalidations. This fixes a SMMU bug on ARM64. On ARM64 PTE permission upgrades require a TLB invalidation. This invalidation is done by the architecutre specific ptep_set_access_flags() which calls flush_tlb_page() if required. However this doesn't call the notifier resulting in infinite faults being generated by devices using the SMMU if it has previously cached a read-only PTE in it's TLB. Moving the invalidations into the TLB invalidation functions ensures all invalidations happen at the same time as the CPU invalidation. The architecture specific flush_tlb_all() routines do not call the notifier as none of the IOMMUs require this. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe Tested-by: SeongJae Park Acked-by: Catalin Marinas Reviewed-by: Jason Gunthorpe --- arch/arm64/include/asm/tlbflush.h | 5 +++++ arch/powerpc/include/asm/book3s/64/tlbflush.h | 1 + arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 1 + arch/powerpc/mm/book3s64/radix_tlb.c | 6 ++++++ arch/x86/include/asm/tlbflush.h | 2 ++ arch/x86/mm/tlb.c | 2 ++ include/asm-generic/tlb.h | 1 - 7 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index 3456866..a99349d 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -252,6 +253,7 @@ static inline void flush_tlb_mm(struct mm_struct *mm) __tlbi(aside1is, asid); __tlbi_user(aside1is, asid); dsb(ish); + mmu_notifier_invalidate_range(mm, 0, -1UL); } static inline void __flush_tlb_page_nosync(struct mm_struct *mm, @@ -263,6 +265,8 @@ static inline void __flush_tlb_page_nosync(struct mm_struct *mm, addr = __TLBI_VADDR(uaddr, ASID(mm)); __tlbi(vale1is, addr); __tlbi_user(vale1is, addr); + mmu_notifier_invalidate_range(mm, uaddr & PAGE_MASK, + (uaddr & PAGE_MASK) + PAGE_SIZE); } static inline void flush_tlb_page_nosync(struct vm_area_struct *vma, @@ -396,6 +400,7 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, scale++; } dsb(ish); + mmu_notifier_invalidate_range(vma->vm_mm, start, end); } static inline void flush_tlb_range(struct vm_area_struct *vma, diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush.h b/arch/powerpc/include/asm/book3s/64/tlbflush.h index 0d0c144..dca0477 100644 --- a/arch/powerpc/include/asm/book3s/64/tlbflush.h +++ b/arch/powerpc/include/asm/book3s/64/tlbflush.h @@ -5,6 +5,7 @@ #define MMU_NO_CONTEXT ~0UL #include +#include #include #include diff --git a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c index 5e31955..f3fb49f 100644 --- a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c +++ b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c @@ -39,6 +39,7 @@ void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma, unsigned long st radix__flush_tlb_pwc_range_psize(vma->vm_mm, start, end, psize); else radix__flush_tlb_range_psize(vma->vm_mm, start, end, psize); + mmu_notifier_invalidate_range(vma->vm_mm, start, end); } void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c index 0bd4866..9724b26 100644 --- a/arch/powerpc/mm/book3s64/radix_tlb.c +++ b/arch/powerpc/mm/book3s64/radix_tlb.c @@ -752,6 +752,8 @@ void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmadd return radix__local_flush_hugetlb_page(vma, vmaddr); #endif radix__local_flush_tlb_page_psize(vma->vm_mm, vmaddr, mmu_virtual_psize); + mmu_notifier_invalidate_range(vma->vm_mm, vmaddr, + vmaddr + mmu_virtual_psize); } EXPORT_SYMBOL(radix__local_flush_tlb_page); @@ -987,6 +989,7 @@ void radix__flush_tlb_mm(struct mm_struct *mm) } } preempt_enable(); + mmu_notifier_invalidate_range(mm, 0, -1UL); } EXPORT_SYMBOL(radix__flush_tlb_mm); @@ -1020,6 +1023,7 @@ static void __flush_all_mm(struct mm_struct *mm, bool fullmm) _tlbiel_pid_multicast(mm, pid, RIC_FLUSH_ALL); } preempt_enable(); + mmu_notifier_invalidate_range(mm, 0, -1UL); } void radix__flush_all_mm(struct mm_struct *mm) @@ -1228,6 +1232,7 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm, } out: preempt_enable(); + mmu_notifier_invalidate_range(mm, start, end); } void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start, @@ -1392,6 +1397,7 @@ static void __radix__flush_tlb_range_psize(struct mm_struct *mm, } out: preempt_enable(); + mmu_notifier_invalidate_range(mm, start, end); } void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start, diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 837e4a5..0a54323 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -3,6 +3,7 @@ #define _ASM_X86_TLBFLUSH_H #include +#include #include #include @@ -282,6 +283,7 @@ static inline void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *b { inc_mm_tlb_gen(mm); cpumask_or(&batch->cpumask, &batch->cpumask, mm_cpumask(mm)); + mmu_notifier_invalidate_range(mm, 0, -1UL); } static inline void arch_flush_tlb_batched_pending(struct mm_struct *mm) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 267acf2..93b2f81 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -1036,6 +1037,7 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, put_flush_tlb_info(); put_cpu(); + mmu_notifier_invalidate_range(mm, start, end); } diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index b466172..bc32a22 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -456,7 +456,6 @@ static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) return; tlb_flush(tlb); - mmu_notifier_invalidate_range(tlb->mm, tlb->start, tlb->end); __tlb_reset_range(tlb); } From patchwork Thu Jul 20 08:39:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13320121 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 4D8FEEB64DC for ; Thu, 20 Jul 2023 08:40:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C53CC2800DC; Thu, 20 Jul 2023 04:40:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C02FB28004C; Thu, 20 Jul 2023 04:40:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7CC42800DC; Thu, 20 Jul 2023 04:40:14 -0400 (EDT) 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 9629B28004C for ; Thu, 20 Jul 2023 04:40:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5F48E140168 for ; Thu, 20 Jul 2023 08:40:14 +0000 (UTC) X-FDA: 81031343148.12.1636FA0 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2070.outbound.protection.outlook.com [40.107.244.70]) by imf03.hostedemail.com (Postfix) with ESMTP id 618602001B for ; Thu, 20 Jul 2023 08:40:11 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=pPpfBbTa; spf=pass (imf03.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.70 as permitted sender) smtp.mailfrom=apopple@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689842411; 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=eVZWmJyawWp7qJVj6fsL5exDFyKRe6K0X+0eHRtAuyU=; b=X21kMUd52UhrZgQIt7IyAeJOMF5Q6NzUJ8qV/5B22RCiT5ODdg4m6tkjG19w7gMTjVBjVz /t7LRccV/VG+MMvY6gFDwSUkqI3r4vaKPcrgoCMUj+VOjXO3J6bGGiuCFZX8nzrp3TlJ8u T71yT6Otb+1bYg3xTpBCdzS7QEyjzY4= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1689842411; a=rsa-sha256; cv=pass; b=i6ZBqVxzudGphqjAZeXBzSo/y2VeWRISz3lNDnxqUFpSLC1LEcQRahDjf0ptA3URo/sJAs 3AUadVCTltXmacIBMXlK6v/KXysQMnkbNIS68IZ3h7/g/YWYnoXYfUJcrbhKbbPnZnw3yQ /BXA5WOp15WQxSxkLgPh2vhMRVY70Lc= ARC-Authentication-Results: i=2; imf03.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=pPpfBbTa; spf=pass (imf03.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.70 as permitted sender) smtp.mailfrom=apopple@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QIqKsAIVFtQNsYnJT5dHOtbgCS3X8vryi6jhBYSo6vWJ7Dpyxhh/nt7j4esY7jzVbe3jseoPSQ0gieOM9ulH2loBvgaDbXFfwXV1I4Zgj2pXlwroyKx8AS/AcINgL4hqU3UewWm4n5FJdym3BJ4ZgHH7tYHzjlOfslmpNxHCYhIkMV4iLlzf4XVnGLbYBpj2OPgc7ouDFte4gsVdq4aenzwBdUVPerw4ixJ+7L33IKd6L69/uJegGm6PO9aTJ5Rpe9CThTZGd2D4GZ992+k2fAN1zt60xwf5FYcymVt5HQ1LxO605ho0hW5Oez3i2IYGP07CwpMuTQpM5VBBqTdm/w== 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=eVZWmJyawWp7qJVj6fsL5exDFyKRe6K0X+0eHRtAuyU=; b=TEjfkrAgM6hAHJiAjkTMEOXyCaOTO45FhGJQDQOh+xUp+zoT7h7/0Upuo+ZiydWjMV4zUgC+unnM/hGjnem2uqg3v0IgwEiIOQz21kt3vBaT3L0WfoGsD31GP5rRnEVQ/iorXlZNy41rXLp5ytDVyKL5pT+yD2cfR6kN5xLdlamQXXayf/M+eOrDqYSK0sj5ajTApVhJ+YcSqscljtU0jrtHVVE8YfBgmOy4uK7mpfSCoZ0NjK/uz1y+8vLEqeM6ny+GXcq1OpX+5sFELkQb81gFDQYttvQ6+pO6wHO6YxRX7dSPOuuCtW+znqGQ183gy4JqkhEWrOZjJlMPn2l3jA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eVZWmJyawWp7qJVj6fsL5exDFyKRe6K0X+0eHRtAuyU=; b=pPpfBbTaF/OpRBTQ9IMZoTWEXW3uExYK0DT0PohZxWvWh2O6jjMyCY/XggarCm0fMX+n70+rp2iyezVxvVu7YQxrJSPqs9KD5Kl+Zlw9e9xkVi4yyOICgnXVc5v5x3Ko3NTxKtt/8N8JDiOR8RPwiq7pRPeo5RhFOxlfh7I1dnBrscNTtNtQjlEMVxozuV/JduP8ZO8Lt0vtsxuEtrSV4WbFdiZishNNPD1gV35FqzwnqZbziLPqfFb8iRXlMpSilZ2Di5G62M30PS9WcGF2sxS7VYxBLOGcI6iNgD/xMNaYvl4vx/e7NEOB2e6dQ4ckORz6I7dvbhSb+R/0sWErbA== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by PH8PR12MB7025.namprd12.prod.outlook.com (2603:10b6:510:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:40:07 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74%7]) with mapi id 15.20.6609.025; Thu, 20 Jul 2023 08:40:07 +0000 From: Alistair Popple To: akpm@linux-foundation.org Cc: ajd@linux.ibm.com, catalin.marinas@arm.com, fbarrat@linux.ibm.com, iommu@lists.linux.dev, jgg@ziepe.ca, jhubbard@nvidia.com, kevin.tian@intel.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, nicolinc@nvidia.com, npiggin@gmail.com, robin.murphy@arm.com, seanjc@google.com, will@kernel.org, x86@kernel.org, zhi.wang.linux@gmail.com, sj@kernel.org, Alistair Popple Subject: [PATCH v3 4/5] mmu_notifiers: Don't invalidate secondary TLBs as part of mmu_notifier_invalidate_range_end() Date: Thu, 20 Jul 2023 18:39:26 +1000 Message-Id: <141e786b68527b1db9fc5a3259066c360448e7a4.1689842332.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SY6PR01CA0132.ausprd01.prod.outlook.com (2603:10c6:10:1b9::10) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3176:EE_|PH8PR12MB7025:EE_ X-MS-Office365-Filtering-Correlation-Id: 01842850-9864-4354-6da3-08db88fceb7c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZsxigUjQwEWxP12RqI7Nij/BMznIbynTr4xQGb+1dl5S5z17z56Z5DOu31OxsYQP8rxBxJkiTcgWClcEmEshn2ey5m6wxJ2vQ4TH0RhrhmadrppiLY46MB3Z6/fW3/kdQBPjpytircqmKSSSK+0pyu8js5zxHD+YUQfSdrjhK+K3tzomeEjzhnPRZp4yr4ZG6GuzAFN6EWBaFewsLTGHpQE72WerEc6p8EcnwgytxUW060glBSr86u9dX4ZeqxML3Q1EHNnUbPq6E06S27Neh+GGQoi081Z9TOgc3f1WPFY8M9oPAjJgRleieeW31SWr592WK6U8VvO98FXW+HHIkCRk8NVkAJTspZsvXWLmt2kd7EuDSz4oIfZoKjuBGPqP+9H3a0CgyT4HvwWHXj2MxN1bLqTptaG25kKz6F2ydJKy+NL+uuUyNBEke/MuL34E0tWqG3PrALOoay29LlT6Doa77ruxOJvmYhSVymNg0gNrBDYGPkPQNZYg6guvoKRqe2g1QKiFcIm5PZ9jw1NGa+4DF9PpJzJW0ZSclde4VrM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(451199021)(36756003)(86362001)(38100700002)(186003)(7416002)(478600001)(6506007)(6666004)(26005)(41300700001)(66476007)(66946007)(4326008)(66556008)(6916009)(5660300002)(316002)(2616005)(8936002)(8676002)(83380400001)(6512007)(107886003)(6486002)(30864003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nQ3Qq5TqscrekbPzQjL4/+Gh5arDy7luatp0n6hlOVki06Imbh7MnTnxZZ2n8s4rZXPFlBLwiaYOY8IDQ5HUXfnOHtSJZ+FLQtRph4ePfG0iHnPUUyWMxa2ILDcbRM0HcLaMbNCWe5vD60D8a7N0ImyJJwFpG7xfbX/DelydMGRfFwv9YK5Y1zckMXLyG/zki7m7g7yEQLaYntO86qr2yeHEPqJP816RvloxAoOtchUUVB8dDE2Z3KDBPgLHjUuM+wQL71k9VC82vR1Qul1t3cCwfGtOwUGMIaNXuLpHSJeq9M5elGFy+dm5LuCNMzSLADwlXYLqPGHRQ/TDypKOkcEp3jSACMPOYqVIyr8Yb28j5LW6yZbFd9giu+7laeOv6a/sxUr4eI51OEgEuR3qRNP6N/U1B4tOnJU8wYoi7gYNPl48o/bhYSl4ZP9Vjhwb7TLdJwRR8PyBFKyQT8X19bGJz4adWuuKhTVd/4mGzmDLLK5aAW0KpMNn9/UF08EWC4rDqc+20zLb6yBinlcfRs5k8WQomOjjTI0Pn4WzfqHf4VQZDPTK64+VonIUuyaSOpSsjmFoz2k2ZV6diUZ85iWV4SYDcwnHkwjv7+tlPYsPwSZomjlwXdm+rd+9YBW3palRAUgau+GaERy4QzjZG9cix1gt9N2ERsm5UCPMqysXwf29Y8FIP+lk7cSzuPNz+6670Kviv4cALVQGziBMT9Bl6IY8535rBtJv3PbsjxKGeb+X0LybpgP/T0kLuZfFX62hCnux5/ml7+ZjQjk0ardXmc+Xw0wA1NuMrSB3hUas2g0Cn4gj27LZLVlD5TgMfowEimg8E5FQWSkoKO9tgfgHCaCx3+8IK8I640mpoglbjpFyO3mQenNmw9kytiDqcGv/6qSN4QjArQpxEVJ5i3tist9FQ2bDYgl1IvFynYIrQ2cNfLaxMumxBA9AfGINDOxG1lw5uLZs5brCPOfLIAWhS/1JRQaVX2A3dQV7Fr8S+/SWDQgtZ77pX6sNcgkScplkOW4+2JOal/hb6C/79jBYjfcD+ezKqxu1S4CodL6tVmUrC+RZNwcHsmpB44UJKnQosxt7klfZvogWVnPblgs1QEjWeijIldVNiiOMu2flA/OdUp8EOXpOLcWTwQCJSEtJnvgt4ZIH4wZkHGaTK5Pzc21dF3++b/YRho7xNsVZgZZkkVJ49bGX8i5a/wuH6eaGfbWBZQsSE0xZlt4xqaVVwIViAnCN8pe2p+COZq9zHyv0eUQXWsBm4s1DDUvOf6PeXI2Zhvc8dujJ/DiLQ3yvd8RGnzhaWjUx/k1tfQDJ78N/GQ9lB8N++592EvSR7Bal/KTkM8jRk313P3dYcxoHbJ19UdWnMGfzCKbjwGknuqpNGi5YuSBeLAdRhrnyNCUibrQh0WH0NsefBcjicYVals/3fLkj5CrlEmVPHoQVAf4O/ft/DBFQMsnYGIJnPWKOUWeswweOKU7UOWU9OlMpxhMAfwCJOut17AoRtCUy+F+iP0DtGcGg78jmSK3ca/UWpz1nWKKWzhoksvwhEbcg5BzZcJWBMhRQgD1BeGlEC+VxgsjgSMHD44UrhDn2 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01842850-9864-4354-6da3-08db88fceb7c X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:40:06.9797 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5736zlc0rImE8FuDAZpZEPCmQgTpNlfn7N6ulUCe5VJ/klTgBpK/7NrPIxESovVvmpi3MIycm9JQF8zC0/suXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7025 X-Rspamd-Queue-Id: 618602001B X-Rspam-User: X-Stat-Signature: zfmun1t6nmw19akh3ut5i3oxj61u1um9 X-Rspamd-Server: rspam03 X-HE-Tag: 1689842411-882881 X-HE-Meta: U2FsdGVkX1+LspzdPRmzlvuohK5AhJTpwLaUMhknWG1QK7KLjfE7q/sbyQGhZiA4UcqKn3ITsiOfL9NUBcF5+aKzsuRETxoA7jYVTyh1AoX8Nok2xjC58efy8NEIXDgcgMa4hh/d258HwFg0acp2OT0HicVuJP9NbYO2u4bbUzM8CiMciHBYoDH5/radnVvMKV8gUvXc1Lc32ETTL/bNktKXavSbnxDj7M8P5UoBy2eMcXed23KbiY+sqZbc0Duhs9DndPtj9Zd47rK4JQrFjS29FU6pPJ4gU9441m/ZRK+pbgyIWAN3bHSLuThO1OaKZ2lkqFoEI96l2gYpnYpKP5ch9+McKdxYa3yvy6BbmwJUyBF3g5wMhM+uxlpNF34H028dz8vLno3Ai8MKDghfSqT8Tthgcv6UwEakt9JXK0aqj5jghvqPkzt0q4Ug2g2z/SJTc406JLSj32wR9kbpEhsfPNANbMQ7PeV29UjN9SnJOYw9ISsr8r+AFtZlixKB9Gtzuv0dmZBl00lzpKZsD+hRDacUfRjN6750jQwREyBSKpiOFNhNarKXW01VNUs+F5EnXg39rNCFZRlndN2+86eHO9JaaeRnG3oauJKnxdJGjBEGdloNBq5Mh25fvhkoFY7h36qJ3CyPrT3vfT+goDfdMYLfAuIjahKXudOWTQu0X/0/XDTIkuHmwW/jIOqXAOFiLhoLsznIX94lFuZxhWDfXc0LZ63jkyk42T6rIYZW0oUAkLKg728yhNX/dQ8meiIOrOJL7YWX78BZGpNMBdlZfWVcJ9K7Qvhfa6JU5DgjI1tGNdKbvuI1J+eDFWkPiZjprt+I0mdXGbnk4asXeh/bDVmQjHGKpgtvsUFnQCY3MCpPv+hK9AVORzRewNuQ3VPqvqUlUiM9l9bq5Ut45WSQCAYVD3T6gplKTwG2C50H/2TjG+YVmH8KvCQzSWhw7EWRpTwzwgBp0L1sUsw 4vTIHxYF aYDghIcDLx02ULnD4gKR+p5K8+w2ojap19kkDPId6KzLtMOZxMhPImO5ZOFDLqat+57hpTKEfSjcSBqeG3Yv7rhhR8wah2SbsVhbYs9UaYXsl8qYsztzuZqi82vRopFl+EH1LsGvPj73ufCLvLIc78etqB9cK3MtFxKY9FC2fsOZWHl0UauKDCXBknwP9jUCT63D4D+5MHz87VYq4Tm0oxEsYSO5kHzo5GLhMjO0Az7PilQY80mfwgTX6UDsJUs29l7JUjKcHRALqD+QtrohwwJZnGw85vUbBk4zbGg9JGDghSQo+Y6skwKSKgLmkecZKdyDxMmrpMSacnJ8ToL8bxw8v8w== 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: Secondary TLBs are now invalidated from the architecture specific TLB invalidation functions. Therefore there is no need to explicitly notify or invalidate as part of the range end functions. This means we can remove mmu_notifier_invalidate_range_end_only() and some of the ptep_*_notify() functions. Signed-off-by: Alistair Popple Reviewed-by: Jason Gunthorpe --- include/linux/mmu_notifier.h | 56 +------------------------------------ kernel/events/uprobes.c | 2 +- mm/huge_memory.c | 25 ++--------------- mm/hugetlb.c | 1 +- mm/memory.c | 8 +---- mm/migrate_device.c | 9 +----- mm/mmu_notifier.c | 25 ++--------------- mm/rmap.c | 40 +-------------------------- 8 files changed, 14 insertions(+), 152 deletions(-) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 64a3e05..f2e9edc 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -395,8 +395,7 @@ extern int __mmu_notifier_test_young(struct mm_struct *mm, extern void __mmu_notifier_change_pte(struct mm_struct *mm, unsigned long address, pte_t pte); extern int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *r); -extern void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *r, - bool only_end); +extern void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *r); extern void __mmu_notifier_invalidate_range(struct mm_struct *mm, unsigned long start, unsigned long end); extern bool @@ -481,14 +480,7 @@ mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) might_sleep(); if (mm_has_notifiers(range->mm)) - __mmu_notifier_invalidate_range_end(range, false); -} - -static inline void -mmu_notifier_invalidate_range_only_end(struct mmu_notifier_range *range) -{ - if (mm_has_notifiers(range->mm)) - __mmu_notifier_invalidate_range_end(range, true); + __mmu_notifier_invalidate_range_end(range); } static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, @@ -582,45 +574,6 @@ static inline void mmu_notifier_range_init_owner( __young; \ }) -#define ptep_clear_flush_notify(__vma, __address, __ptep) \ -({ \ - unsigned long ___addr = __address & PAGE_MASK; \ - struct mm_struct *___mm = (__vma)->vm_mm; \ - pte_t ___pte; \ - \ - ___pte = ptep_clear_flush(__vma, __address, __ptep); \ - mmu_notifier_invalidate_range(___mm, ___addr, \ - ___addr + PAGE_SIZE); \ - \ - ___pte; \ -}) - -#define pmdp_huge_clear_flush_notify(__vma, __haddr, __pmd) \ -({ \ - unsigned long ___haddr = __haddr & HPAGE_PMD_MASK; \ - struct mm_struct *___mm = (__vma)->vm_mm; \ - pmd_t ___pmd; \ - \ - ___pmd = pmdp_huge_clear_flush(__vma, __haddr, __pmd); \ - mmu_notifier_invalidate_range(___mm, ___haddr, \ - ___haddr + HPAGE_PMD_SIZE); \ - \ - ___pmd; \ -}) - -#define pudp_huge_clear_flush_notify(__vma, __haddr, __pud) \ -({ \ - unsigned long ___haddr = __haddr & HPAGE_PUD_MASK; \ - struct mm_struct *___mm = (__vma)->vm_mm; \ - pud_t ___pud; \ - \ - ___pud = pudp_huge_clear_flush(__vma, __haddr, __pud); \ - mmu_notifier_invalidate_range(___mm, ___haddr, \ - ___haddr + HPAGE_PUD_SIZE); \ - \ - ___pud; \ -}) - /* * set_pte_at_notify() sets the pte _after_ running the notifier. * This is safe to start by updating the secondary MMUs, because the primary MMU @@ -711,11 +664,6 @@ void mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) { } -static inline void -mmu_notifier_invalidate_range_only_end(struct mmu_notifier_range *range) -{ -} - static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, unsigned long start, unsigned long end) { diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index f0ac5b8..3048589 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -193,7 +193,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, } flush_cache_page(vma, addr, pte_pfn(ptep_get(pvmw.pte))); - ptep_clear_flush_notify(vma, addr, pvmw.pte); + ptep_clear_flush(vma, addr, pvmw.pte); if (new_page) set_pte_at_notify(mm, addr, pvmw.pte, mk_pte(new_page, vma->vm_page_prot)); diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 762be2f..3ece117 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2003,7 +2003,7 @@ static void __split_huge_pud_locked(struct vm_area_struct *vma, pud_t *pud, count_vm_event(THP_SPLIT_PUD); - pudp_huge_clear_flush_notify(vma, haddr, pud); + pudp_huge_clear_flush(vma, haddr, pud); } void __split_huge_pud(struct vm_area_struct *vma, pud_t *pud, @@ -2023,11 +2023,7 @@ void __split_huge_pud(struct vm_area_struct *vma, pud_t *pud, out: spin_unlock(ptl); - /* - * No need to double call mmu_notifier->invalidate_range() callback as - * the above pudp_huge_clear_flush_notify() did already call it. - */ - mmu_notifier_invalidate_range_only_end(&range); + mmu_notifier_invalidate_range_end(&range); } #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ @@ -2094,7 +2090,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, count_vm_event(THP_SPLIT_PMD); if (!vma_is_anonymous(vma)) { - old_pmd = pmdp_huge_clear_flush_notify(vma, haddr, pmd); + old_pmd = pmdp_huge_clear_flush(vma, haddr, pmd); /* * We are going to unmap this huge page. So * just go ahead and zap it @@ -2304,20 +2300,7 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, out: spin_unlock(ptl); - /* - * No need to double call mmu_notifier->invalidate_range() callback. - * They are 3 cases to consider inside __split_huge_pmd_locked(): - * 1) pmdp_huge_clear_flush_notify() call invalidate_range() obvious - * 2) __split_huge_zero_page_pmd() read only zero page and any write - * fault will trigger a flush_notify before pointing to a new page - * (it is fine if the secondary mmu keeps pointing to the old zero - * page in the meantime) - * 3) Split a huge pmd into pte pointing to the same page. No need - * to invalidate secondary tlb entry they are all still valid. - * any further changes to individual pte will notify. So no need - * to call mmu_notifier->invalidate_range() - */ - mmu_notifier_invalidate_range_only_end(&range); + mmu_notifier_invalidate_range_end(&range); } void split_huge_pmd_address(struct vm_area_struct *vma, unsigned long address, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index dc1ec19..9c6e431 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5715,7 +5715,6 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma, /* Break COW or unshare */ huge_ptep_clear_flush(vma, haddr, ptep); - mmu_notifier_invalidate_range(mm, range.start, range.end); page_remove_rmap(&old_folio->page, vma, true); hugepage_add_new_anon_rmap(new_folio, vma, haddr); if (huge_pte_uffd_wp(pte)) diff --git a/mm/memory.c b/mm/memory.c index ad79039..8dca544 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3158,7 +3158,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) * that left a window where the new PTE could be loaded into * some TLBs while the old PTE remains in others. */ - ptep_clear_flush_notify(vma, vmf->address, vmf->pte); + ptep_clear_flush(vma, vmf->address, vmf->pte); folio_add_new_anon_rmap(new_folio, vma, vmf->address); folio_add_lru_vma(new_folio, vma); /* @@ -3204,11 +3204,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); } - /* - * No need to double call mmu_notifier->invalidate_range() callback as - * the above ptep_clear_flush_notify() did already call it. - */ - mmu_notifier_invalidate_range_only_end(&range); + mmu_notifier_invalidate_range_end(&range); if (new_folio) folio_put(new_folio); diff --git a/mm/migrate_device.c b/mm/migrate_device.c index e29626e..6c556b5 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -658,7 +658,7 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, if (flush) { flush_cache_page(vma, addr, pte_pfn(orig_pte)); - ptep_clear_flush_notify(vma, addr, ptep); + ptep_clear_flush(vma, addr, ptep); set_pte_at_notify(mm, addr, ptep, entry); update_mmu_cache(vma, addr, ptep); } else { @@ -763,13 +763,8 @@ static void __migrate_device_pages(unsigned long *src_pfns, src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; } - /* - * No need to double call mmu_notifier->invalidate_range() callback as - * the above ptep_clear_flush_notify() inside migrate_vma_insert_page() - * did already call it. - */ if (notified) - mmu_notifier_invalidate_range_only_end(&range); + mmu_notifier_invalidate_range_end(&range); } /** diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index b7ad155..453a156 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -551,7 +551,7 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) static void mn_hlist_invalidate_end(struct mmu_notifier_subscriptions *subscriptions, - struct mmu_notifier_range *range, bool only_end) + struct mmu_notifier_range *range) { struct mmu_notifier *subscription; int id; @@ -559,24 +559,6 @@ mn_hlist_invalidate_end(struct mmu_notifier_subscriptions *subscriptions, id = srcu_read_lock(&srcu); hlist_for_each_entry_rcu(subscription, &subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { - /* - * Call invalidate_range here too to avoid the need for the - * subsystem of having to register an invalidate_range_end - * call-back when there is invalidate_range already. Usually a - * subsystem registers either invalidate_range_start()/end() or - * invalidate_range(), so this will be no additional overhead - * (besides the pointer check). - * - * We skip call to invalidate_range() if we know it is safe ie - * call site use mmu_notifier_invalidate_range_only_end() which - * is safe to do when we know that a call to invalidate_range() - * already happen under page table lock. - */ - if (!only_end && subscription->ops->invalidate_range) - subscription->ops->invalidate_range(subscription, - range->mm, - range->start, - range->end); if (subscription->ops->invalidate_range_end) { if (!mmu_notifier_range_blockable(range)) non_block_start(); @@ -589,8 +571,7 @@ mn_hlist_invalidate_end(struct mmu_notifier_subscriptions *subscriptions, srcu_read_unlock(&srcu, id); } -void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range, - bool only_end) +void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) { struct mmu_notifier_subscriptions *subscriptions = range->mm->notifier_subscriptions; @@ -600,7 +581,7 @@ void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range, mn_itree_inv_end(subscriptions); if (!hlist_empty(&subscriptions->list)) - mn_hlist_invalidate_end(subscriptions, range, only_end); + mn_hlist_invalidate_end(subscriptions, range); lock_map_release(&__mmu_notifier_invalidate_range_start_map); } diff --git a/mm/rmap.c b/mm/rmap.c index 1355bf6..51ec8aa 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -985,13 +985,6 @@ static int page_vma_mkclean_one(struct page_vma_mapped_walk *pvmw) #endif } - /* - * No need to call mmu_notifier_invalidate_range() as we are - * downgrading page table protection not changing it to point - * to a new page. - * - * See Documentation/mm/mmu_notifier.rst - */ if (ret) cleaned++; } @@ -1549,8 +1542,6 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, hugetlb_vma_unlock_write(vma); flush_tlb_range(vma, range.start, range.end); - mmu_notifier_invalidate_range(mm, - range.start, range.end); /* * The ref count of the PMD page was * dropped which is part of the way map @@ -1623,9 +1614,6 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, * copied pages. */ dec_mm_counter(mm, mm_counter(&folio->page)); - /* We have to invalidate as we cleared the pte */ - mmu_notifier_invalidate_range(mm, address, - address + PAGE_SIZE); } else if (folio_test_anon(folio)) { swp_entry_t entry = { .val = page_private(subpage) }; pte_t swp_pte; @@ -1637,9 +1625,6 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, folio_test_swapcache(folio))) { WARN_ON_ONCE(1); ret = false; - /* We have to invalidate as we cleared the pte */ - mmu_notifier_invalidate_range(mm, address, - address + PAGE_SIZE); page_vma_mapped_walk_done(&pvmw); break; } @@ -1670,9 +1655,6 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, */ if (ref_count == 1 + map_count && !folio_test_dirty(folio)) { - /* Invalidate as we cleared the pte */ - mmu_notifier_invalidate_range(mm, - address, address + PAGE_SIZE); dec_mm_counter(mm, MM_ANONPAGES); goto discard; } @@ -1727,9 +1709,6 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, if (pte_uffd_wp(pteval)) swp_pte = pte_swp_mkuffd_wp(swp_pte); set_pte_at(mm, address, pvmw.pte, swp_pte); - /* Invalidate as we cleared the pte */ - mmu_notifier_invalidate_range(mm, address, - address + PAGE_SIZE); } else { /* * This is a locked file-backed folio, @@ -1745,13 +1724,6 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, dec_mm_counter(mm, mm_counter_file(&folio->page)); } discard: - /* - * No need to call mmu_notifier_invalidate_range() it has be - * done above for all cases requiring it to happen under page - * table lock before mmu_notifier_invalidate_range_end() - * - * See Documentation/mm/mmu_notifier.rst - */ page_remove_rmap(subpage, vma, folio_test_hugetlb(folio)); if (vma->vm_flags & VM_LOCKED) mlock_drain_local(); @@ -1930,8 +1902,6 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, hugetlb_vma_unlock_write(vma); flush_tlb_range(vma, range.start, range.end); - mmu_notifier_invalidate_range(mm, - range.start, range.end); /* * The ref count of the PMD page was @@ -2036,9 +2006,6 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, * copied pages. */ dec_mm_counter(mm, mm_counter(&folio->page)); - /* We have to invalidate as we cleared the pte */ - mmu_notifier_invalidate_range(mm, address, - address + PAGE_SIZE); } else { swp_entry_t entry; pte_t swp_pte; @@ -2102,13 +2069,6 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, */ } - /* - * No need to call mmu_notifier_invalidate_range() it has be - * done above for all cases requiring it to happen under page - * table lock before mmu_notifier_invalidate_range_end() - * - * See Documentation/mm/mmu_notifier.rst - */ page_remove_rmap(subpage, vma, folio_test_hugetlb(folio)); if (vma->vm_flags & VM_LOCKED) mlock_drain_local(); From patchwork Thu Jul 20 08:39:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13320122 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 93542EB64DC for ; Thu, 20 Jul 2023 08:40:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 219802800DD; Thu, 20 Jul 2023 04:40:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C9A728004C; Thu, 20 Jul 2023 04:40:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 043CE2800DD; Thu, 20 Jul 2023 04:40:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E736528004C for ; Thu, 20 Jul 2023 04:40:19 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BCB271A0215 for ; Thu, 20 Jul 2023 08:40:19 +0000 (UTC) X-FDA: 81031343358.22.D8C4346 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2071.outbound.protection.outlook.com [40.107.237.71]) by imf17.hostedemail.com (Postfix) with ESMTP id D471040005 for ; Thu, 20 Jul 2023 08:40:16 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=mE3VgSkr; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf17.hostedemail.com: domain of apopple@nvidia.com designates 40.107.237.71 as permitted sender) smtp.mailfrom=apopple@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689842416; 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=MH28H+CAnzGmPruk0vGr9QVHzZtmLOQboUMLWND1YGU=; b=E3o+J810MXcLmKjs1WrubSCzPPWWZsHpoJFuwGbwsPZ06X3jQq+Z8Q/z1dtPxbeaY3L1BD h0VOxUaIkCaxXifJTnDv9o/PFJnkSPziUiZzMNLe7RjnXy2L2nRlesGVh7QFbI2t+q3Pnp wQo3DHSb1fY4Ovxm6IHxBrU570ZpF0w= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=mE3VgSkr; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf17.hostedemail.com: domain of apopple@nvidia.com designates 40.107.237.71 as permitted sender) smtp.mailfrom=apopple@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1689842417; a=rsa-sha256; cv=pass; b=tEh/Q7UizmxG6sIEhO+FlIhq5p2v5+zV4q1XX0YTj2bb+cDSeMKtc6vnyLVPpAxtYSecbx t9jE4xg008fOz+AN9EJ74dMLRkl/CoxkGN1OVIBv6enGppFX/yaqxo2XTQ3IZ9D1E/K6QJ sO46Gd5o4ucXyUjCTGySVW5jTdUKrLc= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cp0sD6v7udW5RFf4udneb36JIpoguD3JuCQrUBGAQNIHTLbYnkKuiyD2ESJ1nwulGkS24XP8HtG9BYXL8/2Ahhc6d6gyj/kQ2JkDg34i2osgwllOBsDAmJ1pKok2y1c/pHqIGxUnIYSx6OTGnVkCj4hgEOqBaUnQECcgvsHDYjWOHQD8RKTJP9+vgDP6r6K8BD0PnMqZFPumGRR+sZFcx+FkEGH/8pJ5foVUtbWlJ1lzSu78FwETLmMDsV9WGhlqt112S+/Ak43d9k5cKFNJLOwc+QH0kAbU8qAZkTCaryKtsdHm1+vVI5r2yu1dTrBU56jXVZRafOMW7TfquWn2YA== 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=MH28H+CAnzGmPruk0vGr9QVHzZtmLOQboUMLWND1YGU=; b=BoFDiv66r18UgHbxA5bntoevMyj4UhZtdW/8yCALPOVbgQD480tny8FDpz4Dz1WhJW62opsOnYxxU1EsuF/agYqqGZxFTbGDseJRA/4NnEtJFED5PxmtmP2sVajINsbQcPBsixU1qfblww2+JhKSWO7PWhkxyxAx/T1yCCGcLNsoI0xLqK5T+lQRsIwHQxd8BaprSdxumCTlNvYy1kmrW612IPaoj3DJWhwxeGcK2+EyKXMwtjTxJDPBkww6y+wOZ+xdYREMohKUz0gfaopRHaO3M4vYiIfCyW/+y6JYBJe8Ld0ea+W0GODAymTb5XIUh5hKXhR2bia+I/eEp56eHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MH28H+CAnzGmPruk0vGr9QVHzZtmLOQboUMLWND1YGU=; b=mE3VgSkr4Zq62VrFLqFvZqijVQhldVPKcC92Z0aSLYdsNNtBktvQs6cQlPEg/Qdr0FDzk+7paWIeM7kryTPPRTsvUflZBF/1s0zNyJ9XS/IPftLa7MZF/dZMTnArn8jUbLArqzRpDZk7EOuO1Xb3yu9hJgrQ/cHwhffyUwpXzZF5KRo8Iz8MPj7022b3fQOB33X/bSJfLALSljSWQ92xAeu/Ys39HwPH4wbuJ6Q/Et2kTgWA67ZPi26td3jjfh9h7Fm239977wsIlxL3YZI6Eydzjx6g1FFxbnOUwoWDwN0K4wE9tItz1hcu0TamHbtG9b0RQHEHxS68VlleDpAWlQ== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by PH8PR12MB7025.namprd12.prod.outlook.com (2603:10b6:510:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:40:14 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::cd5e:7e33:c2c9:fb74%7]) with mapi id 15.20.6609.025; Thu, 20 Jul 2023 08:40:14 +0000 From: Alistair Popple To: akpm@linux-foundation.org Cc: ajd@linux.ibm.com, catalin.marinas@arm.com, fbarrat@linux.ibm.com, iommu@lists.linux.dev, jgg@ziepe.ca, jhubbard@nvidia.com, kevin.tian@intel.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, nicolinc@nvidia.com, npiggin@gmail.com, robin.murphy@arm.com, seanjc@google.com, will@kernel.org, x86@kernel.org, zhi.wang.linux@gmail.com, sj@kernel.org, Alistair Popple , Jason Gunthorpe Subject: [PATCH v3 5/5] mmu_notifiers: Rename invalidate_range notifier Date: Thu, 20 Jul 2023 18:39:27 +1000 Message-Id: <3cbd2a644d56d503b47cfc35868d547f924f880e.1689842332.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SYBPR01CA0156.ausprd01.prod.outlook.com (2603:10c6:10:d::24) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3176:EE_|PH8PR12MB7025:EE_ X-MS-Office365-Filtering-Correlation-Id: 05cbfbc1-c0ff-4054-614e-08db88fcefb4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q1RUZK5rBSPAC260poeKsGZQ67ToNdg7OP+9XBJ6wA39XWmMHi0W3R0vXPnUfYs4jKzzOxx+1kNld+Dxc/BSykJDe1EU4fE7nVGhkjMZJ02jAvf3B/g4/AOwaWoKFmPdDS98SbNh0Uuzq3wNtBKmr8i8lxq+Hjkg/5ibYLg4K6i1iXCaLJSC7HBZIxhSJ4HkAh1+AmpvEPC+fdPaGhzA+znYoOc9Yqehj1B1RKRKTsEQ9aw93AvZb8/rzOwejZvW8RM/n9XkL9JczjsH4nQtnoclbvLSYUzwrTmOTPQNeni0Xio+vILv4t0xE0M8mcBDp+v++6MbRphxqzqQwP+Zz6+XkZr6F4NpJF6fWCISwJIkFRw8lkgJoCL2JZUrmlu8IfVx1Drlnnv5OcR6owGwooICIL0zKlhb1/ntaaaaQV5s6M4UyR7y26hxh2BgUhv4BZKe8cnN6Tmc6FdzcQREYwI1f9JZ6mc5whT91EtsjR6QaTpxVfsh8+bku5uPmF7wsXc7me1BZ8YxJOBw1eV+oY9F6spRQVhv/0Jh7ROghCUBa5RwWGuqD7udsii+7jXyRdninviN8zv5FMusKQLKQgirzieEKqYjjTxByTpSx60= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(451199021)(36756003)(86362001)(38100700002)(186003)(7416002)(478600001)(6506007)(6666004)(26005)(41300700001)(66476007)(66946007)(4326008)(66556008)(6916009)(5660300002)(316002)(2616005)(8936002)(8676002)(83380400001)(6512007)(107886003)(6486002)(30864003)(54906003)(2906002)(473944003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Lu9/xGhECsxFSuPSVe21S4nShrycFRbZjy4S51HrMBfAgHUO2hFR+v33/n7Ihk3vfip4UkLaZKXwf0KnCDXHKG4icj08TVmSl42R0+5cTz96zkdnY/EYaTYB3goY1DnRfLUtMWrfTTeILj1UnsiN9ClL3N02SGYqU15ladFrpfr2KGMJUoV19vFE+sQs6f8NQJt31IqXgemQx7hRZp4ZgOchEvqGhpYlZwWdScNR7OkAkVb5R0/K9168hTO6awdUb1ZKYQoGyFZ3yZjNNNmo3SFXQuW8FgKQgN7P9T26EhxCihx1Dep9edpNxMSIt2edRaTOrk0Cu7wU/T8FtYNMtGzTj4zxU/w0rSOXvnLQTfRlccybKUyPaf/kd4pj/JYW0fjV5DIUYS2FG7SWCkjjtG0ylT7PTdbVT02+x13VnhUApIrjDWa+ZeLVM7DWygBuKnAKss3yAeDJQ2t+50CvWR97bemW+dVlw03ObCYRmtom8x0+F6k6xFSnYgD3XFFaZOIHn8xLsnntYfa+wl0i1uPc8/5hjgbjCaRHNy/KK0Dr/SOpPHQfxPc/9hhBNz8DcWaZ9csjrXd28CyOpKd6cOjyd/RIztc19gYDAZDJ6xbjgfZ5qFjnsPLmvfFo2/WTcSrWdS4I8T8VHQ17F4Un9Wp/1I+aJ/A76xPtYZYQ/owUFGUi9Kx2a5OAzs7ktbGRl4xPrRD8006DNwodDeuQbszZ7MDO9gSS7aQRdyT75OHT/4bsDaJbVufmdY6U2uMq2Cv/6x9mapH2a+rqn+fHqFrX8d5Qnv9mQO3URXkM3JppnG/MxxFDgBzsjQjMGV9FNrJ1Zqd1kq5W6yjz6bHjPP1awv+c02hrlixNu9iBqsvVV5tvhKP4tP2OcziEJ4cfgEWpfDP68by2QVtTI/25TyVWcFRxKDW9jZ1JdMX/Furt3DsntPd8h/woEahsQgZ0CoQk2o3eS9ExVBJ7MyLNyWuwGOEFsE10eJiO3G0dXCVaIe8sxv/HdHyBDZ0OVSTf+dc0on7xRfvtR+tCLOBHA7wXtdMUvQrAsudsxcM/kLGK/1lFoelnJljJ/YOCqsCXg94v1wFijvh/aN8Qg2vr6A9tHobHdHKkN5hspc1yFw7dKCS/Yt3QdbJjBbRlgw78+wV6NoRSrHKAcqdA+X9iv9nHgvqbBc3CyrWbDUeJaVB8thL5Fg4zWfJ2wQfm0NfciKTZZ3Qn3divMnuZH9yBCaZLSMb99DvRfDHrvLJjx8FEGVhFguPCtIxksfK04Ke03AV5O9LB7Q4dkuF2pbOT54xOuRGnjdDhNUVjkDjwtVDT91xX7HmDvk4uzxMdPJ/1Kw4mXm6IbQyqUUXYJU+VqlKO8nZ0uIVH5N7dh98GAD7RkMPW9981OkIXRe1pOrukn5JMDnBj/8IbN4UbnfHDA8nUMmEWzhTVwbytwIGBW80zroEDko62oUuP/R/BY542/1+IlMf6sdScpSzSH2E+TLkxl2pJ5Krl9jd+ewR3z0kNyAe5FURiW6ezi459z3x9NiKir4XMBfH6hztfYVVcVTaZxP3Y7yOaw0mT2rILsQwojRpB6KmldCvtiJjWw4Nt X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05cbfbc1-c0ff-4054-614e-08db88fcefb4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:40:14.0687 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tix7EeaDS6l53ammRLs09uuO6zUxjam7jToWa7NELS3yf9S5uR7dpmf3vtRf5ORNgZt1wd3vx0Q3+/eMZ8QQ9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7025 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D471040005 X-Stat-Signature: 1x6e83djo6g3hiersc5qwzh6gxzhgygb X-HE-Tag: 1689842416-681298 X-HE-Meta: U2FsdGVkX1+l2hnjLE4BzXYBrCarl7CVpZF5vBz+xobL8xxcQKYKLXfRJNZ8B6Kas6QKhvE2VakTMWQMGPfRcNBlplZLskCFcmKD5YAmzr1xW8xHATRF3MmLYUaMBTipNXPOf9rO9fSTIzegmfSSZGhoQLOlyC1pI6v1iJ3wi4eQ9XmgZGzWv+UsUneibrmkdlK6Y+8J7QkaXTap6mO7ovKPaVUL+gP4+oek5C0tIMg8I25+Lc+azvR+hoB/XFldxPl0mmloKzX2hgmKrnxfcQ3nm3HCZXPtf/s4ApknA2F7Z180joGoPnwgoh+47HBDfhvfW1PIEEE/QjsFFWYd4ues82v5GcEO/+EFCuj9hEJNRTyzm8Q4kp8hTtmOPa9M2hhoSok7jyJfeZCMw4AMQAe52diBzRvybPKj6dGg+9A92WmNs7Vb+B9rt8jsftx+NTXR+DcGXfvLDU7JJdCO3XYO4/M5E/kYxLp/jKRBZo2YK3urVSQ1ScZ4Ay5c3bwVYjidJb4jvGYilcG2Cadlhiib+qx3dcM9AaGIeoP5MGa0Istnqp6MYq/N3CWMQZSrw583Cw0Hzu4gdOMPGmMOLqdPw/gbxTd6NFOMPd0pW/F+BXLW/a4SCreulKLbdEjs3gZ2dWA8lu9SRNzEB5uPp4BiOGgXgVwefudewOuhXCRTqmgwUb+cdTTfsKBfTBnIdBAG/XWsrP9yv0+yhDe9Ev9gM6C0MTvZEkfwqUFlB6ACV+J9Dke10AQKb0TuwK73tvkIsYD5ZCaB1p4ZrhSlPVcrzX0YzP365oJFi5hlU3c0MMJ435DC92R1uZgbRdCBitlQs1Amiz6OqhA0tJvH6JXK9WN90myqlinlcZJPDggGVE/XACpkKAy2TZmRWUAcYKQcBHPd58jThp1z1NKLLwXOOtZg0IDowKhmX/9lzilJJOsf33/Uc5lnbxx1zKjjBzMspC9R3E++XEmBRo5 cHwvzgqa 3HuvbLM0k7dev3l/HxwScC8HGzb5ribe0SJNUYzAESDzO8GAigJFZiy+sh8IBJFMGGJNf40P9V69zO1yTfR2cNpKygH6pnCxcW/gToBTJsRYLz1IbzGPqqkhyLRpbN5ywcOr0G0o5k/riqyhDUn3qQI3lb6fIRZxMyWcfNND7VGSYeJ1uAViuNYlYkVeITzHQrXuK/AbtPASxnh46vYjuf1AFwwpvGqKA01WPiHEaR2mSCkagMipPk7zS2GRNHhwNicHtzNwVqlQZG2KKLkdKSwC6wAstO9/ay8LATMLcjPbE0cU8Wgd/o5T34gKthMmpVQXzrZUcNxTjNY2FPMrRdNZsLw== 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: There are two main use cases for mmu notifiers. One is by KVM which uses mmu_notifier_invalidate_range_start()/end() to manage a software TLB. The other is to manage hardware TLBs which need to use the invalidate_range() callback because HW can establish new TLB entries at any time. Hence using start/end() can lead to memory corruption as these callbacks happen too soon/late during page unmap. mmu notifier users should therefore either use the start()/end() callbacks or the invalidate_range() callbacks. To make this usage clearer rename the invalidate_range() callback to arch_invalidate_secondary_tlbs() and update documention. Signed-off-by: Alistair Popple Suggested-by: Jason Gunthorpe Acked-by: Catalin Marinas Reviewed-by: Jason Gunthorpe --- arch/arm64/include/asm/tlbflush.h | 6 +- arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 2 +- arch/powerpc/mm/book3s64/radix_tlb.c | 10 ++-- arch/x86/include/asm/tlbflush.h | 2 +- arch/x86/mm/tlb.c | 2 +- drivers/iommu/amd/iommu_v2.c | 10 ++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 13 ++--- drivers/iommu/intel/svm.c | 8 +-- drivers/misc/ocxl/link.c | 8 +-- include/linux/mmu_notifier.h | 48 +++++++++--------- mm/huge_memory.c | 4 +- mm/hugetlb.c | 7 +-- mm/mmu_notifier.c | 20 ++++++-- 13 files changed, 76 insertions(+), 64 deletions(-) diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index a99349d..84a05a0 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -253,7 +253,7 @@ static inline void flush_tlb_mm(struct mm_struct *mm) __tlbi(aside1is, asid); __tlbi_user(aside1is, asid); dsb(ish); - mmu_notifier_invalidate_range(mm, 0, -1UL); + mmu_notifier_arch_invalidate_secondary_tlbs(mm, 0, -1UL); } static inline void __flush_tlb_page_nosync(struct mm_struct *mm, @@ -265,7 +265,7 @@ static inline void __flush_tlb_page_nosync(struct mm_struct *mm, addr = __TLBI_VADDR(uaddr, ASID(mm)); __tlbi(vale1is, addr); __tlbi_user(vale1is, addr); - mmu_notifier_invalidate_range(mm, uaddr & PAGE_MASK, + mmu_notifier_arch_invalidate_secondary_tlbs(mm, uaddr & PAGE_MASK, (uaddr & PAGE_MASK) + PAGE_SIZE); } @@ -400,7 +400,7 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, scale++; } dsb(ish); - mmu_notifier_invalidate_range(vma->vm_mm, start, end); + mmu_notifier_arch_invalidate_secondary_tlbs(vma->vm_mm, start, end); } static inline void flush_tlb_range(struct vm_area_struct *vma, diff --git a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c index f3fb49f..17075c7 100644 --- a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c +++ b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c @@ -39,7 +39,7 @@ void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma, unsigned long st radix__flush_tlb_pwc_range_psize(vma->vm_mm, start, end, psize); else radix__flush_tlb_range_psize(vma->vm_mm, start, end, psize); - mmu_notifier_invalidate_range(vma->vm_mm, start, end); + mmu_notifier_arch_invalidate_secondary_tlbs(vma->vm_mm, start, end); } void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c index 9724b26..64c11a4 100644 --- a/arch/powerpc/mm/book3s64/radix_tlb.c +++ b/arch/powerpc/mm/book3s64/radix_tlb.c @@ -752,7 +752,7 @@ void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmadd return radix__local_flush_hugetlb_page(vma, vmaddr); #endif radix__local_flush_tlb_page_psize(vma->vm_mm, vmaddr, mmu_virtual_psize); - mmu_notifier_invalidate_range(vma->vm_mm, vmaddr, + mmu_notifier_arch_invalidate_secondary_tlbs(vma->vm_mm, vmaddr, vmaddr + mmu_virtual_psize); } EXPORT_SYMBOL(radix__local_flush_tlb_page); @@ -989,7 +989,7 @@ void radix__flush_tlb_mm(struct mm_struct *mm) } } preempt_enable(); - mmu_notifier_invalidate_range(mm, 0, -1UL); + mmu_notifier_arch_invalidate_secondary_tlbs(mm, 0, -1UL); } EXPORT_SYMBOL(radix__flush_tlb_mm); @@ -1023,7 +1023,7 @@ static void __flush_all_mm(struct mm_struct *mm, bool fullmm) _tlbiel_pid_multicast(mm, pid, RIC_FLUSH_ALL); } preempt_enable(); - mmu_notifier_invalidate_range(mm, 0, -1UL); + mmu_notifier_arch_invalidate_secondary_tlbs(mm, 0, -1UL); } void radix__flush_all_mm(struct mm_struct *mm) @@ -1232,7 +1232,7 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm, } out: preempt_enable(); - mmu_notifier_invalidate_range(mm, start, end); + mmu_notifier_arch_invalidate_secondary_tlbs(mm, start, end); } void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start, @@ -1397,7 +1397,7 @@ static void __radix__flush_tlb_range_psize(struct mm_struct *mm, } out: preempt_enable(); - mmu_notifier_invalidate_range(mm, start, end); + mmu_notifier_arch_invalidate_secondary_tlbs(mm, start, end); } void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start, diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 0a54323..6ab42ca 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -283,7 +283,7 @@ static inline void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *b { inc_mm_tlb_gen(mm); cpumask_or(&batch->cpumask, &batch->cpumask, mm_cpumask(mm)); - mmu_notifier_invalidate_range(mm, 0, -1UL); + mmu_notifier_arch_invalidate_secondary_tlbs(mm, 0, -1UL); } static inline void arch_flush_tlb_batched_pending(struct mm_struct *mm) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 93b2f81..2d25391 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1037,7 +1037,7 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, put_flush_tlb_info(); put_cpu(); - mmu_notifier_invalidate_range(mm, start, end); + mmu_notifier_arch_invalidate_secondary_tlbs(mm, start, end); } diff --git a/drivers/iommu/amd/iommu_v2.c b/drivers/iommu/amd/iommu_v2.c index 261352a..2596466 100644 --- a/drivers/iommu/amd/iommu_v2.c +++ b/drivers/iommu/amd/iommu_v2.c @@ -355,9 +355,9 @@ static struct pasid_state *mn_to_state(struct mmu_notifier *mn) return container_of(mn, struct pasid_state, mn); } -static void mn_invalidate_range(struct mmu_notifier *mn, - struct mm_struct *mm, - unsigned long start, unsigned long end) +static void mn_arch_invalidate_secondary_tlbs(struct mmu_notifier *mn, + struct mm_struct *mm, + unsigned long start, unsigned long end) { struct pasid_state *pasid_state; struct device_state *dev_state; @@ -391,8 +391,8 @@ static void mn_release(struct mmu_notifier *mn, struct mm_struct *mm) } static const struct mmu_notifier_ops iommu_mn = { - .release = mn_release, - .invalidate_range = mn_invalidate_range, + .release = mn_release, + .arch_invalidate_secondary_tlbs = mn_arch_invalidate_secondary_tlbs, }; static void set_pri_tag_status(struct pasid_state *pasid_state, diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index 2a19784..dbc812a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -186,9 +186,10 @@ static void arm_smmu_free_shared_cd(struct arm_smmu_ctx_desc *cd) } } -static void arm_smmu_mm_invalidate_range(struct mmu_notifier *mn, - struct mm_struct *mm, - unsigned long start, unsigned long end) +static void arm_smmu_mm_arch_invalidate_secondary_tlbs(struct mmu_notifier *mn, + struct mm_struct *mm, + unsigned long start, + unsigned long end) { struct arm_smmu_mmu_notifier *smmu_mn = mn_to_smmu(mn); struct arm_smmu_domain *smmu_domain = smmu_mn->domain; @@ -247,9 +248,9 @@ static void arm_smmu_mmu_notifier_free(struct mmu_notifier *mn) } static const struct mmu_notifier_ops arm_smmu_mmu_notifier_ops = { - .invalidate_range = arm_smmu_mm_invalidate_range, - .release = arm_smmu_mm_release, - .free_notifier = arm_smmu_mmu_notifier_free, + .arch_invalidate_secondary_tlbs = arm_smmu_mm_arch_invalidate_secondary_tlbs, + .release = arm_smmu_mm_release, + .free_notifier = arm_smmu_mmu_notifier_free, }; /* Allocate or get existing MMU notifier for this {domain, mm} pair */ diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index e95b339..8f6d680 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -219,9 +219,9 @@ static void intel_flush_svm_range(struct intel_svm *svm, unsigned long address, } /* Pages have been freed at this point */ -static void intel_invalidate_range(struct mmu_notifier *mn, - struct mm_struct *mm, - unsigned long start, unsigned long end) +static void intel_arch_invalidate_secondary_tlbs(struct mmu_notifier *mn, + struct mm_struct *mm, + unsigned long start, unsigned long end) { struct intel_svm *svm = container_of(mn, struct intel_svm, notifier); @@ -256,7 +256,7 @@ static void intel_mm_release(struct mmu_notifier *mn, struct mm_struct *mm) static const struct mmu_notifier_ops intel_mmuops = { .release = intel_mm_release, - .invalidate_range = intel_invalidate_range, + .arch_invalidate_secondary_tlbs = intel_arch_invalidate_secondary_tlbs, }; static DEFINE_MUTEX(pasid_mutex); diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c index 4cf4c55..c06c699 100644 --- a/drivers/misc/ocxl/link.c +++ b/drivers/misc/ocxl/link.c @@ -491,9 +491,9 @@ void ocxl_link_release(struct pci_dev *dev, void *link_handle) } EXPORT_SYMBOL_GPL(ocxl_link_release); -static void invalidate_range(struct mmu_notifier *mn, - struct mm_struct *mm, - unsigned long start, unsigned long end) +static void arch_invalidate_secondary_tlbs(struct mmu_notifier *mn, + struct mm_struct *mm, + unsigned long start, unsigned long end) { struct pe_data *pe_data = container_of(mn, struct pe_data, mmu_notifier); struct ocxl_link *link = pe_data->link; @@ -509,7 +509,7 @@ static void invalidate_range(struct mmu_notifier *mn, } static const struct mmu_notifier_ops ocxl_mmu_notifier_ops = { - .invalidate_range = invalidate_range, + .arch_invalidate_secondary_tlbs = arch_invalidate_secondary_tlbs, }; static u64 calculate_cfg_state(bool kernel) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index f2e9edc..6e3c857 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -187,27 +187,27 @@ struct mmu_notifier_ops { const struct mmu_notifier_range *range); /* - * invalidate_range() is either called between - * invalidate_range_start() and invalidate_range_end() when the - * VM has to free pages that where unmapped, but before the - * pages are actually freed, or outside of _start()/_end() when - * a (remote) TLB is necessary. + * arch_invalidate_secondary_tlbs() is used to manage a non-CPU TLB + * which shares page-tables with the CPU. The + * invalidate_range_start()/end() callbacks should not be implemented as + * invalidate_secondary_tlbs() already catches the points in time when + * an external TLB needs to be flushed. * - * If invalidate_range() is used to manage a non-CPU TLB with - * shared page-tables, it not necessary to implement the - * invalidate_range_start()/end() notifiers, as - * invalidate_range() already catches the points in time when an - * external TLB range needs to be flushed. For more in depth - * discussion on this see Documentation/mm/mmu_notifier.rst + * This requires arch_invalidate_secondary_tlbs() to be called while + * holding the ptl spin-lock and therefore this callback is not allowed + * to sleep. * - * Note that this function might be called with just a sub-range - * of what was passed to invalidate_range_start()/end(), if - * called between those functions. + * This is called by architecture code whenever invalidating a TLB + * entry. It is assumed that any secondary TLB has the same rules for + * when invalidations are required. If this is not the case architecture + * code will need to call this explicitly when required for secondary + * TLB invalidation. */ - void (*invalidate_range)(struct mmu_notifier *subscription, - struct mm_struct *mm, - unsigned long start, - unsigned long end); + void (*arch_invalidate_secondary_tlbs)( + struct mmu_notifier *subscription, + struct mm_struct *mm, + unsigned long start, + unsigned long end); /* * These callbacks are used with the get/put interface to manage the @@ -396,8 +396,8 @@ extern void __mmu_notifier_change_pte(struct mm_struct *mm, unsigned long address, pte_t pte); extern int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *r); extern void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *r); -extern void __mmu_notifier_invalidate_range(struct mm_struct *mm, - unsigned long start, unsigned long end); +extern void __mmu_notifier_arch_invalidate_secondary_tlbs(struct mm_struct *mm, + unsigned long start, unsigned long end); extern bool mmu_notifier_range_update_to_read_only(const struct mmu_notifier_range *range); @@ -483,11 +483,11 @@ mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) __mmu_notifier_invalidate_range_end(range); } -static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, - unsigned long start, unsigned long end) +static inline void mmu_notifier_arch_invalidate_secondary_tlbs(struct mm_struct *mm, + unsigned long start, unsigned long end) { if (mm_has_notifiers(mm)) - __mmu_notifier_invalidate_range(mm, start, end); + __mmu_notifier_arch_invalidate_secondary_tlbs(mm, start, end); } static inline void mmu_notifier_subscriptions_init(struct mm_struct *mm) @@ -664,7 +664,7 @@ void mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) { } -static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, +static inline void mmu_notifier_arch_invalidate_secondary_tlbs(struct mm_struct *mm, unsigned long start, unsigned long end) { } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3ece117..e0420de 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2120,8 +2120,8 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, if (is_huge_zero_pmd(*pmd)) { /* * FIXME: Do we want to invalidate secondary mmu by calling - * mmu_notifier_invalidate_range() see comments below inside - * __split_huge_pmd() ? + * mmu_notifier_arch_invalidate_secondary_tlbs() see comments below + * inside __split_huge_pmd() ? * * We are going from a zero huge page write protected to zero * small page also write protected so it does not seems useful diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 9c6e431..e0028cb 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6676,8 +6676,9 @@ long hugetlb_change_protection(struct vm_area_struct *vma, else flush_hugetlb_tlb_range(vma, start, end); /* - * No need to call mmu_notifier_invalidate_range() we are downgrading - * page table protection not changing it to point to a new page. + * No need to call mmu_notifier_arch_invalidate_secondary_tlbs() we are + * downgrading page table protection not changing it to point to a new + * page. * * See Documentation/mm/mmu_notifier.rst */ @@ -7321,7 +7322,7 @@ static void hugetlb_unshare_pmds(struct vm_area_struct *vma, i_mmap_unlock_write(vma->vm_file->f_mapping); hugetlb_vma_unlock_write(vma); /* - * No need to call mmu_notifier_invalidate_range(), see + * No need to call mmu_notifier_arch_invalidate_secondary_tlbs(), see * Documentation/mm/mmu_notifier.rst. */ mmu_notifier_invalidate_range_end(&range); diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 453a156..63c8eb7 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -585,8 +585,8 @@ void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) lock_map_release(&__mmu_notifier_invalidate_range_start_map); } -void __mmu_notifier_invalidate_range(struct mm_struct *mm, - unsigned long start, unsigned long end) +void __mmu_notifier_arch_invalidate_secondary_tlbs(struct mm_struct *mm, + unsigned long start, unsigned long end) { struct mmu_notifier *subscription; int id; @@ -595,9 +595,10 @@ void __mmu_notifier_invalidate_range(struct mm_struct *mm, hlist_for_each_entry_rcu(subscription, &mm->notifier_subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { - if (subscription->ops->invalidate_range) - subscription->ops->invalidate_range(subscription, mm, - start, end); + if (subscription->ops->arch_invalidate_secondary_tlbs) + subscription->ops->arch_invalidate_secondary_tlbs( + subscription, mm, + start, end); } srcu_read_unlock(&srcu, id); } @@ -616,6 +617,15 @@ int __mmu_notifier_register(struct mmu_notifier *subscription, mmap_assert_write_locked(mm); BUG_ON(atomic_read(&mm->mm_users) <= 0); + /* + * Subsystems should only register for invalidate_secondary_tlbs() or + * invalidate_range_start()/end() callbacks, not both. + */ + if (WARN_ON_ONCE(subscription->ops->arch_invalidate_secondary_tlbs && + (subscription->ops->invalidate_range_start || + subscription->ops->invalidate_range_end))) + return -EINVAL; + if (!mm->notifier_subscriptions) { /* * kmalloc cannot be called under mm_take_all_locks(), but we