sst-linux/arch/x86
Jann Horn 0708fd6bd8 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: 016c4d92cd ("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:33:42 +02:00
..
boot x86/boot: Use '-std=gnu11' to fix build with GCC 15 2025-02-21 13:49:46 +01:00
coco x86/tdx: Fix "in-kernel MMIO" check 2024-10-17 15:21:29 +02:00
configs x86/defconfig: Enable CONFIG_DEBUG_WX=y 2022-09-02 10:41:42 +02:00
crypto crypto: x86/aegis128 - access 32-bit arguments as 32-bit 2024-12-14 19:53:58 +01:00
entry x86/entry: Fix ORC unwinder for PUSH_REGS with save_ret=1 2025-04-10 14:33:35 +02:00
events perf/x86/intel: Avoid disable PMU if !cpuc->enabled in sample read 2025-04-10 14:33:42 +02:00
hyperv x86/hyperv: Fix the detection of E820_TYPE_PRAM in a Gen2 VM 2023-12-20 17:00:21 +01:00
ia32 x86: Remove a.out support 2022-04-11 18:04:27 +02:00
include x86/mm: Fix flush_tlb_range() when used for zapping normal PMDs 2025-04-10 14:33:42 +02:00
kernel x86/tsc: Always save/restore TSC sched_clock() on suspend/resume 2025-04-10 14:33:42 +02:00
kvm KVM: SVM: Drop DEBUGCTL[5:2] from guest's effective value 2025-03-13 12:53:21 +01:00
lib x86/kmsan: Fix hook for unaligned accesses 2024-09-12 11:10:19 +02:00
math-emu
mm x86/sev: Add missing RIP_REL_REF() invocations during sme_enable() 2025-04-10 14:33:30 +02:00
net bpf, x64: Fix a jit convergence issue 2024-10-17 15:22:13 +02:00
pci PCI: Detect and trust built-in Thunderbolt chips 2024-12-14 19:54:47 +01:00
platform x86/platform/iosf_mbi: Convert PCIBIOS_* return codes to errnos 2024-08-03 08:48:54 +02:00
power x86/pm: Add enumeration check before spec MSRs save/restore setup 2022-11-21 14:16:16 +01:00
purgatory x86/purgatory: Switch to the position-independent small code model 2024-06-12 11:03:12 +02:00
ras
realmode x86/boot: Skip realmode init code when running as Xen PV guest 2022-12-31 13:32:16 +01:00
tools x86/boot: Ignore relocations in .notes sections in walk_relocs() too 2024-06-12 11:03:07 +02:00
um um: Fix the -Wmissing-prototypes warning for get_thread_reg 2024-06-12 11:03:47 +02:00
video
virt/vmx/tdx
xen Grab mm lock before grabbing pt lock 2025-02-21 13:49:59 +01:00
.gitignore x86/purgatory: Omit use of bin2c 2022-07-25 10:32:32 +02:00
Kbuild x86/cc: Move arch/x86/{kernel/cc_platform.c => coco/core.c} 2022-02-23 18:25:58 +01:00
Kconfig x86/platform: Only allow CONFIG_EISA for 32-bit 2025-04-10 14:33:30 +02:00
Kconfig.assembler x86/delay: Introduce TPAUSE delay 2020-05-07 16:06:20 +02:00
Kconfig.cpu x86/Kconfig: Transmeta Crusoe is CPU family 5, not 6 2024-02-23 09:12:43 +01:00
Kconfig.debug x86/kconfig: Select ARCH_WANT_FRAME_POINTERS again when UNWINDER_FRAME_POINTER=y 2024-06-12 11:03:50 +02:00
Makefile x86/build: Move '-mindirect-branch-cs-prefix' out of GCC-only block 2023-02-09 11:28:13 +01:00
Makefile_32.cpu x86/build: Do not add -falign flags unconditionally for clang 2021-09-19 10:35:53 +09:00
Makefile.um um: Only disable SSE on clang to work around old GCC bugs 2023-05-01 08:26:27 +09:00