From patchwork Wed Jan 27 23:53:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12051285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABC93C433E0 for ; Wed, 27 Jan 2021 23:54:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 52EC964DDA for ; Wed, 27 Jan 2021 23:54:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52EC964DDA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E04CB6B0073; Wed, 27 Jan 2021 18:54:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D8E206B0074; Wed, 27 Jan 2021 18:54:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7DE26B0075; Wed, 27 Jan 2021 18:54:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AEC0E6B0073 for ; Wed, 27 Jan 2021 18:54:26 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6E7C5181AEF21 for ; Wed, 27 Jan 2021 23:54:26 +0000 (UTC) X-FDA: 77753211732.03.train24_1e0142e2759b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 75A7528A4EB for ; Wed, 27 Jan 2021 23:54:23 +0000 (UTC) X-HE-Tag: train24_1e0142e2759b X-Filterd-Recvd-Size: 3292 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Jan 2021 23:54:22 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id CC12A64DD8; Wed, 27 Jan 2021 23:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611791662; bh=IyZMRWubT8lewmjSA1zCALq266sCXPZZNFPDHqaC0PM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWUS5LgFUC38pCI71/9L1l4fG+UqwNtejoeFafHg6Opxuj5zux3Zgvil3KNvoR+Qu FB12Xm/6QISjiHzzIR4nKYnZ68pvnOmA1Sq8/MqXgHBYPXETKcT/W3JuPhxwXu/LVT IxJ99r3cqYRABvaq4e6Iw4dkFi9/g12w05brbvmKeJPLZXj+23q5g0YvZcS1NuR2Z1 GEM1cMlQaPT08Bw5Cxd284FOJvNuTEuFDWiuknSjYygZ7elJde7dDBNsrXV/zi169+ sODYHg9f8HyO7y8LXdpy53eMPY3mt16Z92yPrIcQM5qPFBVkMwMUxNOItBEUuyj4dA zIOyfGDsTEjIA== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, linux-mm@kvack.org, Will Deacon , Yu Zhao , Minchan Kim , Peter Zijlstra , Thomas Gleixner , Linus Torvalds , Vlastimil Babka , Mohamed Alzayat , "Aneesh Kumar K.V" , Nadav Amit , Andrea Arcangeli Subject: [PATCH v3 6/6] x86/ldt: Use tlb_gather_mmu_fullmm() when freeing LDT page-tables Date: Wed, 27 Jan 2021 23:53:47 +0000 Message-Id: <20210127235347.1402-7-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210127235347.1402-1-will@kernel.org> References: <20210127235347.1402-1-will@kernel.org> MIME-Version: 1.0 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: free_ldt_pgtables() uses the MMU gather API for batching TLB flushes over the call to free_pgd_range(). However, tlb_gather_mmu() expects to operate on user addresses and so passing LDT_{BASE,END}_ADDR will confuse the range setting logic in __tlb_adjust_range(), causing the gather to identify a range starting at TASK_SIZE. Such a large range will be converted into a 'fullmm' flush by the low-level invalidation code, so change the caller to invoke tlb_gather_mmu_fullmm() directly. Cc: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Reviewed-by: Yu Zhao Signed-off-by: Will Deacon --- arch/x86/kernel/ldt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index 7ad9834e0d95..aa15132228da 100644 --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -398,7 +398,13 @@ static void free_ldt_pgtables(struct mm_struct *mm) if (!boot_cpu_has(X86_FEATURE_PTI)) return; - tlb_gather_mmu(&tlb, mm); + /* + * Although free_pgd_range() is intended for freeing user + * page-tables, it also works out for kernel mappings on x86. + * We use tlb_gather_mmu_fullmm() to avoid confusing the + * range-tracking logic in __tlb_adjust_range(). + */ + tlb_gather_mmu_fullmm(&tlb, mm); free_pgd_range(&tlb, start, end, start, end); tlb_finish_mmu(&tlb); #endif