From patchwork Wed Jul 19 12:18:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13318868 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 4BBB0EB64DA for ; Wed, 19 Jul 2023 12:19:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E18E1280058; Wed, 19 Jul 2023 08:19:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC9EF28004C; Wed, 19 Jul 2023 08:19:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4303280058; Wed, 19 Jul 2023 08:19:38 -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 B4B1728004C for ; Wed, 19 Jul 2023 08:19:38 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 87749A0158 for ; Wed, 19 Jul 2023 12:19:38 +0000 (UTC) X-FDA: 81028267236.23.44C7B5B Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2045.outbound.protection.outlook.com [40.107.244.45]) by imf12.hostedemail.com (Postfix) with ESMTP id D03F640019 for ; Wed, 19 Jul 2023 12:19:34 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="Kk9d2h/U"; spf=pass (imf12.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.45 as permitted sender) smtp.mailfrom=apopple@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1689769174; a=rsa-sha256; cv=pass; b=vs+tfxcT9m6smRtZ1fFw4gY0PXE2L/7jrjF9XJZ30yz0WjUDw/Ib76P8exWPPowFOfdJa8 2frmBUefQPL+y4qheeEFkG1sfi50v8QJ/B+WHojLahGgeCNUWtgGdMnj3nIhG2JoIhiu/2 rLGJLskJBF965QGeKjxLMc1IYgiL13U= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="Kk9d2h/U"; spf=pass (imf12.hostedemail.com: domain of apopple@nvidia.com designates 40.107.244.45 as permitted sender) smtp.mailfrom=apopple@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689769174; 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=E7ln65n/Hpq4F8/Xi4Ld2pMN/wvlMSEVhslNm/lYul8=; b=NQ1CixIy091QlhhbeP8R+/ARY/sqN8lVDKVpbJw1QgqepiMXightCVlOFlzzETaQEH4lWF MRQi+atZyN3XnVyAcODeYUArNjp1VE++V8+5FYLG+WpiBtiuTljEHnsw+u2o+iMXNx1Q8G +l9uSZN4lhQpzCiBY6khBHrR79RL3MI= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lT4Hn+0PVVo3rDt+eWn5r8qKuc3X4dogYNmojWkqrNbDA1P1CF2PVBR+KP9NG0otGbj7ARI5HJc55SVuV+JM67c6GAkobLC0FeVrF4OqCYnkpV12zDjG1ESc0MGY0cx6iwCC7pbwCweSu4uquV00fikp4kFmcIudJke1wgtEHKC2kLkcs4A53vDGWz455m0+aiSdpgJqb9xF64CUMlUj6nHhLWFrvTmfPyDl8RNTzvwaxaCOeYwe6Xuw+uRgaCmM8KSyLc7uYEmLNxnKDBEWpSkiTY06ukY7hHmmTem5ccU/GoOCayLUJ441UgX1K4RTe8rbezmQh1R65trsPP7MIA== 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=E7ln65n/Hpq4F8/Xi4Ld2pMN/wvlMSEVhslNm/lYul8=; b=av9IOjAfkTccCOaG7Roau4LZeCgkjJI8KG5801kht/tx2V1cHJMqWKWwjq7J8jgmcQy/hrVtXbSoEhpvkmRNKNBFAlMAwNaUJi6lOQEI0vCtc8KbLRHZ5gUBOUaoCy2oRAmQ1hjLH0HWqjf2Jrfhr+3uWprBa3UWKGrN7UehRte6ELSGZNsflVEqpaG0QqhnF7Sqwk6TycvyCJj/WH/4X3iYnmlTJdY9MBF1dcuJErEWKZTVO70UULtOIwrbTOsUboDaGUopmRWVAgA2YWpu4BLeEgT/PaK45dguTPpOfOSsp1r7X4pol/pODo2vMl1PLzDFe/+E5ZDSPFo9FAmQ0Q== 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=E7ln65n/Hpq4F8/Xi4Ld2pMN/wvlMSEVhslNm/lYul8=; b=Kk9d2h/UXu8tHao5JqM+1d+vCXPa9l8xGIjEBGf+Dct6lhHNPTrdeEji4/x6VUQd100CAFLhiJObP/IImT1pABxZlyFbd7cOUnIDDgU0mRFh8wBUa/3ocWYOjR4Qx3bFpCpPBCWQYy5I8LRZfufNB4M5bL0bu5f4QIJ/mOS9SuRhMmItD6CAqOGThlsaZk86z65UezDedI6bVe6rJQe6ZFPwcohIFlz5jAxfHhRf895ZaOc9HeAXn6b5eyFs3c3hnOKfmFCN9s6wJqTY59bQDAUzTpaG3KnGbu+FFz5l1IwaSJTR5/zDDl5QG+zYkEgZgfC3o60lKz78rZ3aeWziDw== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by DM4PR12MB5359.namprd12.prod.outlook.com (2603:10b6:5:39e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Wed, 19 Jul 2023 12:19:32 +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.6588.031; Wed, 19 Jul 2023 12:19:32 +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, Alistair Popple Subject: [PATCH v2 3/5] mmu_notifiers: Call invalidate_range() when invalidating TLBs Date: Wed, 19 Jul 2023 22:18:44 +1000 Message-Id: <8f293bb51a423afa71ddc3ba46e9f323ee9ffbc7.1689768831.git-series.apopple@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SY6PR01CA0013.ausprd01.prod.outlook.com (2603:10c6:10:e8::18) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3176:EE_|DM4PR12MB5359:EE_ X-MS-Office365-Filtering-Correlation-Id: bec1a96b-0b83-4e70-ea91-08db8852681e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EtM+koDEZOdci30wx6IY9TSUmvjAhX0GGnKtEVLQsdAbRVZUd+MGCxgdIMOuFqYh+h/8Hyrorrzu+RlGct/iQqczUAdCvxYHLODwTG4xiCHmZzyhMEk+mN8VK2+eDWOwGPyac50mHkkQph0eR2OAJZa8Q9vq1ROxaVi3Ovu7+GNfg4fVvnFJjs1vjXk/WLbqJ8MVEYDp584KLAVgXxJytMN7aWzE6EWiZHmH7xtKoTrIeyJigJS3Ri3CL1HNT1XysVZ+C5XXdQqPxrJppuMmsGpFkeZ1esW0e/eu90a9pMxCvzTaFRMdDtviCb09hddMupdIJyO6V5/OXc/N2jjVBGIx0io4MMixuSHz7EE37Ag2GgBckOZQIU5BUi8m/2SyySYpeHH9mGe++YuGesC+jwiX3hcTh4sdiu2TV2AAq8JI285sydnT3FyImVgGDCzfQldXTo0agCmT+vep+tzbTF/6u8t+0W2wIWVLlrxzf60AsSwmsA1j4S2k3uAalqVbAIfj7oQi1f4X1I5JfLl62x3QrZgykb/9jsnGxcyVqa8y0iYuwgbjfmGercoPHKU7zVJvJTJU01ZbKNTemzij4W94aQnpNTr0IBDXjSt3FgIB2sEDxwGndi2sAHw36JFd 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)(396003)(39860400002)(376002)(366004)(136003)(346002)(451199021)(26005)(5660300002)(8936002)(478600001)(8676002)(6506007)(83380400001)(2616005)(107886003)(2906002)(6512007)(38100700002)(316002)(186003)(7416002)(66946007)(66476007)(66556008)(6666004)(6916009)(4326008)(6486002)(86362001)(36756003)(41300700001)(473944003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 60km7DvzxHdwrqsIpGcxs/Q3i0aOP5via7XTlHRCeP5RCZX+FGHUuIJNn+xBbR35KEFEOxglvfFYoIyEAnWKZLR0MvMYIXSgmkzc7VwQAZ7h+VFpxnKspk/OiAXOvVYiLVbdRir8AzBzaNYFjCuez2bTim4YDD5NIm37p/7+R8dOTXVU/4NyUpouXbLQOVVwA/bl9FRJuwP2jGXJj6ZPBNyoOb0rmd8mQObWwL2gQKHLmIRgAWZPEYdYIy7QyyPUQ8PLBnjSsSXXquaoTHxhEHyh9b8O/YIb1d5hcSXIxmhgFdN6svKIseLGTzPX6k5ySv9p8eO9icoqmI8g9aX1FAtavUlP4ZBBejE4jYnRE9HW/+ntEj/mg08RHLVPCuKZFpxth+heJcCXbLyv3wPCDngVmBlJTbjG4bvm8IJJawCWMB0eswXWhCchTqO4Tu4mfDiJJiyTLgRA7tT9XhmD1O8ILpBuHXP4EuvaMMCYu8U1w/Og323aovjE3ZV8IhD1FvoZfpFgINqxgP6IVBY4Y9K0vAqaNWYV2Kg6S7Sbrcm18BP6ORCCuexknZ5XDN3Q7YhXVY1V2cjfhyE1A8nUViX/xem5LflXdnSkAHnftKyfBgIQ4+RyrEZ8W1ABLwBa5xAH1hR/OLXHwtb+W4P6ZNhWsBzhMxrZGRpwo81xcgUpo0t54MztmLi7mVmxMOhwREEeG1Hu4ESKClxwcvRX7GsVsvW5dbKFTP8TaX4PgjQxmfrSzMalTDZMYVbhjOEMJznKnMt4zmC60l2E7DrTMGu7f6+UlhGkIjU6taoR6v6sx4rk3EYBUjUSkyINz/GpvzAT/fiT3ittFCtVWM2ZYaBpepYLzPug68AAFe7+Ex1M+jFvtgXxshdbwD9ij52VoESxEb8n+cc1OFeVI8x+m9fqMHOGYy9znsz4S/COsSacqQBPgkim7eawwfFLkGViHQhaiInNDUz6nlDiEaBkbwTmFjOMtwLHXL6oShdgK3lknRDLQJEyhi+P2YUzXkmeSjNi6LyGVAes62sqmtUfRx69oXc1Fn1sTv11NmqG06FGvwI3DU/V2zHAotTepKb3rfb8n9OWi9z4OHqgAOMlIyduLr7N86hlQsxRP2rmbfRJTp8K4YHflMkx57stGROgdX8PUqvsp3Z0ZygSUynv5Hh9hVntKZxXprD+V8V5RaI0qb02r62Qj/50pzFXW6C8Gk98cVffb8XvklDwte8B6Ui6NhjySxlYhbHAkl8moyLc+5N1nFCCeM6xw98xlmJRw+tUEY9e5PWXNx8pONa5clk6lMI1w0WhSbhPdfmcVKVT4TaitAAih/l0yCri8J7py1iPe1p5UaGkC5c0DFk046k96kHJ9IodIGj74ppWO60jq4BWCLIqn6VWCYom98FzuNYGF7saarzNMty8pxqCrAgVfvJFESAxu3KeL4aoYMmvkchNaV/kw+In3ynUw5w2uzp9WasuEZN8zFUUnnZa0+ivs1ZR7fHFmCod2W46vKDsqMIWl5CeO0WEbOpD6v//hLUZIrCBJ96SkwDYbk/adSDN70D36XVMo6IOW2d7/+cdPB4KcUzsjR0oI+bZNxFj X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bec1a96b-0b83-4e70-ea91-08db8852681e X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 12:19:31.9847 (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: H3fNEqTHibnay/bQtxw1p9JiEFoELxCfoOlQxAKb+feCYhlvr7bVZ3tkdpEzC6pcdqnILdxLUZXTMqEeJ2mCpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5359 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D03F640019 X-Stat-Signature: errdkf9eu1ct1znr3ib5oke93p79in7o X-Rspam-User: X-HE-Tag: 1689769174-948423 X-HE-Meta: U2FsdGVkX18yVYGEuYSlniQ/rdBWIkHbZ0IQcarRV2d4N4Tu2WzTz7N7yhXdo3JW6l5t1VWIGXeQx8cNcHCwEgPT7m+TNVgeLB0EOvFx/dcHpijVJyAG7XmB60nNNGl6Y/6ONrso+tNPDgDOcmeQXN64B5hvnDrMDbjQmspB7BBS9MtYDOGv9530sti8XSe7d+hsSthbdeAK6yKeT0Z7R80RXoDuwIQpGak83hnMroq0UzG9H6esQ78epAeDioU5zuo1mUODiT/6jvnEAEbs8honUABSbKv42Pxf/nqfUqyrqCDOPDI9ht8tK6XD1ZwkzZ+c5F67p7KZ9OXYD+rlE6HRuI5Q5DI7O4k4/U9rL0WynXPSdfQH6agn8vxc8uExoHuNoexkkO1nbLrPc0WtRNgL2qV2/ORYr6YlRKrJslU8fMyL9xCFsHrSPrP1k3XzrkR05Dl+7pDEg2Ucs2HtPgGNZCvoCuc4y4ySjRa5RO4wvL0aCb5aHUIFKd1w+4wYYJwSRZKOiV6N+gw34vKwtnhcZ+GUBHF506txJ8utYZzXxouYcpUCSn+dSwAconNcQI28Zm1RdOGpUtFJ9HUXbYEFBOG+A7u/McMuCs6SLgQuNPAWolL/tOL9KMUVIjSsPmMAiRWiBgjWhQ2MXQaDxEbEzJB6izu29y1zTNO9wvpCSgAOm/k48ziYWHsLRta+STPWJ0YexwDZJSqzgSdkuT0rl3hdowYfrqKjer1VRt4NtCyZSUEFXnwCyH2pcggVd8KjxIP+sEY31Qcvvb4J7x1YQ4/0/rgs7iI+VkIdSnMthPhV5UgnimgmdOzQBDjiMH1aISu2+cLl3tM9ouTB2xZfyE/KMHxmW+/K9t0XAX6Vl6FwCAtcRQmnoXd67vA5aJ+Y+j/cAVsSJPhVPyoaCD8W25X4QtxV+JbrGSJer0r9ZY9PXTa8j1KTaokdeFY4PlorptidJAVqb9tKCNS 9T9nEhja RRwGMuyV5e4nve6NruTmW+UYVt6hAzUTV+INKk+iRqNxRF1cVyCsSmTnMw+tm5tsjwOJ/nBgkyoGcZyUxUorOY+081OTG7owDFriucGijXKq6ND6LnL023XLN9Ypp0t3+UnSxelR1eq7zL7CsQdpT5Z9UWvMlgm/oD2Q1Vb/G6T/SDTkYoq1vS7RBwBrSWUHT9dj9GG6KusSNHS9DSB8ySTmI2IzJI/LdlGDnSRZX5Fi9bH5jHniyksDWYbnUKTioSeNMKDrtigzvBhq368iUMItLadjT6s++hc+13yNXIYld7004m1Av+pGiF09O+n0jGYF6akPjMMrQaHdZymg4DR86VztSkl7nvXYEzTI4XUTXti/1teDeEm2IOqBLE8d1CqtAN35q9PaB42FfwRSP+u9b3Q== 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 Tested-by: Luis Chamberlain --- 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/mm/tlb.c | 3 +++ include/asm-generic/tlb.h | 1 - 6 files changed, 16 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/mm/tlb.c b/arch/x86/mm/tlb.c index 267acf2..c30fbcd 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); } @@ -1263,6 +1265,7 @@ void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch) put_flush_tlb_info(); put_cpu(); + mmu_notifier_invalidate_range(current->mm, 0, -1UL); } /* 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); }