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 6D1B826A0C8; Tue, 8 Apr 2025 12:01:06 +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=1744113666; cv=none; b=XeEd9gB76ksuFeRULMrUYT1aHm5en2VAvY63qIkj1zAqs0daQliRTUD46qyKmxcdA3cKKDxluBc+17kbQDCHK4chUZooG2KazsRj8yE6ixZZRYnUlydSkqYwi9aOp7OVHeCdKiJETKXz47fVki4zpTi+oSgTf/YRNwR/lIl405k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744113666; c=relaxed/simple; bh=VMXsF97yM5q1kAggVbHP7ylilVvvUTMRJahfWntWADM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QkjnTghgDjwPCf/2nnv2UWFVkdsU3XCRXNKyJl2BPkqkDjIHNsqz/oxwBp8ZcdQrLUlfNoXbu9xAMuXWMptYtgtWJy11IPDHqFlVsJUZ0XGT1yGUhHXPdh4RqKXNIWOv1BARDG+1EvFP853T8VozLmX25CPGILDoHN2RMKzgcnY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BhkKuzcW; 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="BhkKuzcW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED509C4CEE7; Tue, 8 Apr 2025 12:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744113666; bh=VMXsF97yM5q1kAggVbHP7ylilVvvUTMRJahfWntWADM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BhkKuzcWldWEmY0IbTwrAzeN/8HamrxbcsTy2mtX8YecCPKD6gE2xUb85enoh5xIk ziKJ4Mr/2RVYJGydFxx9Vg11OX1TpB3Nm1gIqkEnidHkY/gec5Y7S8Jhmkta8THugU mRaypnQHw0YdZMxIu+KCppsT1Wy6vDxcwPZz4mbg= 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.6 245/268] x86/mm: Fix flush_tlb_range() when used for zapping normal PMDs Date: Tue, 8 Apr 2025 12:50:56 +0200 Message-ID: <20250408104835.193851984@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104828.499967190@linuxfoundation.org> References: <20250408104828.499967190@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.6-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 @@ -242,7 +242,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,