From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0FF9267F57; Tue, 8 Apr 2025 12:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744116002; cv=none; b=XXQ8+ohFJx5C/CUb75DF/XMtp7t3d5tDkZ1QkRJQ6cq2NfwEFvUqdeOvIy0mVBvuGctGswJtnV9xHeK0g9VwV6s4WIzUJeXGxTanX+/8NEXvhXgSSt08um1KKWc+i+gkmg/Hy46Q5sNh+FaudCi8Y6OWYmBiMBcXCuL3+k06qfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744116002; c=relaxed/simple; bh=NkixqNOh1oNgSNP1oIpnTV4s3KBN0xuioamD6bpdzVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j+nEjoOXNGTcWE9Rd+IRLZhIHJs9Epg2cJOPtaZ1F0EB90tQkiPSkr3ylZ9L+O5S6vcIjae/scd344KCD0xhXlEAe2GGKDNn61FP95FacD4ayc1QIjnG75XVZwIiuEmmN8oJVO0yKJapsAAcwD8/MD64qh5q5YebbjcFbkuBj7g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JZKNi13d; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="JZKNi13d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F380C4CEE5; Tue, 8 Apr 2025 12:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744116002; bh=NkixqNOh1oNgSNP1oIpnTV4s3KBN0xuioamD6bpdzVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZKNi13d37IpdpWPsFbik+Inz4zfPrZ6hwXTpJBDXqiUB9CrZAfEeh6p0q6i6rcwy kArbwge4i068Lm8kyw2pXLX4trVftlbPKMKnwUybdwQx3eRHYM2gQ1Iomn9Stucffu CzAojd9lnxJuNMMevFUNB8dkzdVMXVdg7nKypWmM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jann Horn , "Peter Zijlstra (Intel)" Subject: [PATCH 6.1 184/204] x86/mm: Fix flush_tlb_range() when used for zapping normal PMDs Date: Tue, 8 Apr 2025 12:51:54 +0200 Message-ID: <20250408104825.719044871@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104820.266892317@linuxfoundation.org> References: <20250408104820.266892317@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jann Horn commit 3ef938c3503563bfc2ac15083557f880d29c2e64 upstream. On the following path, flush_tlb_range() can be used for zapping normal PMD entries (PMD entries that point to page tables) together with the PTE entries in the pointed-to page table: collapse_pte_mapped_thp pmdp_collapse_flush flush_tlb_range The arm64 version of flush_tlb_range() has a comment describing that it can be used for page table removal, and does not use any last-level invalidation optimizations. Fix the X86 version by making it behave the same way. Currently, X86 only uses this information for the following two purposes, which I think means the issue doesn't have much impact: - In native_flush_tlb_multi() for checking if lazy TLB CPUs need to be IPI'd to avoid issues with speculative page table walks. - In Hyper-V TLB paravirtualization, again for lazy TLB stuff. The patch "x86/mm: only invalidate final translations with INVLPGB" which is currently under review (see ) would probably be making the impact of this a lot worse. Fixes: 016c4d92cd16 ("x86/mm/tlb: Add freed_tables argument to flush_tlb_mm_range") Signed-off-by: Jann Horn Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20250103-x86-collapse-flush-fix-v1-1-3c521856cfa6@google.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/tlbflush.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -228,7 +228,7 @@ void flush_tlb_multi(const struct cpumas flush_tlb_mm_range((vma)->vm_mm, start, end, \ ((vma)->vm_flags & VM_HUGETLB) \ ? huge_page_shift(hstate_vma(vma)) \ - : PAGE_SHIFT, false) + : PAGE_SHIFT, true) extern void flush_tlb_all(void); extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,