Skip to content

Fixup page directory freeing

Peter Zijlstra linux-arch linux-mm linux-sh lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest11 patches 2 repliesIn review
  2. v117 patches 19 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11asm-generic/tlb: Fix MMU_GATHER_TABLE_FREEinclude/asm-generic/tlb.h+19 -161 reply
2/11sh/tlb: Fix PGTABLE_LEVELS > 2arch/sh/include/asm/pgalloc.h+1 -90 replies
3/11sh/tlb: Fix __pmd_free_tlb()arch/sh/Kconfig arch/sh/include/asm/pgalloc.h arch/sh/mm/pgtable.c+9 -10 replies
4/11sparc32/tlb: Fix __p*_free_tlb()arch/sparc/Kconfig arch/sparc/include/asm/pgalloc_32.h arch/sparc/mm/srmmu.c+34 -20 replies
5/11parisc/tlb: Fix __p*_free_tlb()arch/parisc/Kconfig arch/parisc/include/asm/pgalloc.h arch/parisc/include/asm/tlb.h+26 -70 replies
6/11mips/tlb: Fix __p*_free_tlb()arch/mips/Kconfig arch/mips/include/asm/pgalloc.h arch/mips/mm/pgtable.c+41 -70 replies
7/11ia64/tlb: Fix __p*_free_tlb()arch/ia64/include/asm/pgalloc.h+10 -30 replies
8/11alpha/tlb: Fix __p*_free_tlb()arch/alpha/include/asm/tlb.h+11 -20 replies
9/11nds32/tlb: Fix __p*_free_tlb()arch/nds32/include/asm/tlb.h+6 -10 replies
10/11riscv/tlb: Fix __p*_free_tlb()arch/riscv/include/asm/pgalloc.h+6 -50 replies
11/11m68k/tlb: Fix __p*_free_tlb()arch/m68k/Kconfig arch/m68k/include/asm/mcf_pgalloc.h arch/m68k/include/asm/motorola_pgalloc.h +1 more+30 -120 replies

Reviews trailers per patch

1 of 11 patches has a Reviewed-by or Acked-by.

PatchGeert Uytterhoeven
1/11
2/11R-b T-b
3/11
4/11
5/11
6/11
7/11
8/11
9/11
10/11
11/11

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/11] Fixup page directory freeing

Hi All,

While fixing a silly bug on SH (patch #1), I realized that even with the trivial patch to restore prior behaviour, page directory freeing was still broken.

The thing is, on anything SMP, freeing page directories should observe the exact same order as normal page freeing:

1) unhook page/directory
2) TLB invalidate
3) free page/directory

Without this any concurrent page-table walk could end up with a Use-after-Free. This is esp. trivial for anything that has software page-table walkers (HAVE_FAST_GUP / software TLB fill) or the hardware caches partial page-walks (ie. caches page directories).

Even on UP this might give issues, since mmu_gather is preemptible these days. An interrupt or preempted task accessing user pages might stumble into the free page if the hardware caches page directories.

So I've converted everything to always observe the above order, simply so we don't have to worry about it.

If however I've been over zealous and your arch/mmu really doesn't need this and you're offended by this potentially superfluous code, please let me know and I'll replace the patch with one that adds a comment describing your rationale for why it is not needed.

v1: https://lkml.kernel.org/r/[email protected]