twx-linux/arch
Jann Horn 7085895c59 x86/mm: Fix flush_tlb_range() when used for zapping normal PMDs
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
<https://lore.kernel.org/all/20241230175550.4046587-13-riel@surriel.com/>)
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 <jannh@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
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 <gregkh@linuxfoundation.org>
2025-04-10 14:37:42 +02:00
..
alpha alpha/elf: Fix misc/setarch test of util-linux by removing 32bit support 2025-03-22 12:50:41 -07:00
arc ARC: build: Try to guess GCC variant of cross compiler 2025-01-09 13:32:05 +01:00
arm ARM: Remove address checking for MMUless devices 2025-04-07 10:06:36 +02:00
arm64 arm64: dts: rockchip: fix u2phy1_host status for NanoPi R4S 2025-03-28 21:59:56 +01:00
csky of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-09 10:31:56 +01:00
hexagon hexagon: Fix unbalanced spinlock in die() 2025-02-08 09:52:34 +01:00
ia64 vgacon: rework screen_info #ifdef checks 2024-06-27 13:49:15 +02:00
loongarch LoongArch: BPF: Use move_addr() for BPF_PSEUDO_FUNC 2025-04-10 14:37:41 +02:00
m68k m68k: vga: Fix I/O defines 2025-02-17 09:40:15 +01:00
microblaze of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-09 10:31:56 +01:00
mips mm: hugetlb: Add huge page size param to huge_ptep_get_and_clear() 2025-03-13 12:58:38 +01:00
nios2 of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-09 10:31:56 +01:00
openrisc openrisc: Use asm-generic's version of fix_to_virt() & virt_to_fix() 2024-12-11 16:13:43 +01:00
parisc mm: hugetlb: Add huge page size param to huge_ptep_get_and_clear() 2025-03-13 12:58:38 +01:00
powerpc spufs: fix a leak in spufs_create_context() 2025-04-10 14:37:38 +02:00
riscv riscv: Fix hugetlb retrieval of number of ptes in case of !present pte 2025-04-10 14:37:39 +02:00
s390 mm: hugetlb: Add huge page size param to huge_ptep_get_and_clear() 2025-03-13 12:58:38 +01:00
sh sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK 2024-12-09 10:32:50 +01:00
sparc mm: hugetlb: Add huge page size param to huge_ptep_get_and_clear() 2025-03-13 12:58:38 +01:00
um um: remove copy_from_kernel_nofault_allowed 2025-04-10 14:37:34 +02:00
x86 x86/mm: Fix flush_tlb_range() when used for zapping normal PMDs 2025-04-10 14:37:42 +02:00
xtensa of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-09 10:31:56 +01:00
.gitignore
Kconfig Revert "mm: mmap: allow for the maximum number of bits for randomizing mmap_base by default" 2024-06-27 13:49:15 +02:00